-
Notifications
You must be signed in to change notification settings - Fork 547
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 can be used to build librespot for linux x86_64, armhf (compatible e. g. with Raspberry Pi 2 or 3, but not with Raspberry Pi 1 or Zero) and armel.
The compiled binaries will be located in /tmp/librespot-build/<architecture>/release/
docker run -v /tmp/librespot-build:/build librespot-cross
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
Don't forget to set the with-tremor
feature flag if your target device does not have floating-point capabilities.
For Raspberry Pi you can run:
docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh
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: 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