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

Cross compilation with sysroot #100

Open
dudycz opened this issue Aug 2, 2024 · 2 comments
Open

Cross compilation with sysroot #100

dudycz opened this issue Aug 2, 2024 · 2 comments

Comments

@dudycz
Copy link

dudycz commented Aug 2, 2024

Hello,

I have a project which is cross compiling successfully to aarch64 target using my sdk (sysroot).

Problem starts when I add jemalloc dependency: configure script executed during jemalloc build fails due to missing standard libs. I checked config.log and there are few entries suggesting that prefix was passed from cargo down to configure, but maybe there is something missing? When I export in shell environment variable: CFLAGS="--sysroot=/path/to/aarch64-linux-gnu" it works.

@BusyJay
Copy link
Member

BusyJay commented Aug 3, 2024

jemalloc-sys detects compiler by using cc crate, as long as cross compile works for cc, it should work for jemAlloc-sys.

@dudycz
Copy link
Author

dudycz commented Aug 3, 2024

I don't know what exactly failed, but when I tried to cross compile my project (without jemalloc) to aarch64 it failed on linking the same system libs (libcrt, etc.). Then I figured out that I should add appropriate section to .cargo/config.toml with path to my sysroot:

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
ar = "aarch64-linux-gnu-ar"
rustflags = ["-C", "link-arg=--sysroot=sdk/sysroots/aarch64-linux-gnu"]

After that step, everything started to work. And then when I added jemalloc, its configure script failed on linking giving the same error like cargo build before adding path to sysroot. So maybe this is some issue with cc crate? Or maybe it would be better to inherit configuration from cargo config?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants