From 34813e205157f0235e5cf8847079f13ac6acd078 Mon Sep 17 00:00:00 2001 From: yukang Date: Thu, 15 Dec 2022 14:49:11 +0800 Subject: [PATCH 1/3] Test that the compiler/library builds with -Zmir-opt-level=3 -Zvalidate-mir --- config.toml.example | 3 +++ src/bootstrap/builder.rs | 7 +++++++ src/bootstrap/config.rs | 3 +++ src/ci/run.sh | 1 + 4 files changed, 14 insertions(+) diff --git a/config.toml.example b/config.toml.example index df4478bb0cb8..69eb228a2d5a 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 952c70cec1c0..fe92ee3c18ef 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 56f96734bbbc..4a563bc396dc 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -173,6 +173,7 @@ pub struct Config { pub rust_profile_use: Option, pub rust_profile_generate: Option, pub rust_lto: RustcLto, + pub rust_validate_mir_opts: Option, pub llvm_profile_use: Option, pub llvm_profile_generate: bool, pub llvm_libunwind_default: Option, @@ -770,6 +771,7 @@ define_config! { // ignored; this is set from an env var set by bootstrap.py download_rustc: Option = "download-rustc", lto: Option = "lto", + validate_mir_opts: Option = "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/run.sh b/src/ci/run.sh index 93dccb54c4e3..1f451fc479c2 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -58,6 +58,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1" +RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.validate-mir-opts=3" # Only produce xz tarballs on CI. gz tarballs will be generated by the release # process by recompressing the existing xz ones. This decreases the storage From 15813cf6466ed4d7d546b2f08e9521dfe496ef53 Mon Sep 17 00:00:00 2001 From: yukang Date: Wed, 28 Dec 2022 21:10:57 +0800 Subject: [PATCH 2/3] enable validate-mir-opts in mingw-check --- src/ci/docker/host-x86_64/mingw-check/Dockerfile | 4 +++- src/ci/run.sh | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/host-x86_64/mingw-check/Dockerfile b/src/ci/docker/host-x86_64/mingw-check/Dockerfile index 4cc5d9f8a0da..a7220710830f 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 @@ -39,7 +41,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 build --stage 0 src/tools/build-manifest && \ + python3 ../x.py build --stage 0 src/tools/build-manifest library/std && \ python3 ../x.py test --stage 0 src/tools/compiletest && \ python3 ../x.py test --stage 0 core alloc std test proc_macro && \ # Build both public and internal documentation. diff --git a/src/ci/run.sh b/src/ci/run.sh index 1f451fc479c2..93dccb54c4e3 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -58,7 +58,6 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1" -RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.validate-mir-opts=3" # Only produce xz tarballs on CI. gz tarballs will be generated by the release # process by recompressing the existing xz ones. This decreases the storage From 001bceeb1ecd1239031a5c7ff711106b2b1c54cc Mon Sep 17 00:00:00 2001 From: yukang Date: Fri, 24 Feb 2023 22:51:25 +0000 Subject: [PATCH 3/3] check is default to all targets now --- src/ci/docker/host-x86_64/mingw-check/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/host-x86_64/mingw-check/Dockerfile b/src/ci/docker/host-x86_64/mingw-check/Dockerfile index a7220710830f..98bd90210d61 100644 --- a/src/ci/docker/host-x86_64/mingw-check/Dockerfile +++ b/src/ci/docker/host-x86_64/mingw-check/Dockerfile @@ -40,8 +40,8 @@ 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 build --stage 0 src/tools/build-manifest library/std && \ + 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 && \ # Build both public and internal documentation.