1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-03 09:49:31 +02:00

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 <starypatyk@users.noreply.github.com>

* Cross-compile with libmdns

Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>

* Simplify Docker image to cross-compile for armv6hf (RPi 1)

Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>

* Revert "Use ring instead of aws-lc as the default backend for hyper-rustls"

This reverts commit faeaf506d6.

* Fix bindgen issues (aws-lc-rs) when cross-compiling for armv6hf

Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>

* Add git to the Docker image for cross-compiling

Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>

---------

Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
Co-authored-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
Dariusz Olszewski 2025-02-03 22:50:47 +01:00 committed by GitHub
parent 34762f2274
commit cf61ede6c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 23 deletions

View file

@ -8,10 +8,10 @@
# The compiled binaries will be located in /tmp/librespot-build
#
# If only one architecture is desired, cargo can be invoked directly with the appropriate options :
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --no-default-features --features alsa-backend
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features alsa-backend
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features alsa-backend
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features alsa-backend
# $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --no-default-features --features "alsa-backend with-libmdns"
# $ 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"
# $ 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"
# $ 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"
FROM debian:bookworm
@ -30,6 +30,7 @@ RUN dpkg --add-architecture arm64 && \
crossbuild-essential-armel \
crossbuild-essential-armhf \
curl \
git \
libasound2-dev \
libasound2-dev:arm64 \
libasound2-dev:armel \

View file

@ -11,20 +11,18 @@ FROM --platform=linux/amd64 ubuntu:18.04
# Install common packages.
RUN apt-get update
RUN apt-get install -y -qq git curl build-essential libasound2-dev libssl-dev libpulse-dev libdbus-1-dev
RUN apt-get install -y -qq git curl build-essential cmake clang libclang-dev libasound2-dev libpulse-dev
# Install armhf packages.
RUN echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic main" | tee -a /etc/apt/sources.list
RUN apt-get update
RUN apt-get download libasound2:armhf libasound2-dev:armhf libssl-dev:armhf libssl1.1:armhf
RUN apt-get download libasound2:armhf libasound2-dev:armhf
RUN mkdir /sysroot && \
dpkg -x libasound2_*.deb /sysroot/ && \
dpkg -x libssl-dev*.deb /sysroot/ && \
dpkg -x libssl1.1*.deb /sysroot/ && \
dpkg -x libasound2-dev*.deb /sysroot/
# Install rust.
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.81 -y
ENV PATH="/root/.cargo/bin/:${PATH}"
RUN rustup target add arm-unknown-linux-gnueabihf
RUN mkdir /.cargo && \
@ -35,14 +33,11 @@ RUN mkdir /pi && \
git -C /pi clone --depth=1 https://github.com/raspberrypi/tools.git
# Build env variables.
ENV CARGO_TARGET_DIR /build
ENV CARGO_HOME /build/cache
ENV CARGO_TARGET_DIR=/build
ENV CARGO_HOME=/build/cache
ENV PATH="/pi/tools/arm-bcm2708/arm-linux-gnueabihf/bin:${PATH}"
ENV PKG_CONFIG_ALLOW_CROSS=1
ENV PKG_CONFIG_PATH_arm-unknown-linux-gnueabihf=/usr/lib/arm-linux-gnueabihf/pkgconfig/
ENV C_INCLUDE_PATH=/sysroot/usr/include
ENV OPENSSL_LIB_DIR=/sysroot/usr/lib/arm-linux-gnueabihf
ENV OPENSSL_INCLUDE_DIR=/sysroot/usr/include/arm-linux-gnueabihf
ADD . /src
WORKDIR /src

View file

@ -1,14 +1,17 @@
#!/usr/bin/env bash
set -eux
PI1_TOOLS_DIR="/pi/tools/arm-bcm2708/arm-linux-gnueabihf"
cargo install --force --locked bindgen-cli
PI1_TOOLS_DIR=/pi/tools/arm-bcm2708/arm-linux-gnueabihf
PI1_TOOLS_SYSROOT_DIR=$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot
PI1_LIB_DIRS=(
"$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot/lib"
"$PI1_TOOLS_DIR/arm-linux-gnueabihf/sysroot/usr/lib"
"$PI1_TOOLS_SYSROOT_DIR/lib"
"$PI1_TOOLS_SYSROOT_DIR/usr/lib"
"/sysroot/usr/lib/arm-linux-gnueabihf"
"/sysroot/lib/arm-linux-gnueabihf"
)
export RUSTFLAGS="-C linker=$PI1_TOOLS_DIR/bin/arm-linux-gnueabihf-gcc ${PI1_LIB_DIRS[*]/#/-L}"
export BINDGEN_EXTRA_CLANG_ARGS=--sysroot=$PI1_TOOLS_SYSROOT_DIR
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend with-libmdns"

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -eux
cargo build --release --no-default-features --features alsa-backend
cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features alsa-backend
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features alsa-backend
cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features alsa-backend
cargo build --release --no-default-features --features "alsa-backend with-libmdns"
cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features "alsa-backend with-libmdns"
cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend with-libmdns"
cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features "alsa-backend with-libmdns"