{"id":"f4cb778433bdb77d","repo":"rust-lang/rust","slug":"command-did-not-execute-successfully-expecte","errorCode":null,"errorMessage":"command did not execute successfully: {:?}\nexpected success, got: {}","messagePattern":"command did not execute successfully: (.+?)\nexpected success, got: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_llvm/build.rs","lineNumber":102,"sourceCode":"        if entry.file_type().unwrap().is_dir() {\n            stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));\n        } else {\n            println!(\"cargo:rerun-if-changed={}\", path.display());\n        }\n    }\n}\n\n#[track_caller]\nfn execute(cmd: &mut Command) -> Output {\n    let output = match cmd.output() {\n        Ok(status) => status,\n        Err(e) => {\n            println!(\"\\n\\nfailed to execute command: {cmd:?}\\nerror: {e}\\n\\n\");\n            std::process::exit(1);\n        }\n    };\n    if !output.status.success() {\n        panic!(\n            \"command did not execute successfully: {:?}\\n\\\n             expected success, got: {}\",\n            cmd, output.status\n        );\n    }\n    output\n}\n\n#[track_caller]\nfn output(cmd: &mut Command) -> String {\n    String::from_utf8(execute(cmd.stderr(Stdio::inherit())).stdout).unwrap()\n}\n#[track_caller]\nfn stderr(cmd: &mut Command) -> String {\n    String::from_utf8(execute(cmd).stderr).unwrap()\n}\n\nenum LlvmConfigOutput {","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_llvm/build.rs#L84-L120","documentation":"Thrown by execute() (build.rs:92-109) — the shared command runner for rustc_llvm's build script — when an invoked command exits with a non-success status. It panics with the full command (`{:?}`) and its ExitStatus. The commands run through execute()/output()/stderr() are almost always `llvm-config` invocations (e.g. `--components`, `--help`, `--link-shared --libs`, `--cxxflags`, `--ldflags`), so a failure here means llvm-config itself errored.","triggerScenarios":"llvm-config exits non-zero: the configured LLVM_CONFIG path points at a broken or mismatched LLVM build; the LLVM installation is missing libraries llvm-config expects; `llvm-config --help` (build.rs:193), `--components` (build.rs:228), `--cxxflags`, `--libs`, or `--ldflags` fails. Any execute()/output()/stderr() call in main() can surface it.","commonSituations":"Building rustc against a hand-built or system LLVM that is incomplete, corrupted, or the wrong version; LLVM_CONFIG pointing to a stale binary after an LLVM rebuild; cross-compiling where the host llvm-config cannot run on the target; missing system libraries that llvm-config tries to report.","solutions":["Reproduce the exact failing command shown in the panic (the `{:?}` Command debug output) by running it manually in a shell, then read llvm-config's stderr to find the real cause.","Ensure LLVM_CONFIG points to a working llvm-config matching the LLVM version rustc expects; rebuild/reinstall LLVM if its install is corrupt.","Prefer building LLVM through bootstrap (`./x.py build` with the default src/llvm-project) so the toolchain and llvm-config stay consistent.","If cross-compiling, verify you are using the host-side llvm-config as bootstrap intends and that host/target LLVM are configured identically."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Dry-run every external tool the build script can invoke before the real build\nfor tool in llvm-config cmake ninja clang cc; do\n  command -v \"$tool\" >/dev/null 2>&1 || { echo \"missing required tool: $tool\"; exit 1; }\ndone\n\"$LLVM_CONFIG\" --version >/dev/null 2>&1 || { echo \"llvm-config not runnable\"; exit 1; }","typeGuard":null,"tryCatchPattern":"# Wrap the cargo/x.py build so transient external-command failures are retried\nn=0\nuntil ./x.py build compiler/rustc_llvm; do\n  n=$((n+1)); [ \"$n\" -lt 3 ] || { echo \"build failed after $n attempts\"; exit 1; }\n  echo \"retrying build (attempt $n)...\"\ndone","preventionTips":["Pre-validate every external binary (llvm-config, cmake, ninja) is on PATH and executable","Run the heaviest command standalone first to separate real failures from transient ones","Distinguish exit 124/125 (timeout/resource cull) from genuine failures before retrying"],"tags":["rustc-internals","build-script","llvm","llvm-config","environment"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}