rust-lang/rust · critical
command did not execute successfully: {:?} expected success,
Error message
command did not execute successfully: {:?}
expected success, got: {} What it means
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.
Source
Thrown at compiler/rustc_llvm/build.rs:102
if entry.file_type().unwrap().is_dir() {
stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));
} else {
println!("cargo:rerun-if-changed={}", path.display());
}
}
}
#[track_caller]
fn execute(cmd: &mut Command) -> Output {
let output = match cmd.output() {
Ok(status) => status,
Err(e) => {
println!("\n\nfailed to execute command: {cmd:?}\nerror: {e}\n\n");
std::process::exit(1);
}
};
if !output.status.success() {
panic!(
"command did not execute successfully: {:?}\n\
expected success, got: {}",
cmd, output.status
);
}
output
}
#[track_caller]
fn output(cmd: &mut Command) -> String {
String::from_utf8(execute(cmd.stderr(Stdio::inherit())).stdout).unwrap()
}
#[track_caller]
fn stderr(cmd: &mut Command) -> String {
String::from_utf8(execute(cmd).stderr).unwrap()
}
enum LlvmConfigOutput {View on GitHub (pinned to 22057b88b0)
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.
Defensive patterns
Strategy: retry
Validate before calling
# Dry-run every external tool the build script can invoke before the real build
for tool in llvm-config cmake ninja clang cc; do
command -v "$tool" >/dev/null 2>&1 || { echo "missing required tool: $tool"; exit 1; }
done
"$LLVM_CONFIG" --version >/dev/null 2>&1 || { echo "llvm-config not runnable"; exit 1; } Try / catch
# Wrap the cargo/x.py build so transient external-command failures are retried
n=0
until ./x.py build compiler/rustc_llvm; do
n=$((n+1)); [ "$n" -lt 3 ] || { echo "build failed after $n attempts"; exit 1; }
echo "retrying build (attempt $n)..."
done Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- REAL_LIBRARY_PATH_VAR
- LLVM_CONFIG was not set
- require llvm component {component} but wasn't found
- TARGET was not set
- HOST was not set
AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03).
Data as JSON: /data/errors/f4cb778433bdb77d.json.
Report an issue: GitHub.