Skip to content

Adjusting -Zon-broken-pipe=kill to only be applied to rustc/rustdoc binary wrappers break two cargo tests #131059

@jieyouxu

Description

@jieyouxu

In https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Modifying.20run-make.20tests.20unnecessarily.20rebuild.20stage.201.20cargo we identified the root cause of #130980 (unnecessary stage 1 cargo rebuilds) being

// `-Zon-broken-pipe=kill` breaks cargo tests
if !path.ends_with("cargo") {
// If the output is piped to e.g. `head -n1` we want the process to be killed,
// rather than having an error bubble up and cause a panic.
cargo.rustflag("-Zon-broken-pipe=kill");
}

The other instance of this is

cargo.rustflag("-Zon-broken-pipe=kill");

As @onur-ozkan (thank you so much) pointed out:

It's not just about cargo builds. If you run x build clippy and then x build cargo, the build cache for clippy will be broken because bootstrap sets -Zon-broken-pipe=kill for every invocation except for cargo. Which means building cargo will invalidate any tool build cache which was built previously.


I tried to limit application of -Zon-broken-pipe=kill to rustc and rustdoc binary wrappers in src/bootstrap/src/bin/{rustc,rustdoc}.rs themselves, and unfortunately this leads to two cargo test failures:

---- build::close_output stdout ----
thread 'build::close_output' panicked at tests/testsuite/build.rs:6680:18:

---- expected: tests/testsuite/build.rs:6682:9
++++ actual:   In-memory
   1    1 | [COMPILING] foo v0.1.0 ([ROOT]/foo)
   2    2 | hello stderr!
   3      - [ERROR] [BROKEN_PIPE]
   4      - [WARNING] build failed, waiting for other jobs to finish...

Update with SNAPSHOTS=overwrite

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- cargo_command::closed_output_ok stdout ----
thread 'cargo_command::closed_output_ok' panicked at tests/testsuite/cargo_command.rs:549:5:
assertion failed: status.success()


failures:
    build::close_output
    cargo_command::closed_output_ok
Previous history

I'm putting up a PR (#131060) to remove conditionally adding -Zon-broken-pipe=kill, and as @saethlin pointed out we expect two cargo tests to be broken with RUSTFLAGS=-Zon-broken-pipe=kill ./x test src/tools/cargo if that is unconditionally passed to bootstrap.

---- build::close_output stdout ----
thread 'build::close_output' panicked at tests/testsuite/build.rs:6680:18:

---- expected: tests/testsuite/build.rs:6682:9
++++ actual:   In-memory
   1    1 | [COMPILING] foo v0.1.0 ([ROOT]/foo)
   2    2 | hello stderr!
   3      - [ERROR] [BROKEN_PIPE]
   4      - [WARNING] build failed, waiting for other jobs to finish...

Update with SNAPSHOTS=overwrite

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- cargo_command::closed_output_ok stdout ----
thread 'cargo_command::closed_output_ok' panicked at tests/testsuite/cargo_command.rs:549:5:
assertion failed: status.success()


failures:
    build::close_output
    cargo_command::closed_output_ok

I don't know if this breaks someone's workflow regarding to piping cargo tool tests, but in the interest of not making everyone rebuild stage1 cargo on every single invocation of ./x test run-make, I'm considering this as "known breakage" for the time being. As @saethlin suggested:

If someone wants to both set -Zon-broken-pipe and also run the Cargo test suite, I think they should file an issue and be part of a discussion about how to support that and what the costs are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-testsuiteArea: The testsuite used to check the correctness of rustcC-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-cargoRelevant to the cargo team, which will review and decide on the PR/issue.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions