Remarks on perma unstable features
rustc_private
Overview
The rustc_private
feature allows external crates to use compiler internals.
Using rustc-private
with Official Toolchains
When using the rustc_private
feature with official Rust toolchains distributed via rustup, you need to install two additional components:
rustc-dev
: Provides compiler librariesllvm-tools
: Provides LLVM libraries required for linking
Installation Steps
Install both components using rustup:
rustup component add rustc-dev llvm-tools
Common Error
Without the llvm-tools
component, you'll encounter linking errors like:
error: linking with `cc` failed: exit status: 1
|
= note: rust-lld: error: unable to find library -lLLVM-{version}
Using rustc-private
with Custom Toolchains
For custom-built toolchains or environments not using rustup, additional configuration is typically required:
Requirements
- LLVM libraries must be available in your system's library search paths
- The LLVM version must match the one used to build your Rust toolchain
Troubleshooting Steps
- Check LLVM installation: Verify LLVM is installed and accessible
- Configure library paths: You may need to set environment variables:
export LD_LIBRARY_PATH=/path/to/llvm/lib:$LD_LIBRARY_PATH
- Check version compatibility: Ensure your LLVM version is compatible with your Rust toolchain
Additional Resources
- GitHub Issue #137421: Explains that
rustc_private
linker failures often occur becausellvm-tools
is not installed