Skip to content

Commit

Permalink
rustc: Use unix_sigpipe instead of rustc_driver::set_sigpipe_handler
Browse files Browse the repository at this point in the history
This is the first (known) step towards starting to use `unix_sigpipe` in
the wild. Eventually, `rustc_driver::set_sigpipe_handler` can be removed
and all clients can use `unix_sigpipe` instead.

For now we just start using `unix_sigpipe` in once place: `rustc`
itself.

It is easy to manually verify this change. If you remove
`#[unix_sigpipe = "sig_dfl"]` and run `./x.py build` you will get an ICE
when you do `./build/x86_64-unknown-linux-gnu/stage1/bin/rustc --help |
false`. Add back `#[unix_sigpipe = "sig_dfl"]` and the ICE disappears
again.
  • Loading branch information
Enselic committed Oct 2, 2022
1 parent 756e7be commit 093b075
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![feature(unix_sigpipe)]

// A note about jemalloc: rustc uses jemalloc when built for CI and
// distribution. The obvious way to do this is with the `#[global_allocator]`
// mechanism. However, for complicated reasons (see
Expand All @@ -23,6 +25,7 @@
// libraries. So we must reference jemalloc symbols one way or another, because
// this file is the only object code in the rustc executable.

#[unix_sigpipe = "sig_dfl"]
fn main() {
// See the comment at the top of this file for an explanation of this.
#[cfg(feature = "jemalloc-sys")]
Expand Down Expand Up @@ -58,6 +61,5 @@ fn main() {
}
}

rustc_driver::set_sigpipe_handler();
rustc_driver::main()
}

0 comments on commit 093b075

Please sign in to comment.