LukeMathWalker / zero-to-production

Code for "Zero To Production In Rust", a book on API development using Rust.
https://www.zero2prod.com
Apache License 2.0
5.43k stars 470 forks source link

zld archived #192

Open JonasKs opened 1 year ago

JonasKs commented 1 year ago

https://github.com/michaeleisel/zld

Seems like this should be replaced with lld for macOS now.

JonasKs commented 1 year ago
# On MacOS, `brew install llvm` and fix .zshrc
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

This worked for me. brew install llvm + following the instructions given by brew info llvm.

JonasKs commented 1 year ago

Nvm, this did not work when running test etc. through Intellij (PyCharm)

This did:

# On MacOS, `brew install llvm` and fix .zshrc
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld"]
image

Also works in terminal.

sondrelg commented 1 year ago

My intel macbook needed:

[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

you're on arch right @JonasKs?

JonasKs commented 1 year ago

M1, yeah. The setup you use works through terminal for me, but not through PyCharm.

Under "Using LLD" pointing to lld64.lld seem to be the documented path as well:

LLD can be used by adding -fuse-ld=/path/to/ld64.lld to the linker flags. For Xcode, this can be done by adding it to “Other linker flags” in the build settings. For Bazel, this can be done with --linkopt or with rules_apple_linker.

LukeMathWalker commented 1 year ago

I think the path where lld64 is installed by homebrew might be different on M1 vs x86_64 macs.

sondrelg commented 1 year ago

The lld64.lld failed for me at least 👍

JonasKs commented 1 year ago

So this should solve it for both? 😊

# On MacOS, `brew install llvm` and follow steps in `brew info llvm`
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld"]
hnaoto commented 11 months ago

So this should solve it for both? 😊

# On MacOS, `brew install llvm` and follow steps in `brew info llvm`
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld"]

Hi @JonasKs , thanks for sharing. That works for M2 as well.