-
Notifications
You must be signed in to change notification settings - Fork 8
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
Unable to build executable for musl target #76
Comments
Those file should locate at |
@12101111 Will this be fixed by rust-lang/rust#90681? |
It can compile after I run |
It can be enable by rustc codegen option You can set it in [build]
target = "x86_64-unknown-linux-musl"
[target.x86_64-unknown-linux-musl]
linker = "ld"
rustflags = ["-Ctarget-feature=-crt-static", "-Clink-self-contained=on", "-L/usr/lib/x86_64-linux-musl", "-Clink-args=--dynamic-linker /lib/ld-musl-x86_64.so.1"]
[unstable]
build-std = ["core", "compiler_builtins", "alloc", "std", "panic_abort"]
build-std-features = ["llvm-libunwind"] Tested on Ubuntu 20.04:
If you are try to build a static linked binary (which is default for musl target), you don't have to add [build]
target = "x86_64-unknown-linux-musl"
[unstable]
build-std = ["core", "compiler_builtins", "alloc", "std", "panic_abort"] |
Cargo can't find native libc.a (musl). However, the location for libc is different on Arch compared to Ubuntu. On Arch, it is installed at My .cargo/config.toml:
My build command:
Error message:
|
edit: it's fixed as of 1.77.0-nightly I have the same problem on macOS. Adding "-L/Users/…/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/" to rustflags has solved it for me. I'm using filosottile/musl-cross/musl-cross export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc
export TARGET_CC=x86_64-linux-musl-gcc
cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-unknown-linux-musl --release
|
Just had a go at reproducing this on my The following options seemed to work for me ( [target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-ld"
|
@c272 I've ran the build again, and it's working now. |
What's the status on this issue? I just had the same problem and it seemed that adding the -L/path/to/self-contained worked. But why do we have to add that manually? |
Even weirder, just tried cargo cross (https://github.com/cross-rs/cross) with it, and it worked just fine without specified -L/path/to/self-contained |
Project folder
fannkuchredux2.zip
Build Command
cargo +nightly build -Z build-std=std,panic_abort --target=x86_64-unknown-linux-musl --release
Error Message
Operating system
Arch Linux
Cargo version
cargo 1.58.0-nightly (ad50d0d26 2021-11-17)
The text was updated successfully, but these errors were encountered: