Rollup merge of #131442 - jieyouxu:mir-opt-rebuild, r=onur-ozkan

Match std `RUSTFLAGS` for host and target for `mir-opt` test suite to fix double std build/rebuilds

Previously the bootstrap compiletest `Step::run` flow had:

```rs
// ensure that `libproc_macro` is available on the host.
builder.ensure(compile::Std::new(compiler, compiler.host));

// ...

if suite == "mir-opt" {
    builder.ensure(compile::Std::new_for_mir_opt_tests(compiler, target));
} else {
    builder.ensure(compile::Std::new(compiler, target));
}
```

This can cause unnecessary std rebuilds (even on the same invocation) because if host == target then `builder.ensure(compile::Std::new_for_mir_opt_tests(compiler, target))` will have different `RUSTFLAGS` than `builder.ensure(compile::Std::new(compiler, compiler.host))`.

This PR fixes that by matching up std `RUSTFLAGS` if the test suite is `mir-opt`:

```rs
if suite == "mir-opt" {
    builder.ensure(compile::Std::new_for_mir_opt_tests(compiler, compiler.host));
} else {
    builder.ensure(compile::Std::new(compiler, compiler.host));
}
```

This is a short-term fix, the better fix is to enforce how `RUSTFLAGS` are handled as described in https://github.com/rust-lang/rust/issues/131437#issuecomment-2401710727.

Fixes #131437.
This commit is contained in:
Matthias Krüger 2024-10-10 22:00:49 +02:00 committed by GitHub
commit 28bc5a2f7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1697,7 +1697,11 @@ fn run(self, builder: &Builder<'_>) {
builder.ensure(TestHelpers { target: compiler.host }); builder.ensure(TestHelpers { target: compiler.host });
// ensure that `libproc_macro` is available on the host. // ensure that `libproc_macro` is available on the host.
if suite == "mir-opt" {
builder.ensure(compile::Std::new_for_mir_opt_tests(compiler, compiler.host));
} else {
builder.ensure(compile::Std::new(compiler, compiler.host)); builder.ensure(compile::Std::new(compiler, compiler.host));
}
// As well as the target // As well as the target
if suite != "mir-opt" { if suite != "mir-opt" {