{"record":{"id":"f0f94e1eff0f63fb","repo":"rust-lang/rust","slug":"llc-failed-to-compile-into","errorCode":null,"errorMessage":"llc failed to compile {} into {}","messagePattern":"llc failed to compile (.+?) into (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/tools/llvm-bitcode-linker/src/linker.rs","lineNumber":156,"sourceCode":"        if let Some(mattr) = &self.feature {\n            lcc_command.arg(&format!(\"--mattr={}\", mattr));\n        }\n\n        let lcc_output = lcc_command\n            .arg(&self.opt_path)\n            .arg(\"-o\").arg(&self.out_path)\n            .output()\n            .context(\"An error occurred when calling llc. Make sure the llvm-tools component is installed.\")?;\n\n        if !lcc_output.status.success() {\n            tracing::error!(\n                \"llc returned with Exit status: {}\\n stdout: {}\\n stderr: {}\",\n                lcc_output.status,\n                String::from_utf8(lcc_output.stdout).unwrap(),\n                String::from_utf8(lcc_output.stderr).unwrap(),\n            );\n\n            anyhow::bail!(\n                \"llc failed to compile {} into {}\",\n                self.opt_path.display(),\n                self.out_path.display()\n            );\n        }\n\n        Ok(())\n    }\n\n    /// Links, optimizes and compiles to the native format\n    pub fn lto(&mut self, optimization: crate::Optimization, debug: bool) -> anyhow::Result<()> {\n        self.link()?;\n        self.optimize(optimization, debug)?;\n        self.compile()\n    }\n}\n","sourceCodeStart":138,"sourceCodeEnd":173,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/tools/llvm-bitcode-linker/src/linker.rs#L138-L173","documentation":"Bailed by Session::compile when the llc subprocess returns non-zero while translating the optimized bitcode to native object code. llc had the target CPU/features and the optimized .o as input; failure means it could not emit the requested object file.","triggerScenarios":"Reached after optimize() succeeds, when llc fails. Causes: an llc from a mismatched LLVM version; an --mcpu/--mattr value the target doesn't recognize; the optimized bitcode referencing intrinsics llc can't lower.","commonSituations":"Cross-compiling with a CPU/feature string (e.g. --mcpu=native on a foreign target) llc rejects; system llc vs bundled LLVM mismatch; corrupted opt_path from a partial optimize step.","solutions":["Read the logged llc stderr for the exact diagnostic (unknown CPU, bad feature, unsupported intrinsic).","Use the llc matching rustc's LLVM (rustup component llvm-tools), not a distro llc.","Validate the cpu/feature strings against `llc --mcpu=help` / `--mattr=help` for the target triple.","Re-run optimize() to regenerate opt_path if the input bitcode is suspect."],"exampleFix":"// before\nanyhow::bail!(\"llc failed to compile {} into {}\",\n    self.opt_path.display(), self.out_path.display());\n\n// after: embed llc stderr\nlet stderr = String::from_utf8_lossy(&lcc_output.stderr);\nanyhow::bail!(\n    \"llc failed to compile {} into {}: {}\",\n    self.opt_path.display(), self.out_path.display(),\n    stderr.trim()\n);","handlingStrategy":"validation","validationCode":"// Validate CPU/feature strings against llc's catalog for the target:\nfn cpu_supported(llc: &str, cpu: &str, target: &str) -> bool {\n    let o = std::process::Command::new(llc)\n        .arg(format!(\"--mtriple={target}\")).arg(\"--mcpu=help\").output();\n    matches!(o, Ok(out) if String::from_utf8_lossy(&out.stdout).contains(cpu))\n}","typeGuard":"null","tryCatchPattern":"match session.lto(opt, debug) {\n    Ok(()) => Ok(()),\n    Err(e) if e.to_string().contains(\"llc failed\") => {\n        eprintln!(\"llc rejected CPU/feature or bitcode; re-check target triple\");\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Cross-check --mcpu/--mattr with `llc --mcpu=help` for the target.","Keep llc on PATH version-matched to rustc's bundled LLVM.","Cross-compile in a clean env so a system llc is never accidentally picked up."],"tags":["llvm","compiler","bitcode","subprocess","llvm-bitcode-linker"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}