Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

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

Closed
demiurge94 opened this issue Oct 25, 2022 · 1 comment
Closed

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

demiurge94 opened this issue Oct 25, 2022 · 1 comment

Comments

@demiurge94
Copy link

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
Copy link
Author

demiurge94 commented Oct 25, 2022

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:

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

No branches or pull requests

1 participant