{"record":{"id":"a8db0594d4287c94","repo":"rust-lang/rust","slug":"from-rlib","errorCode":null,"errorMessage":"from rlib","messagePattern":"from rlib","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_gcc/src/back/lto.rs","lineNumber":236,"sourceCode":"        serialized_modules.sort_by(|module1, module2| module1.1.cmp(&module2.1));\n\n        // We add the object files and save in should_combine_object_files that we should combine\n        // them into a single object file when compiling later.\n        for (bc_decoded, name) in serialized_modules {\n            let _timer = prof\n                .generic_activity_with_arg_recorder(\"GCC_fat_lto_link_module\", |recorder| {\n                    recorder.record_arg(format!(\"{:?}\", name))\n                });\n            info!(\"linking {:?}\", name);\n            match bc_decoded {\n                SerializedModule::Local(ref module_buffer) => {\n                    module.module_llvm.lto_mode = LtoMode::Fat;\n                    module\n                        .module_llvm\n                        .context\n                        .add_driver_option(module_buffer.0.to_str().expect(\"path\"));\n                }\n                SerializedModule::FromRlib(_) => unimplemented!(\"from rlib\"),\n                SerializedModule::FromUncompressedFile(_) => {\n                    unimplemented!(\"from uncompressed file\")\n                }\n            }\n        }\n        save_temp_bitcode(cgcx, &module, \"lto.input\");\n\n        // Internalize everything below threshold to help strip out more modules and such.\n        /*unsafe {\n        let ptr = symbols_below_threshold.as_ptr();\n        llvm::LLVMRustRunRestrictionPass(\n            llmod,\n            ptr as *const *const libc::c_char,\n            symbols_below_threshold.len() as libc::size_t,\n        );*/\n\n        save_temp_bitcode(cgcx, &module, \"lto.after-restriction\");\n        //}","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_codegen_gcc/src/back/lto.rs#L218-L254","documentation":"Raised by rustc_codegen_gcc's fat-LTO path when a serialized module being linked is a SerializedModule::FromRlib variant. The GCC backend has not implemented consuming rlib-embedded bitcode for fat LTO, so this code path panics with unimplemented! to signal an unsupported configuration rather than silently miscompiling.","triggerScenarios":"Building with -C linker-plugin-lto / fat LTO where one of the inputs reaches the back end as FromRlib, while using rustc_codegen_gcc (the GCC backend) instead of the default LLVM backend. The match arm at lto.rs:236 panics.","commonSituations":"Switching a project from the LLVM backend to the experimental GCC backend while leaving fat/cross-crate LTO enabled; depending on a precompiled rlib that the GCC backend would need to inline during LTO.","solutions":["Disable fat LTO for the GCC backend (-C lto=off or -C lto=thin if supported).","Rebuild the rlib dependencies with the GCC backend so they enter LTO as Local modules rather than FromRlib.","Track / contribute the missing FromRlib handling upstream in rustc_codegen_gcc."],"exampleFix":"# before\nRUSTFLAGS='-C linker-plugin-lto -C lto=fat' cargo build\n# after\nRUSTFLAGS='-C lto=off' cargo build\n","handlingStrategy":"validation","validationCode":"# In build scripts, detect the GCC backend + fat LTO and refuse early\nimport os, sys\nflags = os.environ.get(\"RUSTFLAGS\", \"\")\nif \"codegen-backend=gcc\" in flags and (\"lto=fat\" in flags or \"linker-plugin-lto\" in flags):\n    sys.exit(\"rustc_codegen_gcc does not support FromRlib fat LTO; use -C lto=off\")\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not enable fat/cross-crate LTO with the GCC backend until FromRlib is implemented.","Rebuild rlib deps with the GCC backend so they enter LTO as Local modules."],"tags":["codegen","gcc-backend","lto","rustc","unimplemented"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}