Skip to content

Commit cf61ede

Browse files
authored
Fix cross compilation for armv6hf (Raspberry Pi 1) (#1457)
* Use ring instead of aws-lc as the default backend for hyper-rustls Signed-off-by: Dariusz Olszewski <[email protected]> * Cross-compile with libmdns Signed-off-by: Dariusz Olszewski <[email protected]> * Simplify Docker image to cross-compile for armv6hf (RPi 1) Signed-off-by: Dariusz Olszewski <[email protected]> * Revert "Use ring instead of aws-lc as the default backend for hyper-rustls" This reverts commit faeaf50. * Fix bindgen issues (aws-lc-rs) when cross-compiling for armv6hf Signed-off-by: Dariusz Olszewski <[email protected]> * Add git to the Docker image for cross-compiling Signed-off-by: Dariusz Olszewski <[email protected]> --------- Signed-off-by: Dariusz Olszewski <[email protected]> Co-authored-by: Dariusz Olszewski <[email protected]>
1 parent 34762f2 commit cf61ede

4 files changed

Lines changed: 22 additions & 23 deletions

File tree

contrib/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
# The compiled binaries will be located in /tmp/librespot-build
99
#
1010
# If only one architecture is desired, cargo can be invoked directly with the appropriate options :
11-
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --no-default-features --features alsa-backend
12-
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features alsa-backend
13-
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features alsa-backend
14-
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features alsa-backend
11+
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --no-default-features --features "alsa-backend with-libmdns"
12+
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend with-libmdns"
13+
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features "alsa-backend with-libmdns"
14+
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features "alsa-backend with-libmdns"
1515

1616
FROM debian:bookworm
1717

@@ -30,6 +30,7 @@ RUN dpkg --add-architecture arm64 && \
3030
crossbuild-essential-armel \
3131
crossbuild-essential-armhf \
3232
curl \
33+
git \
3334
libasound2-dev \
3435
libasound2-dev:arm64 \
3536
libasound2-dev:armel \

contrib/cross-compile-armv6hf/Dockerfile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@ FROM --platform=linux/amd64 ubuntu:18.04
1111

1212
# Install common packages.
1313
RUN apt-get update
14-
RUN apt-get install -y -qq git curl build-essential libasound2-dev libssl-dev libpulse-dev libdbus-1-dev
14+
RUN apt-get install -y -qq git curl build-essential cmake clang libclang-dev libasound2-dev libpulse-dev
1515

1616
# Install armhf packages.
1717
RUN echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic main" | tee -a /etc/apt/sources.list
1818
RUN apt-get update
19-
RUN apt-get download libasound2:armhf libasound2-dev:armhf libssl-dev:armhf libssl1.1:armhf
19+
RUN apt-get download libasound2:armhf libasound2-dev:armhf
2020
RUN mkdir /sysroot && \
2121
dpkg -x libasound2_*.deb /sysroot/ && \
22-
dpkg -x libssl-dev*.deb /sysroot/ && \
23-
dpkg -x libssl1.1*.deb /sysroot/ && \
2422
dpkg -x libasound2-dev*.deb /sysroot/
2523

2624
# Install rust.
27-
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
25+
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.81 -y
2826
ENV PATH="/root/.cargo/bin/:${PATH}"
2927
RUN rustup target add arm-unknown-linux-gnueabihf
3028
RUN mkdir /.cargo && \
@@ -35,14 +33,11 @@ RUN mkdir /pi && \
3533
git -C /pi clone --depth=1 https://github.com/raspberrypi/tools.git
3634

3735
# Build env variables.
38-
ENV CARGO_TARGET_DIR /build
39-
ENV CARGO_HOME /build/cache
36+
ENV CARGO_TARGET_DIR=/build
37+
ENV CARGO_HOME=/build/cache
4038
ENV PATH="/pi/tools/arm-bcm2708/arm-linux-gnueabihf/bin:${PATH}"
4139
ENV PKG_CONFIG_ALLOW_CROSS=1
4240
ENV PKG_CONFIG_PATH_arm-unknown-linux-gnueabihf=/usr/lib/arm-linux-gnueabihf/pkgconfig/
43-
ENV C_INCLUDE_PATH=/sysroot/usr/include
44-
ENV OPENSSL_LIB_DIR=/sysroot/usr/lib/arm-linux-gnueabihf
45-
ENV OPENSSL_INCLUDE_DIR=/sysroot/usr/include/arm-linux-gnueabihf
4641

4742
ADD . /src
4843
WORKDIR /src
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#!/usr/bin/env bash
22
set -eux
33

4-
PI1_TOOLS_DIR="/pi/tools/arm-bcm2708/arm-linux-gnueabihf"
4+
cargo install --force --locked bindgen-cli
5+
6+
PI1_TOOLS_DIR=/pi/tools/arm-bcm2708/arm-linux-gnueabihf
7+
PI1_TOOLS_SYSROOT_DIR=$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot
58

69
PI1_LIB_DIRS=(
7-
"$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot/lib"
8-
"$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot/usr/lib"
10+
"$PI1_TOOLS_SYSROOT_DIR/lib"
11+
"$PI1_TOOLS_SYSROOT_DIR/usr/lib"
912
"/sysroot/usr/lib/arm-linux-gnueabihf"
10-
"/sysroot/lib/arm-linux-gnueabihf"
1113
)
1214
export RUSTFLAGS="-C linker=$PI1_TOOLS_DIR/bin/arm-linux-gnueabihf-gcc ${PI1_LIB_DIRS[*]/#/-L}"
15+
export BINDGEN_EXTRA_CLANG_ARGS=--sysroot=$PI1_TOOLS_SYSROOT_DIR
1316

14-
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"
17+
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend with-libmdns"

contrib/docker-build.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -eux
33

4-
cargo build --release --no-default-features --features alsa-backend
5-
cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features alsa-backend
6-
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features alsa-backend
7-
cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features alsa-backend
4+
cargo build --release --no-default-features --features "alsa-backend with-libmdns"
5+
cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features "alsa-backend with-libmdns"
6+
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend with-libmdns"
7+
cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features "alsa-backend with-libmdns"

0 commit comments

Comments
 (0)