Prevent EPIPE causing ICEs in rustc and rustdoc
This commit is contained in:
parent
4b9b70c394
commit
7ab31f6556
4 changed files with 19 additions and 3 deletions
|
@ -548,6 +548,18 @@ fn run_compiler_impl<'a>(args: &[String],
|
||||||
(result, Some(sess))
|
(result, Some(sess))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
pub fn set_sigpipe_handler() {
|
||||||
|
unsafe {
|
||||||
|
// Set the SIGPIPE signal handler, so that an EPIPE
|
||||||
|
// will cause rustc to terminate, as expected.
|
||||||
|
assert!(libc::signal(libc::SIGPIPE, libc::SIG_DFL) != libc::SIG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub fn set_sigpipe_handler() {}
|
||||||
|
|
||||||
// Extract output directory and file from matches.
|
// Extract output directory and file from matches.
|
||||||
fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>) {
|
fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>) {
|
||||||
let odir = matches.opt_str("out-dir").map(|o| PathBuf::from(&o));
|
let odir = matches.opt_str("out-dir").map(|o| PathBuf::from(&o));
|
||||||
|
|
|
@ -101,6 +101,7 @@ struct Output {
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
const STACK_SIZE: usize = 32_000_000; // 32MB
|
const STACK_SIZE: usize = 32_000_000; // 32MB
|
||||||
|
rustc_driver::set_sigpipe_handler();
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let res = std::thread::Builder::new().stack_size(STACK_SIZE).spawn(move || {
|
let res = std::thread::Builder::new().stack_size(STACK_SIZE).spawn(move || {
|
||||||
syntax::with_globals(move || {
|
syntax::with_globals(move || {
|
||||||
|
|
|
@ -80,11 +80,11 @@ pub fn init() {
|
||||||
reset_sigpipe();
|
reset_sigpipe();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os="fuchsia")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "fuchsia")))]
|
||||||
unsafe fn reset_sigpipe() {
|
unsafe fn reset_sigpipe() {
|
||||||
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR);
|
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR);
|
||||||
}
|
}
|
||||||
#[cfg(any(target_os = "emscripten", target_os="fuchsia"))]
|
#[cfg(any(target_os = "emscripten", target_os = "fuchsia"))]
|
||||||
unsafe fn reset_sigpipe() {}
|
unsafe fn reset_sigpipe() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,7 @@ extern {}
|
||||||
|
|
||||||
extern crate rustc_driver;
|
extern crate rustc_driver;
|
||||||
|
|
||||||
fn main() { rustc_driver::main() }
|
fn main() {
|
||||||
|
rustc_driver::set_sigpipe_handler();
|
||||||
|
rustc_driver::main()
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue