Skip to content

Commit

Permalink
Use exec for the wrapper on UNIXes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nagisa committed Dec 18, 2016
1 parent 8327b5a commit b3b2f1b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern crate bootstrap;
use std::env;
use std::ffi::OsString;
use std::path::PathBuf;
use std::process::Command;
use std::process::{Command, ExitStatus};

fn main() {
let args = env::args_os().skip(1).collect::<Vec<_>>();
Expand Down Expand Up @@ -180,8 +180,19 @@ fn main() {
}

// Actually run the compiler!
std::process::exit(match cmd.status() {
Ok(s) => s.code().unwrap_or(1),
std::process::exit(match exec_cmd(&mut cmd) {
Ok(s) => s.code().unwrap_or(0xfe),
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()
}

0 comments on commit b3b2f1b

Please sign in to comment.