Description
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
rust/src/bootstrap/src/core/build_steps/tool.rs
Lines 212 to 217 in e9df22f
The other instance of this is
As @onur-ozkan (thank you so much) pointed out:
It's not just about cargo builds. If you run
x build clippy
and thenx build cargo
, the build cache forclippy
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.