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

rustc_private linker error when llvm-tools is not installed #137421

Closed
Noratrieb opened this issue Feb 22, 2025 · 5 comments · Fixed by #137931 or rust-lang/rustc-dev-guide#2268
Closed
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Noratrieb
Copy link
Member

Noratrieb commented Feb 22, 2025

#![feature(rustc_private)]
extern crate rustc_driver;

fn main() {}

With the rustc-dev component but without the llvm-tools component:

error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-m64" "/tmp/nix-shell-24333-0/rustchPbv3V/symbols.o" "<1 object files omitted>" "-Wl,--as-needed" "-Wl,-Bdynamic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_driver-0f916e861b45e5f3.so" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lLLVM-20-rust-1.87.0-nightly" "-ldl" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: unable to find library -lLLVM-20-rust-1.87.0-nightly
          collect2: error: ld returned 1 exit status
          

error: aborting due to 1 previous error

libLLVM is part of the llvm-tools component, so that is needed for linkage. It would be nice if rustc had a more specialized error message for this, as it's very confusing if you're not aware of this.

@Noratrieb Noratrieb added A-diagnostics Area: Messages for errors, warnings, and lints requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 22, 2025
@xizheyin
Copy link
Contributor

Hi, how difficult is this task and could I try it?

@lolbinarycat
Copy link
Contributor

@xizheyin it's a simple diagnostic issue, so all that needs to be done is to detect this error, and print a hint message alongside it like "consider using rustup to add the llvm-tools component".

@Noratrieb
Copy link
Member Author

I expect that detecting this error will be quite nontrivial to do nicely, and honestly I have no idea how to best do it. I only have a bunch of bad ideas on how to do it

@xizheyin
Copy link
Contributor

@Noratrieb This makes a lot of sense, I've encountered this error a few times recently and it took a while of troubleshooting to realize that I didn't have llvm-tools installed. I need to know how to go about fixing the diagnosis first.

@lolbinarycat Thanks for your help. I'm going to read up on this first, as I have no experience related to fixing diagnostics.

@xizheyin
Copy link
Contributor

xizheyin commented Mar 3, 2025

@rustbot claim

@bors bors closed this as completed in 150e88c Mar 10, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 10, 2025
Rollup merge of rust-lang#137931 - xizheyin:issue-137421, r=jieyouxu

Add remark for missing `llvm-tools` component re. `rustc_private` linker failures related to not finding LLVM libraries

Fixes rust-lang#137421
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 requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
3 participants