I want to speed up my local development of a web app and I heard LLVM's LLD linker is a fast alternative to GCC's standard linker LD.
I'm on a recent rust
$ rustc --version
rustc 1.41.0-nightly (5fa0af232 2019-11-22)
and I have run brew install llvm
to get the 9.0 system installed. Then I have it exposed through my $PATH and I have lld (typical old school compiler tool, it won't spit out its version info):
$ which lld
/usr/local/opt/llvm/bin/lld
So now when I try to run cargo with the magic reconfig variable I get early failures:
$ RUSTFLAGS="-C linker=ld64.lld" cargo build
Compiling proc-macro2 v1.0.6
Compiling log v0.4.8
Compiling byteorder v1.3.2
Compiling memchr v2.2.1
Compiling arrayvec v0.4.12
error: failed to run custom build command for `log v0.4.8`
Caused by:
process didn't exit successfully: `/Users/xlange/code/thing/target/debug/build/log-e84787c8de742ce8/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
--- stdout
cargo:rustc-cfg=atomic_cas
cargo:rerun-if-changed=build.rs
How can I get it to use the rust-lld
that's installed by rustup? I see them like this:
/Users/xlange/.rustup//toolchains/nightly-x86_64-apple-darwin/bin/rust-lldb
/Users/xlange/.rustup//toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/rust-lld
/Users/xlange/.rustup//toolchains/nightly-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py
and I can do something like:
$ export PATH="/Users/xlange/.rustup//toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/:$PATH"
$ RUSTFLAGS="-C linker=rust-lld" cargo build
$ RUSTFLAGS="-C linker=rust-lld" cargo build
Compiling libc v0.2.65
Compiling cfg-if v0.1.10
Compiling proc-macro2 v1.0.6
Compiling unicode-xid v0.2.0
Compiling syn v1.0.5
Compiling spin v0.5.2
Compiling log v0.4.8
Compiling byteorder v1.3.2
Compiling either v1.5.3
Compiling semver-parser v0.7.0
Compiling slab v0.4.2
Compiling autocfg v0.1.7
Compiling memchr v2.2.1
Compiling fnv v1.0.6
Compiling scopeguard v1.0.0
Compiling smallvec v0.6.10
error: linking with `rust-lld` failed: exit code: 1
[[[ SNIP ]]]
= note: rust-lld: error: unknown argument '-dead_strip'
rust-lld: error: /Users/xlange/code/thing/target/debug/build/log-e84787c8de742ce8/build_script_build-e84787c8de742ce8.build_script_build.b80nmw92-cgu.0.rcgu.o: unknown file type