{"id":"aabbfba94f59e586","repo":"rust-lang/rust","slug":"not-implemented","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_gcc/src/base.rs","lineNumber":69,"sourceCode":"        Linkage::WeakODR => unimplemented!(),\n        Linkage::Internal => GlobalKind::Internal,\n        Linkage::ExternalWeak => GlobalKind::Imported, // FIXME(antoyo): should be weak linkage.\n        Linkage::Common => unimplemented!(),\n    }\n}\n\npub fn linkage_to_gcc(linkage: Linkage) -> FunctionType {\n    match linkage {\n        Linkage::External => FunctionType::Exported,\n        // FIXME(antoyo): set the attribute externally_visible.\n        Linkage::AvailableExternally => FunctionType::Extern,\n        Linkage::LinkOnceAny => unimplemented!(),\n        Linkage::LinkOnceODR => unimplemented!(),\n        Linkage::WeakAny => FunctionType::Exported, // FIXME(antoyo): should be similar to linkonce.\n        Linkage::WeakODR => unimplemented!(),\n        Linkage::Internal => FunctionType::Internal,\n        Linkage::ExternalWeak => unimplemented!(),\n        Linkage::Common => unimplemented!(),\n    }\n}\n\npub fn compile_codegen_unit(\n    tcx: TyCtxt<'_>,\n    cgu_name: Symbol,\n    target_info: LockedTargetInfo,\n    lto_supported: bool,\n) -> (ModuleCodegen<GccContext>, u64) {\n    let prof_timer = tcx.prof.generic_activity(\"codegen_module\");\n    let start_time = Instant::now();\n\n    let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx);\n    let (module, _) = tcx.dep_graph.with_task(\n        dep_node,\n        tcx,\n        || module_codegen(tcx, cgu_name, target_info, lto_supported),\n        Some(dep_graph::hash_result),","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_codegen_gcc/src/base.rs#L51-L87","documentation":"Thrown by rustc_codegen_gcc (the libgccjit backend) when mapping a Rust linkage kind to a libgccjit FunctionType. The linkage_to_gcc() match handles External, AvailableExternally, WeakAny, Internal, but panics with unimplemented!() for LinkOnceAny, LinkOnceODR, WeakODR, ExternalWeak, and Common. The specific line (base.rs:69) is Linkage::Common => unimplemented!(), meaning a function/static with common/tentative linkage cannot be lowered to GCC. Common linkage corresponds to C-style tentative definitions and COMDAT-like globals.","triggerScenarios":"Compiling a function or static whose Linkage resolves to Common while using the gccjit backend (-Ccodegen-backend=gcc). This arises from items annotated with #[linkage = \"...\"], certain COMDAT/section attributes, weak symbols from FFI, or compiler-generated common symbols during LTO/codegen-unit partitioning. Several other linkage variants (LinkOnce*, WeakODR, ExternalWeak) in the same function panic identically.","commonSituations":"Using the gccjit backend (rustc_codegen_gcc / gcc-codegen) with crates that rely on weak or tentative linkage - common in C-FFI bindings, dynamic-plugin systems, or kernel/embedded code with #[linkage]. Also hits with -C lto configurations that merge symbols into COMDAT-like groups the GCC backend never implemented.","solutions":["Switch the codegen backend to LLVM for this crate (remove -Ccodegen-backend=gcc / RUSTC_CODEGEN_BACKEND=gcc).","Remove or replace the #[linkage = \"...\"] / tentative-definition attribute causing Common linkage.","Disable LTO (-Clto=no) if the Common linkage appears only during LTO symbol merging.","Implement the Common (and related LinkOnce*/WeakODR/ExternalWeak) arms in linkage_to_gcc() by mapping to the closest libgccjit FunctionType / GlobalKind and submit upstream."],"exampleFix":"// before\n#[linkage = \"external\"]\nstatic FOO: u32 = 0; // or a tentative-definition pattern producing Common\n\n// after - plain internal static, no special linkage\nstatic FOO: u32 = 0;","handlingStrategy":"fallback","validationCode":"// cg_gcc emits a generic 'not implemented' from base.rs. Pre-flight by\n// building a tiny probe crate and checking the codegen works before\n// committing to cg_gcc for the whole workspace.\nlet status = std::process::Command::new(\"cargo\")\n    .args([\"build\", \"--lib\", \"--\", \"-Zcodegen-backend=gcc\"])\n    .current_dir(\"probe/\").status()?;\nif !status.success() { eprintln!(\"cg_gcc unsupported feature hit; use LLVM.\"); }","typeGuard":null,"tryCatchPattern":"// Unreachable at runtime — the panic is in rustc_codegen_gcc's base layer\n// and aborts compilation. Wrap the *cargo invocation* in CI and fall back:\nlet s = std::process::Command::new(\"cargo\").args([\"build\"]).status();\nif !s.map(|s| s.success()).unwrap_or(false) {\n    std::process::Command::new(\"cargo\").args([\"build\"]).status()?; // LLVM fallback\n}","preventionTips":["Treat cg_gcc as experimental; pin a known-good gcc + rustc_codegen_gcc pair.","Run a nightly smoke build over your crate list before adopting cg_gcc in CI.","Keep LLVM as the default backend; only opt into cg_gcc per-target where it's verified."],"tags":["rustc","gcc","gccjit","codegen","unimplemented","linkage","ffi"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}