[GH-ISSUE #389] Docker build fails at alsa-sys crate on arm-unknown-linux-gnueabihf #255

Closed
opened 2026-02-27 19:29:40 +03:00 by kerem · 5 comments
Owner

Originally created by @tenortim on GitHub (Oct 31, 2019).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/389

The alsa-sys crate seems to need to run pkg-config (missing from the Dockerfile) and pkg-config isn't architecture aware, so the contrib/docker-build.sh that tries to build five different architectures doesn't work correctly any longer.

I have a fairly simple patch. Will fork and send a PR, but will attach the diff here since it's pretty simple.

Originally created by @tenortim on GitHub (Oct 31, 2019). Original GitHub issue: https://github.com/librespot-org/librespot/issues/389 The alsa-sys crate seems to need to run pkg-config (missing from the Dockerfile) and pkg-config isn't architecture aware, so the contrib/docker-build.sh that tries to build five different architectures doesn't work correctly any longer. I have a fairly simple patch. Will fork and send a PR, but will attach the diff here since it's pretty simple.
kerem closed this issue 2026-02-27 19:29:40 +03:00
Author
Owner

@tenortim commented on GitHub (Oct 31, 2019):

Proposed fix:

ubuntu-server:contrib$ git diff
diff --git a/contrib/Dockerfile b/contrib/Dockerfile
index 0fcdaff..3a18589 100644
--- a/contrib/Dockerfile
+++ b/contrib/Dockerfile
@@ -22,6 +22,7 @@ RUN dpkg --add-architecture mipsel
 RUN apt-get update

 RUN apt-get install -y curl git build-essential crossbuild-essential-arm64 crossbuild-essential-armel crossbuild-essential-armhf crossbuild-essential-mipsel
+RUN apt-get install -y pkg-config
 RUN apt-get install -y libasound2-dev libasound2-dev:arm64 libasound2-dev:armel libasound2-dev:armhf libasound2-dev:mipsel

 RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
@@ -43,6 +44,7 @@ RUN mkdir /build && \

 ENV CARGO_TARGET_DIR /build
 ENV CARGO_HOME /build/cache
+ENV PKG_CONFIG_ALLOW_CROSS=1

 ADD . /src
 WORKDIR /src
diff --git a/contrib/docker-build.sh b/contrib/docker-build.sh
index cd5ef46..301e8d6 100755
--- a/contrib/docker-build.sh
+++ b/contrib/docker-build.sh
@@ -2,7 +2,11 @@
 set -eux

 cargo build --release --no-default-features --features alsa-backend
+export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
 cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features alsa-backend
+export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
 cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features alsa-backend
+export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabi/pkgconfig
 cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features alsa-backend
+export PKG_CONFIG_PATH=/usr/lib/mipsel-linux-gnu/pkgconfig
 cargo build --release --target mipsel-unknown-linux-gnu --no-default-features --features alsa-backend
<!-- gh-comment-id:548608096 --> @tenortim commented on GitHub (Oct 31, 2019): Proposed fix: ``` ubuntu-server:contrib$ git diff diff --git a/contrib/Dockerfile b/contrib/Dockerfile index 0fcdaff..3a18589 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -22,6 +22,7 @@ RUN dpkg --add-architecture mipsel RUN apt-get update RUN apt-get install -y curl git build-essential crossbuild-essential-arm64 crossbuild-essential-armel crossbuild-essential-armhf crossbuild-essential-mipsel +RUN apt-get install -y pkg-config RUN apt-get install -y libasound2-dev libasound2-dev:arm64 libasound2-dev:armel libasound2-dev:armhf libasound2-dev:mipsel RUN curl https://sh.rustup.rs -sSf | sh -s -- -y @@ -43,6 +44,7 @@ RUN mkdir /build && \ ENV CARGO_TARGET_DIR /build ENV CARGO_HOME /build/cache +ENV PKG_CONFIG_ALLOW_CROSS=1 ADD . /src WORKDIR /src diff --git a/contrib/docker-build.sh b/contrib/docker-build.sh index cd5ef46..301e8d6 100755 --- a/contrib/docker-build.sh +++ b/contrib/docker-build.sh @@ -2,7 +2,11 @@ set -eux cargo build --release --no-default-features --features alsa-backend +export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features alsa-backend +export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features alsa-backend +export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabi/pkgconfig cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features alsa-backend +export PKG_CONFIG_PATH=/usr/lib/mipsel-linux-gnu/pkgconfig cargo build --release --target mipsel-unknown-linux-gnu --no-default-features --features alsa-backend ```
Author
Owner

@ashthespy commented on GitHub (Nov 1, 2019):

Sorry, this was me - https://github.com/librespot-org/librespot/pull/245#issuecomment-430247445
I never pushed the fix, will do it now.

<!-- gh-comment-id:548743775 --> @ashthespy commented on GitHub (Nov 1, 2019): Sorry, this was me - https://github.com/librespot-org/librespot/pull/245#issuecomment-430247445 I never pushed the fix, will do it now.
Author
Owner

@tenortim commented on GitHub (Nov 1, 2019):

Hi @ashthespy,
I think you still need the docker-build.sh changes too. Otherwise the build fails because pkg-config isn't architecture-aware and the arm-linux-gnueabihf build fails at the link stage. Do you want to add that separately, or should I generate a new PR?

<!-- gh-comment-id:548841320 --> @tenortim commented on GitHub (Nov 1, 2019): Hi @ashthespy, I think you still need the docker-build.sh changes too. Otherwise the build fails because pkg-config isn't architecture-aware and the arm-linux-gnueabihf build fails at the link stage. Do you want to add that separately, or should I generate a new PR?
Author
Owner

@ashthespy commented on GitHub (Nov 1, 2019):

@tenortim I didn't have all the changes in that commit, need to keep better track of all my branches!
Added a new commit that sets the individual PKG_CONFIG_PATH for each triple.

EDIT: I use a different Dockerfile for my builds for diff architecture, and I now see I only have to set the PKG_CONFIG_PATH only when the triple name doesn't match the linker name. I will investigate more to see what I do differently in my image.

<!-- gh-comment-id:548845184 --> @ashthespy commented on GitHub (Nov 1, 2019): @tenortim I didn't have all the changes in that commit, need to keep better track of all my branches! Added a new commit that sets the individual `PKG_CONFIG_PATH` for each triple. EDIT: I use a different Dockerfile for [my builds for diff architecture](https://github.com/ashthespy/Vollibrespot/releases), and I now see I only have to set the `PKG_CONFIG_PATH` only when the triple name doesn't match the linker name. I will investigate more to see what I do differently in my image.
Author
Owner

@ashthespy commented on GitHub (Nov 4, 2019):

From my quick experiments, crossbuild-essential-arm64 and crossbuild-essential-mipsel seem to work fine, however, both crossbuild-essential-armel and crossbuild-essential-armhf need some help. That being said, there shouldn't be much harm setting the right environment variables for each target triple.

<!-- gh-comment-id:549375381 --> @ashthespy commented on GitHub (Nov 4, 2019): From my quick experiments, `crossbuild-essential-arm64` and `crossbuild-essential-mipsel` seem to work fine, however, both `crossbuild-essential-armel` and `crossbuild-essential-armhf` need some help. That being said, there *shouldn't* be much harm setting the right [environment variables](https://github.com/rust-lang/pkg-config-rs#external-configuration-via-target-scoped-environment-variables) for each target triple.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#255
No description provided.