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

Compilation issues for --target armv7-unknown-linux-gnueabihf #68

Closed
mickvandijke opened this issue Aug 14, 2022 · 3 comments · Fixed by #69
Closed

Compilation issues for --target armv7-unknown-linux-gnueabihf #68

mickvandijke opened this issue Aug 14, 2022 · 3 comments · Fixed by #69
Assignees
Labels
Bug Incorrect Behavior

Comments

@mickvandijke
Copy link
Member

mickvandijke commented Aug 14, 2022

Torrust won't compile to armv7-unknown-linux-gnueabihf (Raspberry Pi etc..).

@mickvandijke mickvandijke added the Bug Incorrect Behavior label Aug 14, 2022
@mickvandijke mickvandijke self-assigned this Aug 14, 2022
@mickvandijke
Copy link
Member Author

mickvandijke commented Aug 14, 2022

After some painful hours, I've figured out a way to cross compile to armv7-unknown-linux-gnueabihf from an Ubuntu host.

I mostly ran into errors with openssl and sqlite3, so I had to add and update some dependencies in the Cargo.toml to fix these. openssl had to be included with the vendored feature:

openssl = { version = "0.10.41", features = ["vendored"] }

And rusqlite had to include the feature bundled through the r2d2_sqlite crate:

r2d2_sqlite = { version = "0.21.0", features = ["bundled"] }

These are the commands I had to use for the compiler to succeed:

sudo apt-get install binutils-arm-linux-gnueabihf gcc-arm-linux-gnueabihf musl-tools

sudo apt-get install gcc-multilib

sudo apt-get install clang

sudo apt-get install sudo apt-get install libsqlite3-dev openssl libssl-dev pkg-config

sudo apt-get install -y libc6-armhf-cross libc6-dev-armhf-cross

sudo ln -s /usr/bin/arm-linux-gnueabihf-gcc /usr/bin/arm-linux-musleabihf-gcc

If you are coss compiling to armv7, you also have to add the following to torrust-tracker/.cargo/config:

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

If this file and folder don’t exist, you’ll have to create them yourself.

@mickvandijke
Copy link
Member Author

#69

@josecelano
Copy link
Member

hi @WarmBeer in the docker configuration I'm working on here, I'm using a docker image that probably does that internally. It works with --target x86_64-unknown-linux-musl but it does not work with --target armv7-unknown-linux-gnueabihf.

I think we could add a GitHub workflow to test cross-compilations like this.

We can start with only this case for the time being so we do not lose this information. I think it's very important to know the exact dependencies of the program to ensure it runs in as many systems as possible. This could be a pain if we keep adding more and more "hidden" or unexplicit indirect dependencies.

At least with the docker configuration, I'm working we know well the dependencies for one system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Incorrect Behavior
Projects
Archived in project
2 participants