|
| 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