{"id":"76b247a75a351f5e","repo":"rust-lang/rust","slug":"llvm-config-was-not-set","errorCode":null,"errorMessage":"LLVM_CONFIG was not set","messagePattern":"LLVM_CONFIG was not set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_llvm/build.rs","lineNumber":186,"sourceCode":"\nfn main() {\n    if cfg!(feature = \"check_only\") {\n        return;\n    }\n\n    for component in REQUIRED_COMPONENTS.iter().chain(OPTIONAL_COMPONENTS.iter()) {\n        println!(\"cargo:rustc-check-cfg=cfg(llvm_component,values(\\\"{component}\\\"))\");\n    }\n\n    if tracked_env_var_os(\"RUST_CHECK\").is_some() {\n        // If we're just running `check`, there's no need for LLVM to be built.\n        return;\n    }\n\n    restore_library_path();\n\n    let llvm_config =\n        PathBuf::from(tracked_env_var_os(\"LLVM_CONFIG\").expect(\"LLVM_CONFIG was not set\"));\n\n    println!(\"cargo:rerun-if-changed={}\", llvm_config.display());\n\n    // FIXME: `--quote-paths` was added to llvm-config in LLVM 22, so this test (and all its ensuing\n    //        fallback paths) can be removed once we bump the minimum llvm_version >= (22, 0, 0).\n    let llvm_config_supports_quote_paths =\n        stderr(Command::new(&llvm_config).arg(\"--help\")).contains(\"quote-paths\");\n\n    let quoted_split = |mut cmd: Command| {\n        if llvm_config_supports_quote_paths {\n            LlvmConfigOutput::QuotedPaths(output(cmd.arg(\"--quote-paths\")))\n        } else {\n            LlvmConfigOutput::UnquotedPaths(output(&mut cmd))\n        }\n    };\n\n    // Test whether we're cross-compiling LLVM. This is a pretty rare case\n    // currently where we're producing an LLVM for a different platform than","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_llvm/build.rs#L168-L204","documentation":"Thrown at build.rs:185-186 via `tracked_env_var_os(\"LLVM_CONFIG\").expect(\"LLVM_CONFIG was not set\")`. rustc_llvm's build script drives an external `llvm-config` executable to discover LLVM include paths, link flags, and components (build.rs:228, 243, 336, 454). Bootstrap is responsible for exporting the LLVM_CONFIG env var pointing at the correct binary; if it is absent, the build script cannot proceed and panics.","triggerScenarios":"Running the rustc_llvm build script without bootstrap having set LLVM_CONFIG — e.g. `cargo build` invoked directly, or a custom build harness that does not export it. Also seen when bootstrap's LLVM discovery fails silently or the var is unset for a target that expects system LLVM.","commonSituations":"Building compiler/rustc_llvm by hand with cargo instead of `./x.py`; misconfigured bootstrap config.toml that does not locate an LLVM installation; switching between system LLVM and in-tree LLVM builds without updating configuration.","solutions":["Build via bootstrap: `./x.py build`, which sets LLVM_CONFIG to the appropriate llvm-config (in-tree or system).","If you must build rustc_llvm manually, set LLVM_CONFIG to an absolute path of a working llvm-config, e.g. `LLVM_CONFIG=/usr/bin/llvm-config cargo build -p rustc_llvm`.","Check config.toml's [llvm] section; when using a system LLVM ensure llvm-config is on PATH or llvm-config is explicitly specified, then re-run bootstrap."],"exampleFix":null,"handlingStrategy":"validation","validationCode":": \"${LLVM_CONFIG:?LLVM_CONFIG must point to an llvm-config binary}\"\n[ -x \"$LLVM_CONFIG\" ] || { echo \"$LLVM_CONFIG is not executable\"; exit 1; }\n\"$LLVM_CONFIG\" --version >/dev/null 2>&1 || { echo \"llvm-config unusable\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export LLVM_CONFIG in your shell rc and CI environment before any cargo/x.py build","Point it at the exact LLVM the toolchain was built against, not a stray system one","Verify with `llvm-config --version` as the first CI step"],"tags":["rustc-internals","build-script","llvm","environment","bootstrap"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}