Skip to content

Commit 34813e2

Browse files
committed
Test that the compiler/library builds with -Zmir-opt-level=3 -Zvalidate-mir
1 parent 07c993e commit 34813e2

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
@@ -666,6 +666,9 @@ changelog-seen = 2
666666
# LTO entirely.
667667
#lto = "thin-local"
668668

669+
# Build compiler with the optimization enabled and -Zvalidate-mir, currently only for `std`
670+
#validate-mir-opts = 3
671+
669672
# =============================================================================
670673
# Options for specific targets
671674
#

src/bootstrap/builder.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,13 @@ impl<'a> Builder<'a> {
19151915
}
19161916
}
19171917

1918+
if matches!(mode, Mode::Std) {
1919+
if let Some(mir_opt_level) = self.config.rust_validate_mir_opts {
1920+
rustflags.arg("-Zvalidate-mir");
1921+
rustflags.arg(&format!("-Zmir-opt-level={}", mir_opt_level));
1922+
}
1923+
}
1924+
19181925
Cargo { command: cargo, rustflags, rustdocflags, allow_features }
19191926
}
19201927

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ pub struct Config {
173173
pub rust_profile_use: Option<String>,
174174
pub rust_profile_generate: Option<String>,
175175
pub rust_lto: RustcLto,
176+
pub rust_validate_mir_opts: Option<u32>,
176177
pub llvm_profile_use: Option<String>,
177178
pub llvm_profile_generate: bool,
178179
pub llvm_libunwind_default: Option<LlvmLibunwind>,
@@ -770,6 +771,7 @@ define_config! {
770771
// ignored; this is set from an env var set by bootstrap.py
771772
download_rustc: Option<StringOrBool> = "download-rustc",
772773
lto: Option<String> = "lto",
774+
validate_mir_opts: Option<u32> = "validate-mir-opts",
773775
}
774776
}
775777

@@ -1149,6 +1151,7 @@ impl Config {
11491151
.as_deref()
11501152
.map(|value| RustcLto::from_str(value).unwrap())
11511153
.unwrap_or_default();
1154+
config.rust_validate_mir_opts = rust.validate_mir_opts;
11521155
} else {
11531156
config.rust_profile_use = flags.rust_profile_use;
11541157
config.rust_profile_generate = flags.rust_profile_generate;

src/ci/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
5858
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
5959
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static"
6060
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1"
61+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.validate-mir-opts=3"
6162

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

0 commit comments

Comments
 (0)