rust-lang/rust · error
not implemented
Error message
not implemented
What it means
An `unimplemented!()` ICE in rustc_codegen_gcc's `handle_native`. When the user requests `target-cpu=native`, the backend must query libgccjit's target info for the host CPU arch. That query only exists under the crate's `master` feature (a recent libgccjit build). Without `master`, `handle_native` has no way to detect the native CPU and panics. The non-master build is a stripped-down fallback that intentionally lacks this capability.
Solutions
- Stop passing `-Ctarget-cpu=native`; pass an explicit CPU name (e.g. `-Ctarget-cpu=x86-64`) so `handle_native` returns early via `arch_to_gcc`.
- Rebuild rustc_codegen_gcc with the `master` cargo feature against a libgccjit that supports `get_target_info()`.
- Switch to the LLVM backend, where `target-cpu=native` is fully supported.
Example fix
# before (non-master cg_gcc -> ICE on native) rustc -Ctarget-cpu=native -Zcodegen-backend=gcc crate.rs # after — explicit CPU rustc -Ctarget-cpu=x86-64 -Zcodegen-backend=gcc crate.rs
Defensive patterns
Strategy: validation
Validate before calling
# Do not pass target-cpu=native to a non-master cg_gcc build
if [[ "${RUSTFLAGS:-}" == *target-cpu=native* && "${RUSTFLAGS:-}" == *codegen-backend=gcc* ]]; then
echo "avoid: pass an explicit -Ctarget-cpu=<name>, not 'native', unless cg_gcc is built with the master feature"
fi Prevention
- Pass an explicit `-Ctarget-cpu=<name>` instead of `native` when using cg_gcc.
- Confirm the `master` cargo feature is enabled in your rustc_codegen_gcc build before relying on native detection.
- Keep build scripts / PGO from injecting `target-cpu=native` when the GCC backend is selected.
When it happens
Trigger: Compiling with the GCC backend that was built without the `master` cargo feature, while passing `-Ctarget-cpu=native` (or a target spec whose CPU is `NATIVE_CPU`). `target_cpu(sess)` calls `handle_native`, which hits the `#[cfg(not(feature = "master"))] unimplemented!()`.
Common situations: A distro or local build of rustc_codegen_gcc linked against an older/stock libgccjit (no master feature), combined with a build script, profile-guided optimization pass, or user flag that sets `-Ctarget-cpu=native`.
Related errors
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/4a6740ec4efe5dbd.
Report an issue: GitHub.
Appendix: source
Thrown at compiler/rustc_codegen_gcc/src/gcc_util.rs:130
"M68000" => "68000",
"M68020" => "68020",
_ => name,
}
}
fn handle_native(name: &str) -> &str {
if name != NATIVE_CPU {
return arch_to_gcc(name);
}
#[cfg(feature = "master")]
{
// Get the native arch.
let context = Context::default();
context.get_target_info().arch().unwrap().to_str().unwrap()
}
#[cfg(not(feature = "master"))]
unimplemented!();
}
pub fn target_cpu(sess: &Session) -> &str {
match sess.opts.cg.target_cpu {
Some(ref name) => handle_native(name),
None => handle_native(sess.target.cpu.as_ref()),
}
}
View on GitHub (pinned to 7088e4b63a)