michaeleisel / zld

A faster version of Apple's linker
MIT License
1.19k stars 50 forks source link

Unable to use Linker on Rust and M1 Pro Mac #120

Closed demiurge94 closed 2 years ago

demiurge94 commented 2 years ago

Currently going through the Rust book Zero to Production.

Successfully installed this linker using homebrew

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=/opt/homebrew/bin/zld"]

Added this to .cargo/config.toml When building I get:

error: linking with `cc` failed: exit status: 1

ld: can't link with a main executable file '/opt/homebrew/bin/zld' for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

To reproduce

Happens on any new rust project after adding the config.toml with the link target. link to repo (not updated with the latest rustflags above)

rustup target list shows aarch64-apple-darwin is the only one installed

I've updated brew, reinstalled xcode command line tools several times and I've double checked the path to zld.

Any help would be appreciated.

demiurge94 commented 2 years ago

rustflags = ["-C", "link-arg=/opt/homebrew/bin/zld"] -> rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/bin/zld"]

was missing -fuse-ld for some reason: