Skip to content

Commit b90a385

Browse files
Rollup merge of #105736 - chenyukang:yukang/add-mir-opt-level-testing, r=jyn514
Test that the compiler/library builds with validate-mir Fixes #105706
2 parents 31448ba + 001bcee commit b90a385

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
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/docker/host-x86_64/mingw-check/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2323

2424
RUN curl -sL https://nodejs.org/dist/v16.9.0/node-v16.9.0-linux-x64.tar.xz | tar -xJ
2525
ENV PATH="/node-v16.9.0-linux-x64/bin:${PATH}"
26+
ENV RUST_CONFIGURE_ARGS="--set rust.validate-mir-opts=3"
27+
2628
# Install es-check
2729
# Pin its version to prevent unrelated CI failures due to future es-check versions.
2830
@@ -38,7 +40,7 @@ COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/
3840

3941
ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
4042
ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
41-
python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu --all-targets && \
43+
python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && \
4244
python3 ../x.py build --stage 0 src/tools/build-manifest && \
4345
python3 ../x.py test --stage 0 src/tools/compiletest && \
4446
python3 ../x.py test --stage 0 core alloc std test proc_macro && \

0 commit comments

Comments
 (0)