Skip to content

Commit c9cdc87

Browse files
authored
Rollup merge of #74803 - infinity0:fix-exec, r=nagisa
rustbuild: fix bad usage of UNIX exec() in rustc wrapper exec never returns, it replaces the current process. so anything after it is unreachable. that's not how exec_cmd() is used in the surrounding code We use `--on-fail env` on Debian. `env` always returns exit code 0. This means that the `rustc` bootstrap wrapper always returns exit code 0 even when it fails. However, the crossbeam-utils build process (due to autocfg) relies on `rustc` returning error exit codes when detecting CPU features, and ends up writing `cargo:rustc-cfg=has_atomic_u128` even when it's not detected, because the `rustc` wrapper is always giving exit code 0. (This separately is causing our builds to try to compile rustc 40+ times, due to #74801.)
2 parents e054340 + b99668b commit c9cdc87

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/bootstrap/bin/rustc.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn main() {
153153
e => e,
154154
};
155155
println!("\nDid not run successfully: {:?}\n{:?}\n-------------", e, cmd);
156-
exec_cmd(&mut on_fail).expect("could not run the backup command");
156+
status_code(&mut on_fail).expect("could not run the backup command");
157157
std::process::exit(1);
158158
}
159159

@@ -182,17 +182,10 @@ fn main() {
182182
}
183183
}
184184

185-
let code = exec_cmd(&mut cmd).unwrap_or_else(|_| panic!("\n\n failed to run {:?}", cmd));
185+
let code = status_code(&mut cmd).unwrap_or_else(|_| panic!("\n\n failed to run {:?}", cmd));
186186
std::process::exit(code);
187187
}
188188

189-
#[cfg(unix)]
190-
fn exec_cmd(cmd: &mut Command) -> io::Result<i32> {
191-
use std::os::unix::process::CommandExt;
192-
Err(cmd.exec())
193-
}
194-
195-
#[cfg(not(unix))]
196-
fn exec_cmd(cmd: &mut Command) -> io::Result<i32> {
189+
fn status_code(cmd: &mut Command) -> io::Result<i32> {
197190
cmd.status().map(|status| status.code().unwrap())
198191
}

0 commit comments

Comments
 (0)