From 0cf17e750d7790e0f2fc1fb184b6f917f55462ca Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Mon, 27 Jul 2020 02:42:02 +0100 Subject: [PATCH 1/2] 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 --- src/bootstrap/bin/rustc.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index fd36cd9bd8beb..c8ee4cb0cd2ef 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -186,13 +186,6 @@ fn main() { std::process::exit(code); } -#[cfg(unix)] -fn exec_cmd(cmd: &mut Command) -> io::Result { - use std::os::unix::process::CommandExt; - Err(cmd.exec()) -} - -#[cfg(not(unix))] fn exec_cmd(cmd: &mut Command) -> io::Result { cmd.status().map(|status| status.code().unwrap()) } From b99668bd221ea2fe99141e7de6db6a4b86efb7b6 Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Mon, 27 Jul 2020 03:00:28 +0100 Subject: [PATCH 2/2] rustbuild: rename exec_cmd -> status_code for clarity --- src/bootstrap/bin/rustc.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index c8ee4cb0cd2ef..af75faf698ecd 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,10 +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); } -fn exec_cmd(cmd: &mut Command) -> io::Result { +fn status_code(cmd: &mut Command) -> io::Result { cmd.status().map(|status| status.code().unwrap()) }