Skip to content
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

Fix cross compilation for armv6hf (Raspberry Pi 1) #1457

Merged
merged 6 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions contrib/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 \
Expand Down
15 changes: 5 additions & 10 deletions contrib/cross-compile-armv6hf/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
photovoltex marked this conversation as resolved.
Show resolved Hide resolved
ENV PATH="/root/.cargo/bin/:${PATH}"
RUN rustup target add arm-unknown-linux-gnueabihf
RUN mkdir /.cargo && \
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions contrib/cross-compile-armv6hf/docker-build.sh
Original file line number Diff line number Diff line change
@@ -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
photovoltex marked this conversation as resolved.
Show resolved Hide resolved

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"
8 changes: 4 additions & 4 deletions contrib/docker-build.sh
Original file line number Diff line number Diff line change
@@ -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"