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

mold: fatal: unknown command line option: -arch #1259

Open
therealjasonkenney opened this issue May 14, 2024 · 1 comment
Open

mold: fatal: unknown command line option: -arch #1259

therealjasonkenney opened this issue May 14, 2024 · 1 comment

Comments

@therealjasonkenney
Copy link

I am trying to cross compile my rust code to x86_64-unknown-linux-musl
I have tried in .cargo/config.toml:

[target.x86_64-unknown-linux-musl]
linker="clang"
rustflags = ["-C", "linker=clang", "-C", "link-arg=--ld-path=/nix/store/fm5083fc4ylj6zyld7n1j270m8kx0q8i-mold-2.31.0/bin/mold", "-C", "target-feature=+crt-static", "-C", "link-arg=-v"]

But something somewhere is setting these flags. I tried using bash -l to isolate env pollution which helped remove -lconv from the lib list.

Not sure what I should do. (Currently using clang 16)

  • Cargo command run by bash -l 'cargo build -p mtomd --release --target=x86_64-unknown-linux-musl'
rustc --crate-name mtomd --edition=2021 mtomd/src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=134 --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C metadata=1cacddd9d05bd727 -C extra-filename=-1cacddd9d05bd727 --out-dir /Volumes/Navi/Users/lain/Developer/projects/ground-control/target/x86_64-unknown-linux-musl/release/deps --target x86_64-unknown-linux-musl -C linker=clang -L dependency=/Volumes/Navi/Users/lain/Developer/projects/ground-control/target/x86_64-unknown-linux-musl/release/deps -L dependency=/Volumes/Navi/Users/lain/Developer/projects/ground-control/target/release/deps --extern prost=/Volumes/Navi/Users/lain/Developer/projects/ground-control/target/x86_64-unknown-linux-musl/release/deps/libprost-a21df6e0ccc2cdb0.rlib --extern tokio=/Volumes/Navi/Users/lain/Developer/projects/ground-control/target/x86_64-unknown-linux-musl/release/deps/libtokio-8ab7d5b4685812a6.rlib --extern tonic=/Volumes/Navi/Users/lain/Developer/projects/ground-control/target/x86_64-unknown-linux-musl/release/deps/libtonic-f906c81e78292274.rlib -C linker=clang -C link-arg=--ld-path=/nix/store/fm5083fc4ylj6zyld7n1j270m8kx0q8i-mold-2.31.0/bin/mold -C target-feature=+crt-static -C link-arg=-v -L native=/Volumes/Navi/Users/lain/Developer/projects/ground-control/target/x86_64-unknown-linux-musl/release/build/ring-4294bf8dc348ad55/out`

This outputs the following mold command: ```
"/nix/store/fm5083fc4ylj6zyld7n1j270m8kx0q8i-mold-2.31.0/bin/mold" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -static -arch x86_64 -platform_version macos 10.12.0 14.2 ...

@rui314
Copy link
Owner

rui314 commented May 15, 2024

-demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -static -arch x86_64 -platform_version macos 10.12.0 14.2 ...

Those flags are for the macOS linker and not compatible with Linux linkers. It looks like you are trying to cross compile your program for macOS instead of for x86_64-unknown-linux-musl.

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