Skip to content

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

Closed
rust-lang/rustc-dev-guide
#2268
@Noratrieb

Description

@Noratrieb
#![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.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions