{"id":"4a6740ec4efe5dbd","repo":"rust-lang/rust","slug":"not-implemented-4a6740","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_gcc/src/gcc_util.rs","lineNumber":130,"sourceCode":"        \"M68000\" => \"68000\",\n        \"M68020\" => \"68020\",\n        _ => name,\n    }\n}\n\nfn handle_native(name: &str) -> &str {\n    if name != NATIVE_CPU {\n        return arch_to_gcc(name);\n    }\n\n    #[cfg(feature = \"master\")]\n    {\n        // Get the native arch.\n        let context = Context::default();\n        context.get_target_info().arch().unwrap().to_str().unwrap()\n    }\n    #[cfg(not(feature = \"master\"))]\n    unimplemented!();\n}\n\npub fn target_cpu(sess: &Session) -> &str {\n    match sess.opts.cg.target_cpu {\n        Some(ref name) => handle_native(name),\n        None => handle_native(sess.target.cpu.as_ref()),\n    }\n}\n","sourceCodeStart":112,"sourceCodeEnd":139,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_codegen_gcc/src/gcc_util.rs#L112-L139","documentation":"`handle_native` (gcc_util.rs:118-131) resolves the `native` target CPU: if the requested `name` is not the special `NATIVE_CPU` token it maps via `arch_to_gcc`. When `name == NATIVE_CPU` (i.e. `-C target-cpu=native`), detecting the actual host CPU requires the libgccjit `master` feature — `context.get_target_info().arch()` (gcc_util.rs:126-127). Without `feature=\"master\"` the fallback is `unimplemented!()` at line 130. So building/running rustc_codegen_gcc without the `master` feature and requesting native CPU detection is unsupported.","triggerScenarios":"Compiling with `--cfg feature=\"master\"` disabled (the default for a plain `cargo build` of the backend) AND the codegen session requests `target-cpu=native` or the target spec's `cpu` field equals `NATIVE_CPU`. `target_cpu(sess)` (gcc_util.rs:133-138) calls `handle_native` which hits the `#[cfg(not(feature = \"master\"))]` arm.","commonSituations":"Running the backend without the `master` libgccjit feature but passing `-Ctarget-cpu=native` (common when users copy LLVM-oriented RUSTFLAGS). Also when the target spec itself defaults `cpu` to `native`. The `master` feature corresponds to building libgccjit from its Git master branch rather than a released version.","solutions":["Enable the `master` feature when building rustc_codegen_gcc (`--cfg feature=\"master\"` / build with the project's prescribed libgccjit-master toolchain) so `get_target_info().arch()` is available.","Stop passing `-Ctarget-cpu=native`; use an explicit CPU name (e.g. `-Ctarget-cpu=x86-64`) which takes the `arch_to_gcc` path and does not require the feature.","If you must support native detection without the master feature, implement a fallback (e.g. read the host CPU via another mechanism) instead of `unimplemented!()`.","Check that your libgccjit is built from master and that the gccjit crate exposes `get_target_info`; a released libgccjit lacks this API."],"exampleFix":"// before (invocation triggering gcc_util.rs:130)\n// RUSTFLAGS='-Ctarget-cpu=native' cargo build   (master feature OFF)\n\n// after\n// either enable master, or pin the cpu:\n// 1) build backend with:   --cfg feature=\"master\"\n// 2) or pass explicit cpu: RUSTFLAGS='-Ctarget-cpu=x86-64' cargo build","handlingStrategy":"fallback","validationCode":"// gcc_util.rs:130 -> unimplemented!() under #[cfg(not(feature = \"master\"))]\n// for native arch detection. Enable the master libgccjit feature, or bypass\n// native_arch() by passing target_cpu explicitly.\n#[cfg(feature = \"master\")]\nfn native_arch() -> String { /* implemented path */ }\n#[cfg(not(feature = \"master\"))]\nfn native_arch() -> String {\n    // fallback: do not query libgccjit; use a static/hardcoded value\n    String::from(\"native\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build and link against a libgccjit with the `master` feature enabled; without it native arch detection is unimplemented.","Pass target_cpu/native explicitly on the rustc command line so native_arch() is never queried.","If master cannot be enabled, route CPU detection through LLVM or a static per-target table."],"tags":["rustc-codegen-gcc","target-cpu","native","master-feature","libgccjit","unimplemented"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}