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

COMPILING.md: Add section about cross compiling for Raspberry Pi #1405

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions COMPILING.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,29 @@ For example, to build with the ALSA audio and libmdns discovery backend:
cargo build --no-default-features --features "alsa-backend with-libmdns"
```

#### Cross Compiling for Raspberry Pi

To cross compile for Raspberry pi, get the arm-unknown-gnueabihf target for Rust:

```bash
rustup target add armv7-unknown-linux-gnueabi
```

You need to manually add a linker, which can be installed with apt:

```bash
sudo apt install gcc-arm-linux-gnueabihf
```

The target must be specified to cargo along with the linker.
This can be done via `.cargo/config.toml`, or via command line:

```bash
RUSTFLAGS="-C linker=arm-linux-gnueabihf-gcc" cargo build --no-default-features --target armv7-unknown-linux-gnueabihf
```

Note that this does not work with armv6 (found e.g. in Raspberry Pi 1 and Zero). Previously, you could use the linker in https://github.com/raspberrypi/tools, but this is now too old and will give an error when compiling Librespot (since `3e85d77bfb3520e16c35bb7db3912c76e8cc90d7`). More info: https://github.com/japaric/rust-cross/issues/42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I compile librespot for armv6 using the official raspi tools no problem. But I don't use cargo cross. I suggest just stating your method doesn't work for pi 1 and zero.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not using cargo cross. After commit 3e85d77 I get an error from the rpi tools linker saying it found dwarf version 6, but only supports versions 1-4. Maybe I'm using a newer version of Rust (I'm on 1.82.0)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update and see what I get. Does this happen even when compiling with the release profile?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oyv friendly nudge - did you get around to testing what @kingosticks asked?


### Running

Assuming you just compiled a ```debug``` build, you can run librespot with the following command:
Expand Down