-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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-compiling with clang
failed because cargo doesn't specify --target
in the linking command
#10863
Comments
Closing as this isn't an issue with Cargo. If you need more help with cross-compiling, I suggest trying one of the user forums such as https://users.rust-lang.org/. |
@ehuss, But it's perfectly fine if I invoke
This produces a valid ELF executable. EDIT: Also tried with “real” |
So, because fn main() {
let target = std::env::var("TARGET").unwrap();
println!(
"cargo:rustc-link-arg=--target={}", target
);
println!(
"cargo:rustc-link-arg=-fuse-ld=/opt/homebrew/bin/ld.mold"
);
println!(
"cargo:rustc-link-arg=--gcc-toolchain=/Volumes/CSP/x-tools/{}", target
);
println!(
"cargo:rustc-link-arg=--sysroot=/Volumes/CSP/x-tools/{}/{}/sysroot", target, target
);
} I think cargo should explicitly output |
clang
and mold
failed with unrecognized option '-dynamic'clang
failed because cargo doesn't specify --target
in the linking command
Problem
Issues first filed here: rui314/mold#564
I'd like to cross-compile a rust project from
aarch64-apple-darwin
tox86_64-unknown-linux-gnu
with these settings:But if failed with unrecognized option:
unrecognized option '-dynamic'
However, the linker command emitted doesn't show
-dynamic
but-Wl,-Bdynamic
:Further investigation shows that it's not only affecting mold, but also
ld.lld
fromllvm
andx86_64-unknown-linux-gnu-ld
from the cross-compilation toolchain.Steps
crosstool-ng
cargo new testing
cd testing && mkdir .cargo
mold
:For
x86_64-unknown-linux-gnu-ld
:For
ld.lld
:cargo build --target=x86_64-unknown-linux-gnu
and failPossible Solution(s)
So, I guess if the linker is
clang
on macOS, regardless of what target it is, it always passes linker options inld64
forms somehow.Notes
Setting
x86_64-unknown-linux-gnu-gcc
as the linker and usingmold
orlld
is fine:Version
The text was updated successfully, but these errors were encountered: