rust-lang/rust · error
unsupported LLVM intrinsic {}
Error message
unsupported LLVM intrinsic {} What it means
An `unimplemented!("unsupported LLVM intrinsic {}")` ICE in rustc_codegen_gcc's `intrinsic` function under `#[cfg(not(feature = "master"))]`. The non-master codegen path can only lower two LLVM intrinsic names (`llvm.x86.sse2.pause`, `llvm.x86.xgetbv`); every other LLVM intrinsic name falls through to the panic. The `master` cfg (the file's other branch) has a large table mapping LLVM intrinsics to GCC builtins, but the non-master build does not.
Source
Thrown at compiler/rustc_codegen_gcc/src/intrinsic/llvm.rs:1037
return true;
}
}
_ => (),
}
false
}
#[cfg(not(feature = "master"))]
pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function<'gcc> {
let gcc_name = match name {
"llvm.x86.sse2.pause" => {
// NOTE: pause is only a hint, so we use a dummy built-in because target built-ins
// are not supported in libgccjit 12.
"__builtin_inff"
}
"llvm.x86.xgetbv" => "__builtin_trap",
_ => unimplemented!("unsupported LLVM intrinsic {}", name),
};
let func = cx.context.get_builtin_function(gcc_name);
cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
func
}
#[cfg(feature = "master")]
pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function<'gcc> {
let gcc_name = match name {
"llvm.prefetch.p0" => {
let gcc_name = "__builtin_prefetch";
let func = cx.context.get_builtin_function(gcc_name);
cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
return func;
}
"llvm.aarch64.isb" => {
// FIXME: GCC doesn't support __builtin_arm_isb yet, check if this builtin is OK.View on GitHub (pinned to 7088e4b63a)
Solutions
- Build rustc_codegen_gcc WITH the `master` cargo feature (recent libgccjit) so the large intrinsic table at llvm.rs:1044+ is compiled in.
- Switch to the LLVM backend, which natively understands all LLVM intrinsics.
- Avoid `#[target_feature]` / `std::arch` intrinsics in the crate being compiled by the non-master GCC backend.
Example fix
# before (non-master cg_gcc + intrinsics -> ICE) rustc -Zcodegen-backend=gcc simd_crate.rs # after — enable master feature when building cg_gcc, or use LLVM # in rustc_codegen_gcc/Cargo.toml: features = ["master"] # or: rustc simd_crate.rs
Defensive patterns
Strategy: fallback
Validate before calling
# Detect intrinsics usage + non-master cg_gcc
if grep -rqE 'core::arch|core::intrinsics|target_feature' src/ && [[ "${RUSTFLAGS:-}" == *codegen-backend=gcc* ]]; then
echo "avoid: non-master cg_gcc only lowers 2 LLVM intrinsics; enable 'master' feature or use LLVM"
fi Prevention
- Build rustc_codegen_gcc with the `master` cargo feature when SIMD/arch intrinsics are needed.
- Default to LLVM for crates using `core::arch` / `#[target_feature]`.
- Grep source for `core::arch` and `core::intrinsics` before flipping on the GCC backend globally.
When it happens
Trigger: Using inline-asm-derived or `std::arch`-derived LLVM intrinsics (e.g. AVX/SSE/NEON builtins) in code compiled with a `rustc_codegen_gcc` built WITHOUT the `master` feature. Any intrinsic name not in the two-entry allowlist at llvm.rs:1030-1037 panics.
Common situations: Crates that use platform intrinsics (`core::arch::x86_64::*`, SIMD, `core::intrinsics`) compiled via a distro-built (non-master) cg_gcc backend. Common when a user enables `-Zcodegen-backend=gcc` globally and then builds a numeric/simd-heavy crate.
Related errors
- not implemented
- simd {}
- funnel shift on {:?}
- Kind: {:?}
- unsupported Apple pointer width {pointer_width:?}
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/85451f96e2958900.
Report an issue: GitHub.