Skip to content

Commit 385272b

Browse files
committed
Add chapter Remarks on perma-unstable features
Signed-off-by: xizheyin <[email protected]>
1 parent 8eb1a18 commit 385272b

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
- [rustc_driver and rustc_interface](./rustc-driver/intro.md)
125125
- [Example: Type checking](./rustc-driver/interacting-with-the-ast.md)
126126
- [Example: Getting diagnostics](./rustc-driver/getting-diagnostics.md)
127+
- [Remarks on perma-unstable features](./rustc-driver/remarks-on-perma-unstable-features.md)
127128
- [Errors and Lints](diagnostics.md)
128129
- [Diagnostic and subdiagnostic structs](./diagnostics/diagnostic-structs.md)
129130
- [Translation](./diagnostics/translation.md)

src/building/bootstrapping/what-bootstrapping-does.md

-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ You can find more discussion about sysroots in:
372372
Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/deps.20in.20sysroot/)
373373
- [Discussions about building rustdoc out of
374374
tree](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/How.20to.20create.20an.20executable.20accessing.20.60rustc_private.60.3F)
375-
- [This issue](https://github.com/rust-lang/rust/issues/137421) explaining that `rustc_private` linker fails sometimes because llvm-tools is not installed.
376375

377376
[rustdoc PR]: https://github.com/rust-lang/rust/pull/76728
378377

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
## Requirements for `rustc_private`
2+
3+
### Overview
4+
5+
The `rustc-private` feature allows external crates to use compiler internals, but requires specific components to be properly installed. This document explains how to resolve common linker errors related to missing LLVM libraries when working with this feature.
6+
7+
### Using `rustc-private` with Official Toolchains
8+
9+
When using the `rustc_private` feature with official Rust toolchains distributed via rustup, you need to install two additional components:
10+
11+
1. **`rustc-dev`**: Provides compiler libraries
12+
2. **`llvm-tools`**: Provides LLVM libraries required for linking
13+
14+
#### Installation Steps
15+
16+
Install both components using rustup:
17+
18+
```bash
19+
rustup component add rustc-dev llvm-tools
20+
```
21+
22+
#### Common Error
23+
24+
Without the `llvm-tools` component, you'll encounter linking errors like:
25+
26+
```
27+
error: linking with `cc` failed: exit status: 1
28+
|
29+
= note: rust-lld: error: unable to find library -lLLVM-{version}
30+
```
31+
32+
### Using `rustc-private` with Custom Toolchains
33+
34+
For custom-built toolchains or environments not using rustup, additional configuration is typically required:
35+
36+
#### Requirements
37+
38+
- LLVM libraries must be available in your system's library search paths
39+
- The LLVM version must match the one used to build your Rust toolchain
40+
41+
#### Troubleshooting Steps
42+
43+
1. **Check LLVM installation**: Verify LLVM is installed and accessible
44+
2. **Configure library paths**: You may need to set environment variables:
45+
```bash
46+
export LD_LIBRARY_PATH=/path/to/llvm/lib:$LD_LIBRARY_PATH
47+
```
48+
3. **Check version compatibility**: Ensure your LLVM version is compatible with your Rust toolchain
49+
50+
### Additional Resources
51+
52+
- [GitHub Issue #137421](https://github.com/rust-lang/rust/issues/137421): Explains that `rustc_private` linker failures often occur because `llvm-tools` is not installed

0 commit comments

Comments
 (0)