Skip to content

Commit b71b26b

Browse files
committed
Test that the compiler/library builds with -Zmir-opt-level=3 -Zvalidate-mir
1 parent 58f5a01 commit b71b26b

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

config.toml.example

+3
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,9 @@ changelog-seen = 2
649649
# "thin" or "fat" to apply Thin/Fat LTO to the `rustc_driver` dylib.
650650
#lto = "thin-local"
651651

652+
# Build compiler with the optimization enabled and -Zvalidate-mir, currently only for `std`
653+
#validate-mir-opts = 3
654+
652655
# =============================================================================
653656
# Options for specific targets
654657
#

src/bootstrap/builder.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,13 @@ impl<'a> Builder<'a> {
18711871
}
18721872
}
18731873

1874+
if matches!(mode, Mode::Std) {
1875+
if let Some(mir_opt_level) = self.config.rust_validate_mir_opts {
1876+
rustflags.arg("-Zvalidate-mir");
1877+
rustflags.arg(&format!("-Zmir-opt-level={}", mir_opt_level));
1878+
}
1879+
}
1880+
18741881
Cargo { command: cargo, rustflags, rustdocflags }
18751882
}
18761883

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ pub struct Config {
168168
pub rust_profile_use: Option<String>,
169169
pub rust_profile_generate: Option<String>,
170170
pub rust_lto: RustcLto,
171+
pub rust_validate_mir_opts: Option<u32>,
171172
pub llvm_profile_use: Option<String>,
172173
pub llvm_profile_generate: bool,
173174
pub llvm_libunwind_default: Option<LlvmLibunwind>,
@@ -762,6 +763,7 @@ define_config! {
762763
// ignored; this is set from an env var set by bootstrap.py
763764
download_rustc: Option<StringOrBool> = "download-rustc",
764765
lto: Option<String> = "lto",
766+
validate_mir_opts: Option<u32> = "validate-mir-opts",
765767
}
766768
}
767769

@@ -1136,6 +1138,7 @@ impl Config {
11361138
.as_deref()
11371139
.map(|value| RustcLto::from_str(value).unwrap())
11381140
.unwrap_or_default();
1141+
config.rust_validate_mir_opts = rust.validate_mir_opts;
11391142
} else {
11401143
config.rust_profile_use = flags.rust_profile_use;
11411144
config.rust_profile_generate = flags.rust_profile_generate;

src/ci/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
6464
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
6565
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static"
6666
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1"
67+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.validate-mir-opts=3"
6768

6869
# Only produce xz tarballs on CI. gz tarballs will be generated by the release
6970
# process by recompressing the existing xz ones. This decreases the storage

0 commit comments

Comments
 (0)