about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-04-08 00:08:44 +0000
committerbors <bors@rust-lang.org>2024-04-08 00:08:44 +0000
commita2c72ce59414d689d3d9f7e6a6a97455d2ac6cad (patch)
tree3c8fecf5972b303789f5b40ef438e76c77668a8e /src
parentf65f84feb0c299ba926f57b998f03f61d3382464 (diff)
parent596908bb9a05d92abe971e62b167d0a763b6d736 (diff)
downloadrust-a2c72ce59414d689d3d9f7e6a6a97455d2ac6cad.tar.gz
rust-a2c72ce59414d689d3d9f7e6a6a97455d2ac6cad.zip
Auto merge of #123506 - RalfJung:miri-test-libstd, r=Mark-Simulacrum
check-aux: test core, alloc, std in Miri

Let's see if this works, and how long it takes.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/mk/Makefile.in30
-rw-r--r--src/bootstrap/src/core/build_steps/test.rs31
-rw-r--r--src/ci/docker/host-x86_64/x86_64-gnu-aux/Dockerfile4
3 files changed, 55 insertions, 10 deletions
diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in
index 0b67079917c..d6e60d52d63 100644
--- a/src/bootstrap/mk/Makefile.in
+++ b/src/bootstrap/mk/Makefile.in
@@ -52,6 +52,36 @@ check-aux:
 		src/tools/cargo \
 		src/tools/cargotest \
 		$(BOOTSTRAP_ARGS)
+	# Run standard library tests in Miri.
+	# We use a 64bit little-endian and a 32bit big-endian target for max coverage.
+	$(Q)BOOTSTRAP_SKIP_TARGET_SANITY=1 \
+		$(BOOTSTRAP) miri --stage 2 \
+		--target x86_64-unknown-linux-gnu,mips-unknown-linux-gnu \
+		library/core \
+		library/alloc \
+		--no-doc
+	# Some doctests have intentional memory leaks.
+	# Also, they work only on the host.
+	$(Q)MIRIFLAGS="-Zmiri-ignore-leaks -Zmiri-disable-isolation" \
+		$(BOOTSTRAP) miri --stage 2 \
+		library/core \
+		library/alloc \
+		--doc
+	# In `std` we cannot test everything.
+	$(Q)MIRIFLAGS="-Zmiri-disable-isolation" BOOTSTRAP_SKIP_TARGET_SANITY=1 \
+		$(BOOTSTRAP) miri --stage 2 library/std \
+		--no-doc -- \
+		--skip fs:: --skip net:: --skip process:: --skip sys::pal::
+	$(Q)MIRIFLAGS="-Zmiri-ignore-leaks -Zmiri-disable-isolation" BOOTSTRAP_SKIP_TARGET_SANITY=1 \
+		$(BOOTSTRAP) miri --stage 2 library/std \
+		--doc -- \
+		--skip fs:: --skip net:: --skip process:: --skip sys::pal::
+	# Also test some very target-specific modules on other targets.
+	$(Q)MIRIFLAGS="-Zmiri-disable-isolation" BOOTSTRAP_SKIP_TARGET_SANITY=1 \
+		$(BOOTSTRAP) miri --stage 2 library/std \
+		--target aarch64-apple-darwin,i686-pc-windows-gnu \
+		--no-doc -- \
+		time:: sync:: thread:: env::
 dist:
 	$(Q)$(BOOTSTRAP) dist $(BOOTSTRAP_ARGS)
 distcheck:
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs
index 028e0f6d05f..1e68f8d276a 100644
--- a/src/bootstrap/src/core/build_steps/test.rs
+++ b/src/bootstrap/src/core/build_steps/test.rs
@@ -2689,16 +2689,27 @@ impl Step for Crate {
 
         match mode {
             Mode::Std => {
-                compile::std_cargo(builder, target, compiler.stage, &mut cargo);
-                // `std_cargo` actually does the wrong thing: it passes `--sysroot build/host/stage2`,
-                // but we want to use the force-recompile std we just built in `build/host/stage2-test-sysroot`.
-                // Override it.
-                if builder.download_rustc() && compiler.stage > 0 {
-                    let sysroot = builder
-                        .out
-                        .join(compiler.host.triple)
-                        .join(format!("stage{}-test-sysroot", compiler.stage));
-                    cargo.env("RUSTC_SYSROOT", sysroot);
+                if builder.kind == Kind::Miri {
+                    // We can't use `std_cargo` as that uses `optimized-compiler-builtins` which
+                    // needs host tools for the given target. This is similar to what `compile::Std`
+                    // does when `is_for_mir_opt_tests` is true. There's probably a chance for
+                    // de-duplication here... `std_cargo` should support a mode that avoids needing
+                    // host tools.
+                    cargo
+                        .arg("--manifest-path")
+                        .arg(builder.src.join("library/sysroot/Cargo.toml"));
+                } else {
+                    compile::std_cargo(builder, target, compiler.stage, &mut cargo);
+                    // `std_cargo` actually does the wrong thing: it passes `--sysroot build/host/stage2`,
+                    // but we want to use the force-recompile std we just built in `build/host/stage2-test-sysroot`.
+                    // Override it.
+                    if builder.download_rustc() && compiler.stage > 0 {
+                        let sysroot = builder
+                            .out
+                            .join(compiler.host.triple)
+                            .join(format!("stage{}-test-sysroot", compiler.stage));
+                        cargo.env("RUSTC_SYSROOT", sysroot);
+                    }
                 }
             }
             Mode::Rustc => {
diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-aux/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-aux/Dockerfile
index e08c4e1e8b7..a74db2250fc 100644
--- a/src/ci/docker/host-x86_64/x86_64-gnu-aux/Dockerfile
+++ b/src/ci/docker/host-x86_64/x86_64-gnu-aux/Dockerfile
@@ -25,5 +25,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
 COPY scripts/sccache.sh /scripts/
 RUN sh /scripts/sccache.sh
 
+# Miri is just too slow with full assertions
+ENV NO_DEBUG_ASSERTIONS=1
+ENV NO_OVERFLOW_CHECKS=1
+
 ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu
 ENV RUST_CHECK_TARGET check-aux