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

-Clink-arg=-fuse-ld=lld reports 'cannot find ld' #82172

Closed
jyn514 opened this issue Feb 16, 2021 · 4 comments
Closed

-Clink-arg=-fuse-ld=lld reports 'cannot find ld' #82172

jyn514 opened this issue Feb 16, 2021 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug.

Comments

@jyn514
Copy link
Member

jyn514 commented Feb 16, 2021

What it actually means is 'cannot find lld', which is different - you can have one installed but not the other.

$ rustc -Clink-arg=-fuse-ld=lld build.rs 
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "build.build.7rcbfp3g-cgu.0.rcgu.o" "build.build.7rcbfp3g-cgu.1.rcgu.o" "build.build.7rcbfp3g-cgu.10.rcgu.o" "build.build.7rcbfp3g-cgu.11.rcgu.o" "build.build.7rcbfp3g-cgu.12.rcgu.o" "build.build.7rcbfp3g-cgu.13.rcgu.o" "build.build.7rcbfp3g-cgu.14.rcgu.o" "build.build.7rcbfp3g-cgu.15.rcgu.o" "build.build.7rcbfp3g-cgu.2.rcgu.o" "build.build.7rcbfp3g-cgu.3.rcgu.o" "build.build.7rcbfp3g-cgu.4.rcgu.o" "build.build.7rcbfp3g-cgu.5.rcgu.o" "build.build.7rcbfp3g-cgu.6.rcgu.o" "build.build.7rcbfp3g-cgu.7.rcgu.o" "build.build.7rcbfp3g-cgu.8.rcgu.o" "build.build.7rcbfp3g-cgu.9.rcgu.o" "-o" "build" "build.3o9xbt4o0msgng42.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6f5658153d127ddd.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-b69e89b2ef7e009e.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-fe971cf9622d0c47.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-9ff49e5df977573d.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-323dea4ee1c9a010.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-f12d17a047776008.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-3d968aa3120f6a27.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-22cd238a7814521c.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-f2c707309e5edc5c.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-6b6b4b2bc151fc5a.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-32b57ee4d7c8dc07.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-d9f2cb19c79e847e.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-3ccc4a4f3013e9ef.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-aa547327a7679d28.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-90996f4879673567.rlib" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-9ea09a899c3eda46.rlib" "-Wl,--end-group" "/home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-ea377e9224b11a8a.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-fuse-ld=lld"
  = note: collect2: fatal error: cannot find 'ld'
          compilation terminated.

This comes from gcc, so you could make a reasonable case for this being an upstream bug.

@jyn514 jyn514 added the C-bug Category: This is a bug. label Feb 16, 2021
@jyn514 jyn514 changed the title -Clink-arg=-fuse-ld=lld reports 'cannot find ld -Clink-arg=-fuse-ld=lld reports 'cannot find ld' Feb 16, 2021
@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints A-linkage Area: linking into static, shared libraries and binaries labels Feb 16, 2021
@nagisa
Copy link
Member

nagisa commented Feb 16, 2021

Does gcc support using lld as a linker?

-fuse-ld= does not tell the gcc (or clang) to use the specified value as a linker executable. It tells it to use the certain family of linkers as a linker. e.g. -fuse-ld=gold will end up invoking ld.gold. Its a lot like the -Clinker-flavor argument of rustc.

upstream bug

Yeah I don't think there's anything rustc can do about the linker having ungreat diagnostics, accepting flags it does not expect or ignoring what it does not understand.

@jyn514
Copy link
Member Author

jyn514 commented Feb 16, 2021

Does gcc support using lld as a linker?

It does - the issue was I didn't have lld installed.

Ok, I'll open an upstream issue.

@mati865
Copy link
Contributor

mati865 commented Feb 19, 2021

-fuse-ld= does not tell the gcc (or clang) to use the specified value as a linker executable.

With Clang one can use LLD command like that -fuse-ld=lld-11 to use specific version, you can even provide the path to LLD.
GCC accepts only linker name (without version).

This issue is not actionable by Rust.

@jyn514
Copy link
Member Author

jyn514 commented Apr 2, 2021

This issue is not actionable by Rust.

I opened https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99878 and https://bugs.llvm.org/show_bug.cgi?id=49814.

@jyn514 jyn514 closed this as completed Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants