-
Notifications
You must be signed in to change notification settings - Fork 756
Cross compiling
A cross compilation environment is provided as a docker image. Build the image from the root of the project with the following command:
$ docker build -t librespot-cross -f contrib/Dockerfile .The resulting image will build librespot for Linux x86_64, aarch64, armhf (compatible e. g. with Raspberry Pi 2 or 3, but not with Raspberry Pi 1 or Zero), armel (would run on Pi 1 and Zero, but really slow due to software emulation of floating point operations - see below for how to build for Pi 1 and Zero with hardware floating point support) and mipsel when being run without any further command:
docker run -v /tmp/librespot-build:/build librespot-crossThe compiled binaries will be located in /tmp/librespot-build/release/ for x86_64 and in /tmp/librespot-build/<architecture>/release/ for the other architectures.
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 --target mipsel-unknown-linux-gnu --no-default-features --features alsa-backendFor Raspberry Pi 1 or Zero you can build librespot for armv6hf (ARMv6 with hardware floating point support) by running:
docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh
The compiled binary will also be located in /tmp/librespot-build/arm-unknown-linux-gnueabihf/release.
To resolve the error message librespot: Error getting 1120 bytes thread-local storage: No such file or directory on older Raspberry Pi devices (armv6 / target: arm-unknown-linux-musleabihf) will require the following additional compilation option:
RUSTFLAGS="-C target-feature=-crt-static"
If you are running docker on a system with SELinux (RHEL, Centos, Fedora), add :Z to the end of the docker volume argument, to ensure the proper SELinux context is inherited by the directory used as a docker volume.
This yields the following commands:
docker run -v /tmp/librespot-build:/build:Z librespot-cross
docker run -v /tmp/librespot-build:/build:Z librespot-cross cargo build --release --no-default-features --features alsa-backend
docker run -v /tmp/librespot-build:/build:Z librespot-cross cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features alsa-backend
docker run -v /tmp/librespot-build:/build:Z librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features alsa-backend