Rollup merge of #38459 - nagisa:rustbuild-exec, r=alexcrichton
Use exec for the wrapper on UNIXes This not only avoids the small – and unnecessary – constant overhead for each compiler invocation, but also helps somewhat by only having “correct” rustc processes to look for in `/proc/`. This also makes the wrapper behave effectively as a regular exec wrapper its intended to be. I also took liberty to change the fallback error code from `1` to `0xfe` (now only relevant on windows) so that when people complain about “compiler exited with code 254”, its obvious where the issue lies (wrapper losing the exit code somehow). r? @alexcrichton
This commit is contained in:
commit
05be48b18b
1 changed files with 14 additions and 3 deletions
|
@ -30,7 +30,7 @@ extern crate bootstrap;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::{Command, ExitStatus};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = env::args_os().skip(1).collect::<Vec<_>>();
|
let args = env::args_os().skip(1).collect::<Vec<_>>();
|
||||||
|
@ -180,8 +180,19 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually run the compiler!
|
// Actually run the compiler!
|
||||||
std::process::exit(match cmd.status() {
|
std::process::exit(match exec_cmd(&mut cmd) {
|
||||||
Ok(s) => s.code().unwrap_or(1),
|
Ok(s) => s.code().unwrap_or(0xfe),
|
||||||
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
|
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn exec_cmd(cmd: &mut Command) -> ::std::io::Result<ExitStatus> {
|
||||||
|
use std::os::unix::process::CommandExt;
|
||||||
|
Err(cmd.exec())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
fn exec_cmd(cmd: &mut Command) -> ::std::io::Result<ExitStatus> {
|
||||||
|
cmd.status()
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue