Rollup merge of #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 #137421
This commit is contained in:
Matthias Krüger 2025-03-10 15:57:08 +01:00 committed by GitHub
commit 150e88c549
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,3 +12,33 @@ The presence of this feature changes the way the linkage format for dylibs is ca
that is necessary for linking against dylibs that statically link `std` (such as `rustc_driver`).
This makes this feature "viral" in linkage; its use in a given crate makes its use required in
dependent crates which link to it (including integration tests, which are built as separate crates).
## Common linker failures related to missing LLVM libraries
### When using `rustc-private` with Official Toolchains
When using the `rustc_private` feature with official toolchains distributed via rustup, you'll need to install:
1. The `rustc-dev` component (provides compiler libraries)
2. The `llvm-tools` component (provides LLVM libraries needed for linking)
You can install these components using `rustup`:
```text
rustup component add rustc-dev llvm-tools
```
Without the `llvm-tools` component, you may encounter linking errors like:
```text
error: linking with `cc` failed: exit status: 1
|
= note: rust-lld: error: unable to find library -lLLVM-{version}
```
### When using `rustc-private` with Custom Toolchains
For custom-built toolchains or environments not using rustup, different configuration may be required:
- Ensure LLVM libraries are available in your library search paths
- You might need to configure library paths explicitly depending on your LLVM installation