Skip to content

Commit e0d9704

Browse files
committed
Add chapter Remarks on perma-unstable features
Signed-off-by: xizheyin <[email protected]>
1 parent 49ff258 commit e0d9704

File tree

2 files changed

+56
-0
lines changed

2 files changed

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