{"id":"c21404f0e888aff9","repo":"rust-lang/rust","slug":"require-llvm-component-component-but-wasn-t-foun","errorCode":null,"errorMessage":"require llvm component {component} but wasn't found","messagePattern":"require llvm component (.+?) but wasn't found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_llvm/build.rs","lineNumber":234,"sourceCode":"    // report itself with a `--host-target` of `x86_64-pc-windows-gnu`. This\n    // tricks us into thinking we're doing a cross build when we aren't, so\n    // havoc ensues.\n    //\n    // In any case, if we're cross compiling, this generally just means that we\n    // can't trust all the output of llvm-config because it might be targeted\n    // for the host rather than the target. As a result a bunch of blocks below\n    // are gated on `if !is_crossed`\n    let target = env::var(\"TARGET\").expect(\"TARGET was not set\");\n    let host = env::var(\"HOST\").expect(\"HOST was not set\");\n    let is_crossed = target != host;\n\n    let components = output(Command::new(&llvm_config).arg(\"--components\"));\n    let mut components = components.split_whitespace().collect::<Vec<_>>();\n    components.retain(|c| OPTIONAL_COMPONENTS.contains(c) || REQUIRED_COMPONENTS.contains(c));\n\n    for component in REQUIRED_COMPONENTS {\n        if !components.contains(component) {\n            panic!(\"require llvm component {component} but wasn't found\");\n        }\n    }\n\n    for component in components.iter() {\n        println!(\"cargo:rustc-cfg=llvm_component=\\\"{component}\\\"\");\n    }\n\n    // Link in our own LLVM shims, compiled with the same flags as LLVM\n    let mut cmd = Command::new(&llvm_config);\n    cmd.arg(\"--cxxflags\");\n    let cxxflags = quoted_split(cmd);\n    let mut cfg = cc::Build::new();\n    cfg.warnings(false);\n\n    // Prevent critical warnings when we're compiling from rust-lang/rust CI,\n    // except on MSVC, as the compiler throws warnings that are only reported\n    // for this platform. See https://github.com/rust-lang/rust/pull/145031#issuecomment-3162677202.\n    // Moreover, LLVM generally guarantees warning-freedom only when building with Clang, as other","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_llvm/build.rs#L216-L252","documentation":"Thrown at build.rs:232-235 when `llvm-config --components` does not report one of the required LLVM components. REQUIRED_COMPONENTS (build.rs:33-34) is [ipo, bitreader, bitwriter, linker, asmparser, lto, coverage, instrumentation]; the loop at build.rs:232-236 verifies each is present in the components list (after filtering to known names at build.rs:230). A missing required component means the LLVM installation rustc is linking against was built without enabling that component, so rustc_llvm cannot function.","triggerScenarios":"Pointing LLVM_CONFIG at an LLVM build that was configured with `-DLLVM_TARGETS_TO_BUILD=...` only or with components disabled (e.g. a minimal/system LLVM lacking lto, coverage, or instrumentation); building rustc against a distro LLVM package split into subpackages where not all are installed.","commonSituations":"Using a stripped-down or vendor LLVM that omits components rustc needs; switching from in-tree LLVM (built by bootstrap with all components) to a system LLVM that is incomplete; outdated LLVM version where component names differ.","solutions":["Rebuild LLVM with the full set of targets/components, or use rustc's in-tree LLVM via bootstrap (`./x.py build`), which enables everything required.","Install any missing distro LLVM subpackages corresponding to the named component (e.g. coverage/lto/dev packages).","Verify with `llvm-config --components` that all of [ipo, bitreader, bitwriter, linker, asmparser, lto, coverage, instrumentation] are listed; if not, the LLVM_CONFIG path is wrong or the LLVM build is incomplete."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Ensure every LLVM component rustc_llvm needs is present before building\nNEEDED=\"orcjit native webassembly target\"\nHAVE=$(\"$LLVM_CONFIG\" --components)\nfor c in $NEEDED; do\n  grep -qw \"$c\" <<<\"$HAVE\" || { echo \"missing required llvm component: $c\"; exit 1; }\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install an LLVM build that includes all components rustc_llvm/build.rs:234 requires","Re-run `llvm-config --components` after any LLVM upgrade and diff against the required set","Build LLVM with component groups enabled (e.g. -DLLVM_BUILD_LLVM_DYLIB=ON) if your distro splits them"],"tags":["rustc-internals","build-script","llvm","llvm-config","linking"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}