diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-27 09:20:18 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-27 09:20:18 -0700 |
| commit | c9cdc87d8b58be04a17212a9f72b80562f5de32c (patch) | |
| tree | 2e6146bb6a8cbb7557be4522660b2141b0122569 | |
| parent | e0543409d5c3835e1355831449dfd7435c4336ff (diff) | |
| parent | b99668bd221ea2fe99141e7de6db6a4b86efb7b6 (diff) | |
| download | rust-c9cdc87d8b58be04a17212a9f72b80562f5de32c.tar.gz rust-c9cdc87d8b58be04a17212a9f72b80562f5de32c.zip | |
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.)
| -rw-r--r-- | src/bootstrap/bin/rustc.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index fd36cd9bd8b..af75faf698e 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -153,7 +153,7 @@ fn main() { e => e, }; println!("\nDid not run successfully: {:?}\n{:?}\n-------------", e, cmd); - exec_cmd(&mut on_fail).expect("could not run the backup command"); + status_code(&mut on_fail).expect("could not run the backup command"); std::process::exit(1); } @@ -182,17 +182,10 @@ fn main() { } } - let code = exec_cmd(&mut cmd).unwrap_or_else(|_| panic!("\n\n failed to run {:?}", cmd)); + let code = status_code(&mut cmd).unwrap_or_else(|_| panic!("\n\n failed to run {:?}", cmd)); std::process::exit(code); } -#[cfg(unix)] -fn exec_cmd(cmd: &mut Command) -> io::Result<i32> { - use std::os::unix::process::CommandExt; - Err(cmd.exec()) -} - -#[cfg(not(unix))] -fn exec_cmd(cmd: &mut Command) -> io::Result<i32> { +fn status_code(cmd: &mut Command) -> io::Result<i32> { cmd.status().map(|status| status.code().unwrap()) } |
