about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-02-25 11:53:08 -0800
committerGitHub <noreply@github.com>2023-02-25 11:53:08 -0800
commitb90a385f26ed16587cb17e28883f5aacd293b9af (patch)
tree759105a405ab414ce2a55916cf14ef52e1f02a8b
parent31448badfd74ea72d2c8622cc60d3dca889ef7d4 (diff)
parent001bceeb1ecd1239031a5c7ff711106b2b1c54cc (diff)
Rollup merge of #105736 - chenyukang:yukang/add-mir-opt-level-testing, r=jyn514
Test that the compiler/library builds with validate-mir

Fixes #105706
-rw-r--r--config.toml.example3
-rw-r--r--src/bootstrap/builder.rs7
-rw-r--r--src/bootstrap/config.rs3
-rw-r--r--src/ci/docker/host-x86_64/mingw-check/Dockerfile4
4 files changed, 16 insertions, 1 deletions
diff --git a/config.toml.example b/config.toml.example
index df4478bb0cb..69eb228a2d5 100644
--- a/config.toml.example
+++ b/config.toml.example
@@ -666,6 +666,9 @@ changelog-seen = 2
 # LTO entirely.
 #lto = "thin-local"
 
+# Build compiler with the optimization enabled and -Zvalidate-mir, currently only for `std`
+#validate-mir-opts = 3
+
 # =============================================================================
 # Options for specific targets
 #
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 952c70cec1c..fe92ee3c18e 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1915,6 +1915,13 @@ impl<'a> Builder<'a> {
             }
         }
 
+        if matches!(mode, Mode::Std) {
+            if let Some(mir_opt_level) = self.config.rust_validate_mir_opts {
+                rustflags.arg("-Zvalidate-mir");
+                rustflags.arg(&format!("-Zmir-opt-level={}", mir_opt_level));
+            }
+        }
+
         Cargo { command: cargo, rustflags, rustdocflags, allow_features }
     }
 
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 56f96734bbb..4a563bc396d 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -173,6 +173,7 @@ pub struct Config {
     pub rust_profile_use: Option<String>,
     pub rust_profile_generate: Option<String>,
     pub rust_lto: RustcLto,
+    pub rust_validate_mir_opts: Option<u32>,
     pub llvm_profile_use: Option<String>,
     pub llvm_profile_generate: bool,
     pub llvm_libunwind_default: Option<LlvmLibunwind>,
@@ -770,6 +771,7 @@ define_config! {
         // ignored; this is set from an env var set by bootstrap.py
         download_rustc: Option<StringOrBool> = "download-rustc",
         lto: Option<String> = "lto",
+        validate_mir_opts: Option<u32> = "validate-mir-opts",
     }
 }
 
@@ -1149,6 +1151,7 @@ impl Config {
                 .as_deref()
                 .map(|value| RustcLto::from_str(value).unwrap())
                 .unwrap_or_default();
+            config.rust_validate_mir_opts = rust.validate_mir_opts;
         } else {
             config.rust_profile_use = flags.rust_profile_use;
             config.rust_profile_generate = flags.rust_profile_generate;
diff --git a/src/ci/docker/host-x86_64/mingw-check/Dockerfile b/src/ci/docker/host-x86_64/mingw-check/Dockerfile
index 4cc5d9f8a0d..98bd90210d6 100644
--- a/src/ci/docker/host-x86_64/mingw-check/Dockerfile
+++ b/src/ci/docker/host-x86_64/mingw-check/Dockerfile
@@ -23,6 +23,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
 
 RUN curl -sL https://nodejs.org/dist/v16.9.0/node-v16.9.0-linux-x64.tar.xz | tar -xJ
 ENV PATH="/node-v16.9.0-linux-x64/bin:${PATH}"
+ENV RUST_CONFIGURE_ARGS="--set rust.validate-mir-opts=3"
+
 # Install es-check
 # Pin its version to prevent unrelated CI failures due to future es-check versions.
 RUN npm install es-check@6.1.1 eslint@8.6.0 -g
@@ -38,7 +40,7 @@ COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/
 
 ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
 ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
-           python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu --all-targets && \
+           python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && \
            python3 ../x.py build --stage 0 src/tools/build-manifest && \
            python3 ../x.py test --stage 0 src/tools/compiletest && \
            python3 ../x.py test --stage 0 core alloc std test proc_macro && \