-
-
Notifications
You must be signed in to change notification settings - Fork 230
Armv6 support #761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jkiddo
wants to merge
8
commits into
dtcooper:master
Choose a base branch
from
jkiddo:armv6-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Armv6 support #761
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3734d47
Add ARMv6 (Pi 1 / Pi Zero v1.x) build target
jkiddo b2a66d6
armv6: statically link OpenSSL for cross-release portability
jkiddo 9921073
armv6: dynamically link OpenSSL and fold docs into the build
jkiddo 2941942
Corrections to distro
jkiddo 72bd9eb
armv6: simplify sysroot prep and libssl dependency
jkiddo fdd838a
armv6: extract sysroot prep into a script, add GCC_VERSION
jkiddo 777ed07
simplifying configuration knobs but retaining checks
jkiddo d08c083
Merge branch 'dtcooper:master' into armv6-support
jkiddo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # syntax=docker/dockerfile:1 | ||
| # | ||
| # ARMv6 builder image (Raspberry Pi 1 / Zero v1.x, ARM1176JZF-S + VFPv2). | ||
| # Debian's armhf is ARMv7-baseline and SIGILLs on an ARM1176, so we: | ||
| # - link against a Raspbian ARMv6 sysroot and its v6 startfiles, not Debian's | ||
| # ARMv7 crt*.o; | ||
| # - build librespot with native-tls, not rustls (ring ships ARMv7/NEON asm). | ||
| # OpenSSL links dynamically, so the .deb depends on libssl3. | ||
| # | ||
| # `make armv6` (needs Docker QEMU/binfmt for linux/arm/v6) -> standalone | ||
| # raspotify_*_armv6.deb, not served from the apt repo. | ||
|
|
||
| # ---- Stage 1: Raspbian ARMv6 sysroot ---------------------------------------- | ||
| # Install the dev libs under emulation, then copy the rootfs out as a cross | ||
| # sysroot (below). bookworm is the oldest suite with ARMv6 Raspbian on glibc | ||
| # >= 2.34 / libssl.so.3, so it gives the widest runtime compatibility; the | ||
| # binary runs on bookworm and newer. | ||
| FROM --platform=linux/arm/v6 balenalib/rpi-raspbian:bookworm AS sysroot | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| gcc \ | ||
| libc6-dev \ | ||
| pkg-config \ | ||
| libasound2-dev \ | ||
| libpulse-dev \ | ||
| libssl-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # ---- Stage 2: build environment -------------------------------------------- | ||
| FROM rust:bullseye | ||
|
|
||
| ENV INSIDE_DOCKER_CONTAINER=1 \ | ||
| DEBIAN_FRONTEND=noninteractive \ | ||
| DEBCONF_NOWARNINGS=yes \ | ||
| PATH="/root/.cargo/bin/:$PATH" \ | ||
| CARGO_INSTALL_ROOT="/root/.cargo" \ | ||
| CARGO_TARGET_DIR="/build" \ | ||
| CARGO_HOME="/build/cache" \ | ||
| RPI_SYSROOT="/opt/rpi-sysroot" \ | ||
| V6GCC="/opt/v6gcc" | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get -y upgrade \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| build-essential \ | ||
| gcc-arm-linux-gnueabihf \ | ||
| cmake \ | ||
| git \ | ||
| bc \ | ||
| liblzma-dev \ | ||
| pkg-config \ | ||
| gettext-base \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| ; | ||
|
|
||
| # Bring in the Raspberry Pi OS ARMv6 sysroot built in stage 1. | ||
| COPY --from=sysroot / ${RPI_SYSROOT}/ | ||
|
|
||
| # Make that rootfs a cross-linking sysroot and stage its ARMv6 startfiles into | ||
| # ${V6GCC}; see prepare-armv6-sysroot.sh for the why of each step. | ||
| COPY prepare-armv6-sysroot.sh /usr/local/bin/prepare-armv6-sysroot.sh | ||
| RUN sh /usr/local/bin/prepare-armv6-sysroot.sh | ||
|
|
||
| RUN mkdir -p /build /.cargo \ | ||
| && rustup target add arm-unknown-linux-gnueabihf \ | ||
| && printf '[target.arm-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"\n' > /.cargo/config.toml \ | ||
| && cargo install --jobs "$(nproc)" cargo-deb \ | ||
| ; | ||
|
|
||
| RUN git config --global --add safe.directory /mnt/raspotify \ | ||
| && git config --global --add safe.directory /mnt/raspotify/librespot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #!/bin/sh | ||
| # vi: set noexpandtab sw=4 ts=4 sts=4: | ||
| # | ||
| # Turn the copied-in Raspberry Pi OS (Raspbian) ARMv6 rootfs into a sysroot the | ||
| # Debian cross gcc can link against, and stage its ARMv6 startup files for that | ||
| # link step. Run once when building the ARMv6 builder image (Dockerfile.armv6). | ||
| # | ||
| # Environment inputs: | ||
| # RPI_SYSROOT the Raspbian rootfs, fixed up in place (required) | ||
| # V6GCC a dedicated dir to collect the ARMv6 startup files in (required) | ||
| # | ||
| # gcc versions and library sonames are detected rather than hard-coded: they | ||
| # change if the Raspbian base image (Dockerfile.armv6) is bumped to a newer | ||
| # suite, so detecting keeps that a one-line change instead of breaking here. | ||
|
|
||
| set -eu | ||
| : "${RPI_SYSROOT:?RPI_SYSROOT must be set}" | ||
| : "${V6GCC:?V6GCC must be set}" | ||
|
|
||
| # The arm-linux-gnueabihf library dirs. Debian splits glibc across /lib and | ||
| # /usr/lib, so both may exist; fix up each in place. | ||
| for d in usr/lib/arm-linux-gnueabihf lib/arm-linux-gnueabihf; do | ||
| dir="$RPI_SYSROOT/$d" | ||
| [ -d "$dir" ] || continue | ||
|
|
||
| # Drop the static glibc archives: they reference loader internals that | ||
| # don't cross-link, so removing them forces ld onto the shared libs. | ||
| for name in pthread dl rt util anl resolv m c; do | ||
| rm -f "$dir/lib$name.a" | ||
| done | ||
|
|
||
| # glibc >= 2.34 folded pthread/dl/rt/util/anl/resolv into libc, leaving | ||
| # only empty stub .so.N files and dropping the unversioned lib<name>.so | ||
| # that "-lpthread", "-ldl", etc. need. Recreate each one pointing at its | ||
| # stub (ln -sfn also repairs a leftover dangling symlink). | ||
| for name in pthread dl rt util anl resolv; do | ||
| [ -e "$dir/lib$name.so" ] && continue | ||
| stub=$(ls -1 "$dir/lib$name.so."* 2>/dev/null | sort -V | tail -n1 || true) | ||
| [ -n "$stub" ] && ln -sfn "$(basename "$stub")" "$dir/lib$name.so" | ||
| done | ||
| done | ||
|
|
||
| # ld follows absolute symlinks against the builder's real "/", where the target | ||
| # is the host's ARMv7 lib or nothing ("cannot find -lm"). Re-point every | ||
| # absolute symlink (-lname '/*') at the same file inside the sysroot, relative. | ||
| find "$RPI_SYSROOT" -type l -lname '/*' | while IFS= read -r link; do | ||
| target=$(readlink "$link") | ||
| ln -sfn "$(realpath -m --relative-to="$(dirname "$link")" "$RPI_SYSROOT$target")" "$link" | ||
| done | ||
|
|
||
| # Debian's arm-linux-gnueabihf-gcc is only the link driver; by default it links | ||
| # the cross toolchain's ARMv7 startup files, which SIGILL on an ARM1176. Collect | ||
| # the sysroot's ARMv6 ones into V6GCC -- nothing else lives there -- so build.sh | ||
| # can pass "-B$V6GCC" and have gcc prefer them: | ||
| # - gcc's crt*.o (crtbegin*/crtend*) and libgcc.a, from its versioned dir | ||
| # - glibc's crt1.o/crti.o/crtn.o/Scrt1.o, from the lib dir | ||
| gcc_dir="$RPI_SYSROOT/usr/lib/gcc/arm-linux-gnueabihf" | ||
| gcc_ver=$(ls "$gcc_dir" | grep -E '^[0-9]+$' | sort -n | tail -1) # newest gcc major | ||
| [ -d "$gcc_dir/$gcc_ver" ] || { echo "no gcc found in $gcc_dir" >&2; exit 1; } | ||
| lib_dir="$RPI_SYSROOT/usr/lib/arm-linux-gnueabihf" | ||
|
|
||
| mkdir -p "$V6GCC" | ||
| cp "$gcc_dir/$gcc_ver/"crt*.o "$gcc_dir/$gcc_ver/libgcc.a" "$V6GCC/" | ||
| cp "$lib_dir/crt1.o" "$lib_dir/crti.o" "$lib_dir/crtn.o" "$lib_dir/Scrt1.o" "$V6GCC/" | ||
|
|
||
| echo "ARMv6 sysroot prepared; v6 startfiles staged in $V6GCC" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possible way to resolve the TLS discrepancies might be to use
native-tlsfor all architectures, if possible. That would be another PR though.