Skip to content

Conversation

@Enselic
Copy link
Member

@Enselic Enselic commented Jan 2, 2026

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 2, 2026
@Enselic Enselic changed the title Add on broken pipe Add initial #![feature(on_broken_pipe)] code Jan 2, 2026
@rust-log-analyzer

This comment has been minimized.

@Enselic Enselic force-pushed the add-on_broken_pipe branch from 7ce0046 to 5825fb6 Compare January 2, 2026 15:05
So that the name is semantically correct for
`#[feature(on_broken_pipe)]` (and actually also `-Zon-broken-pipe` if we
end up keeping that).
…position

So we don't need to update the test when the implementation changes. The
default will work fine. No need to set it explicitly to Error. That is
the default.
@Enselic Enselic force-pushed the add-on_broken_pipe branch from 5825fb6 to 7b52018 Compare January 5, 2026 21:46
@rustbot rustbot added A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc O-unix Operating system: Unix-like T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 5, 2026
@Enselic Enselic changed the title Add initial #![feature(on_broken_pipe)] code Replace -Zon-broken-pipe=... with Externally Implementable Item #[std::io::on_broken_pipe() -> std::io::OnBrokenPipe Jan 5, 2026
@Enselic Enselic changed the title Replace -Zon-broken-pipe=... with Externally Implementable Item #[std::io::on_broken_pipe() -> std::io::OnBrokenPipe Replace -Zon-broken-pipe=... with Externally Implementable Item #[std::io::on_broken_pipe] Jan 5, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment on lines 314 to 320
// `std::io::on_broken_pipe` is implemented via EII and becomes an `extern "Rust"`
// function without a body. Under v0 mangling this shows up with a mangled symbol name
// (e.g. `_RNv..._3std2io14on_broken_pipe`).
//
// Miri does not support the real behavior (changing host SIGPIPE disposition), so we
// treat this as a no-op and request inheriting SIGPIPE.
name if name == "on_broken_pipe" || name.contains("std2io14on_broken_pipe") => {
Copy link
Member

@RalfJung RalfJung Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is just for testing for now, but this hack is definitely not something we'd want to land.

The proper fix here is to implement EII in Miri, so that the real implementation gets invoked. We already have hacks in place to ignore std trying to change the host SIGPIPE disposition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that was indeed a hack and not intended for review. I just wanted to see how far away I was from getting PR CI to pass.

Your comment was still helpful however. I have removed the code and replaced it with

            #[cfg(not(miri))]
            let on_broken_pipe = crate::io::on_broken_pipe();
            #[cfg(miri)] // FIXME: Add proper miri support. See https://github.com/rust-lang/rust/pull/150591#discussion_r2665432118.
            let on_broken_pipe = OnBrokenPipe::BackwardsCompatible;

and will probably create a proper issue for it later.

(Note that this code is still not ready for review.)

Kobzol added a commit to Kobzol/rust that referenced this pull request Jan 7, 2026
rustc book: fix grammar

It was added in ddee45e ([here](https://github.com/rust-lang/rust/pull/97802/changes#diff-85dc642a7bdad363a9e37d2491230280fcd977391ba7a242bda2da9ddb55f654) to be specific) when SIGPIPE was controlled with an attribute on `fn main()` which meant it could also be combined with `#[rustc_main]`:

    #[unix_sigpipe = "sig_dfl"]
    #[rustc_main]
    fn rustc_main() {

The test stopped being needed in cde0cde when `#[unix_sigpipe = "..."]` was replaced by `-Zon-broken-pipe=...`. And it will not be needed when `-Zon-broken-pipe=...` is replaced by an Externally Implementable Item (see rust-lang#150591). Let's remove this test.

Tracking issue:
- rust-lang#150588
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
tests/ui/runtime/on-broken-pipe/with-rustc_main.rs: Not needed so remove

It was added in ddee45e ([here](https://github.com/rust-lang/rust/pull/97802/changes#diff-85dc642a7bdad363a9e37d2491230280fcd977391ba7a242bda2da9ddb55f654) to be specific) when SIGPIPE was controlled with an attribute on `fn main()` which meant it could also be combined with `#[rustc_main]`:

    #[unix_sigpipe = "sig_dfl"]
    #[rustc_main]
    fn rustc_main() {

The test stopped being needed in cde0cde when `#[unix_sigpipe = "..."]` was replaced by `-Zon-broken-pipe=...`. And it will not be needed when `-Zon-broken-pipe=...` is replaced by an Externally Implementable Item (see rust-lang#150591). Let's remove this test.

Tracking issue:
- rust-lang#150588
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
tests/ui/runtime/on-broken-pipe/with-rustc_main.rs: Not needed so remove

It was added in ddee45e ([here](https://github.com/rust-lang/rust/pull/97802/changes#diff-85dc642a7bdad363a9e37d2491230280fcd977391ba7a242bda2da9ddb55f654) to be specific) when SIGPIPE was controlled with an attribute on `fn main()` which meant it could also be combined with `#[rustc_main]`:

    #[unix_sigpipe = "sig_dfl"]
    #[rustc_main]
    fn rustc_main() {

The test stopped being needed in cde0cde when `#[unix_sigpipe = "..."]` was replaced by `-Zon-broken-pipe=...`. And it will not be needed when `-Zon-broken-pipe=...` is replaced by an Externally Implementable Item (see rust-lang#150591). Let's remove this test.

Tracking issue:
- rust-lang#150588
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
tests/ui/runtime/on-broken-pipe/with-rustc_main.rs: Not needed so remove

It was added in ddee45e ([here](https://github.com/rust-lang/rust/pull/97802/changes#diff-85dc642a7bdad363a9e37d2491230280fcd977391ba7a242bda2da9ddb55f654) to be specific) when SIGPIPE was controlled with an attribute on `fn main()` which meant it could also be combined with `#[rustc_main]`:

    #[unix_sigpipe = "sig_dfl"]
    #[rustc_main]
    fn rustc_main() {

The test stopped being needed in cde0cde when `#[unix_sigpipe = "..."]` was replaced by `-Zon-broken-pipe=...`. And it will not be needed when `-Zon-broken-pipe=...` is replaced by an Externally Implementable Item (see rust-lang#150591). Let's remove this test.

Tracking issue:
- rust-lang#150588
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2026
Fix `alloc_error_handler` signature mismatch

It was added in ddee45e ([here](https://github.com/rust-lang/rust/pull/97802/changes#diff-85dc642a7bdad363a9e37d2491230280fcd977391ba7a242bda2da9ddb55f654) to be specific) when SIGPIPE was controlled with an attribute on `fn main()` which meant it could also be combined with `#[rustc_main]`:

    #[unix_sigpipe = "sig_dfl"]
    #[rustc_main]
    fn rustc_main() {

The test stopped being needed in cde0cde when `#[unix_sigpipe = "..."]` was replaced by `-Zon-broken-pipe=...`. And it will not be needed when `-Zon-broken-pipe=...` is replaced by an Externally Implementable Item (see rust-lang#150591). Let's remove this test.

Tracking issue:
- rust-lang#150588
rust-timer added a commit that referenced this pull request Jan 8, 2026
Rollup merge of #150757 - rm-unneded-test, r=bjorn3

Fix `alloc_error_handler` signature mismatch

It was added in ddee45e ([here](https://github.com/rust-lang/rust/pull/97802/changes#diff-85dc642a7bdad363a9e37d2491230280fcd977391ba7a242bda2da9ddb55f654) to be specific) when SIGPIPE was controlled with an attribute on `fn main()` which meant it could also be combined with `#[rustc_main]`:

    #[unix_sigpipe = "sig_dfl"]
    #[rustc_main]
    fn rustc_main() {

The test stopped being needed in cde0cde when `#[unix_sigpipe = "..."]` was replaced by `-Zon-broken-pipe=...`. And it will not be needed when `-Zon-broken-pipe=...` is replaced by an Externally Implementable Item (see #150591). Let's remove this test.

Tracking issue:
- #150588
@Enselic Enselic force-pushed the add-on_broken_pipe branch from 76f940b to fc9e23b Compare January 8, 2026 18:20
@rustbot rustbot added A-tidy Area: The tidy tool O-hermit Operating System: Hermit O-SGX Target: SGX O-solid Operating System: SOLID O-windows Operating system: Windows T-clippy Relevant to the Clippy team. labels Jan 8, 2026
@rust-log-analyzer
Copy link
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking rustc_codegen_cranelift v0.1.0 (/checkout/compiler/rustc_codegen_cranelift)
error[E0425]: cannot find value `sigpipe` in this scope
  --> compiler/rustc_codegen_cranelift/src/main_shim.rs:88:59
   |
88 |             let arg_sigpipe = bcx.ins().iconst(types::I8, sigpipe as i64);
   |                                                           ^^^^^^^ not found in this scope

warning: unused import: `rustc_session::config::EntryFnType`
 --> compiler/rustc_codegen_cranelift/src/main_shim.rs:4:5
  |
---
   |                    ^^^^^^^^ method not found in `(rustc_span::def_id::DefId, EntryFnType)`
   |
help: one of the expressions' fields has a method of the same name
   |
22 |     if main_def_id.0.is_local() {
   |                    ++

error[E0308]: mismatched types
   --> compiler/rustc_codegen_cranelift/src/main_shim.rs:23:44
    |
---
                found tuple `(rustc_span::def_id::DefId, EntryFnType)`
note: associated function defined here
   --> /checkout/compiler/rustc_middle/src/ty/instance.rs:465:12
    |
465 |     pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> {
    |            ^^^^

error[E0308]: mismatched types
  --> compiler/rustc_codegen_cranelift/src/main_shim.rs:31:34
   |
31 |     create_entry_fn(tcx, module, main_def_id, is_jit);
   |     ---------------              ^^^^^^^^^^^ expected `DefId`, found `(DefId, EntryFnType)`
   |     |
   |     arguments to this function are incorrect
   |
   = note: expected struct `rustc_span::def_id::DefId`
               found tuple `(rustc_span::def_id::DefId, EntryFnType)`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool O-hermit Operating System: Hermit O-SGX Target: SGX O-solid Operating System: SOLID O-unix Operating system: Unix-like O-windows Operating system: Windows S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants