From 23b66f2a08f606db1220cacf3fc14d939bb73595 Mon Sep 17 00:00:00 2001 From: Yosh Date: Thu, 20 Apr 2023 13:04:43 +0200 Subject: [PATCH 01/16] Rename`wasm32-wasi` to `wasm32-wasi-preview1` --- compiler/rustc_target/src/spec/mod.rs | 2 +- compiler/rustc_target/src/spec/wasm32_wasi.rs | 10 +++++----- config.example.toml | 6 +++--- library/std/Cargo.toml | 2 +- library/std/src/os/wasi/io/raw.rs | 2 +- src/bootstrap/compile.rs | 4 ++-- src/ci/docker/host-x86_64/dist-various-2/Dockerfile | 2 +- .../host-x86_64/dist-various-2/build-wasi-toolchain.sh | 2 +- src/doc/rustc/src/platform-support.md | 2 +- src/tools/build-manifest/src/main.rs | 2 +- src/tools/compiletest/src/header/tests.rs | 8 ++++---- src/tools/miri/ci.sh | 2 +- .../stack-protector/stack-protector-target-support.rs | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 2365dfaf1af80..4867d3dbe3d9d 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1400,7 +1400,7 @@ supported_targets! { ("asmjs-unknown-emscripten", asmjs_unknown_emscripten), ("wasm32-unknown-emscripten", wasm32_unknown_emscripten), ("wasm32-unknown-unknown", wasm32_unknown_unknown), - ("wasm32-wasi", wasm32_wasi), + ("wasm32-wasi-preview1", wasm32_wasi), ("wasm64-unknown-unknown", wasm64_unknown_unknown), ("thumbv6m-none-eabi", thumbv6m_none_eabi), diff --git a/compiler/rustc_target/src/spec/wasm32_wasi.rs b/compiler/rustc_target/src/spec/wasm32_wasi.rs index a0476d542e642..4718dff75dcda 100644 --- a/compiler/rustc_target/src/spec/wasm32_wasi.rs +++ b/compiler/rustc_target/src/spec/wasm32_wasi.rs @@ -1,4 +1,4 @@ -//! The `wasm32-wasi` target is a new and still (as of April 2019) an +//! The `wasm32-wasi-preview1` target is a new and still (as of April 2019) an //! experimental target. The definition in this file is likely to be tweaked //! over time and shouldn't be relied on too much. //! @@ -13,12 +13,12 @@ //! serve two use cases here with this target: //! //! * First, we want Rust usage of the target to be as hassle-free as possible, -//! ideally avoiding the need to configure and install a local wasm32-wasi +//! ideally avoiding the need to configure and install a local wasm32-wasi-preview1 //! toolchain. //! //! * Second, one of the primary use cases of LLVM's new wasm backend and the //! wasm support in LLD is that any compiled language can interoperate with -//! any other. To that the `wasm32-wasi` target is the first with a viable C +//! any other. To that the `wasm32-wasi-preview1` target is the first with a viable C //! standard library and sysroot common definition, so we want Rust and C/C++ //! code to interoperate when compiled to `wasm32-unknown-unknown`. //! @@ -39,7 +39,7 @@ //! necessary. //! //! All in all, by default, no external dependencies are required. You can -//! compile `wasm32-wasi` binaries straight out of the box. You can't, however, +//! compile `wasm32-wasi-preview1` binaries straight out of the box. You can't, however, //! reliably interoperate with C code in this mode (yet). //! //! ## Interop with C required @@ -53,7 +53,7 @@ //! //! 2. If you're using rustc to build a linked artifact then you'll need to //! specify `-C linker` to a `clang` binary that supports -//! `wasm32-wasi` and is configured with the `wasm32-wasi` sysroot. This +//! `wasm32-wasi-preview1` and is configured with the `wasm32-wasi-preview1` sysroot. This //! will cause Rust code to be linked against the libc.a that the specified //! `clang` provides. //! diff --git a/config.example.toml b/config.example.toml index 367f95b156fed..de1f8863c9ac5 100644 --- a/config.example.toml +++ b/config.example.toml @@ -786,9 +786,9 @@ changelog-seen = 2 # The full path to the musl libdir. #musl-libdir = musl-root/lib -# The root location of the `wasm32-wasi` sysroot. Only used for the -# `wasm32-wasi` target. If you are building wasm32-wasi target, make sure to -# create a `[target.wasm32-wasi]` section and move this field there. +# The root location of the `wasm32-wasi-preview1-preview1-preview1-preview1` sysroot. Only used for the +# `wasm32-wasi-preview1-preview1` target. If you are building wasm32-wasi-preview1 target, make sure to +# create a `[target.wasm32-wasi-preview1]` section and move this field there. #wasi-root = (path) # Used in testing for configuring where the QEMU images are located, you diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index eb4815d0cdf6e..39f545642701f 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -47,7 +47,7 @@ fortanix-sgx-abi = { version = "0.5.0", features = ['rustc-dep-of-std'], public [target.'cfg(target_os = "hermit")'.dependencies] hermit-abi = { version = "0.3.0", features = ['rustc-dep-of-std'] } -[target.wasm32-wasi.dependencies] +[target.wasm32-wasi-preview1.dependencies] wasi = { version = "0.11.0", features = ['rustc-dep-of-std'], default-features = false } [features] diff --git a/library/std/src/os/wasi/io/raw.rs b/library/std/src/os/wasi/io/raw.rs index da3b36adad409..2ba930872e117 100644 --- a/library/std/src/os/wasi/io/raw.rs +++ b/library/std/src/os/wasi/io/raw.rs @@ -13,7 +13,7 @@ // As a result, the items in os::fd::raw were given the // rustc_allowed_through_unstable_modules attribute. // No regression tests were added to ensure this property, -// as CI is not configured to test wasm32-wasi. +// as CI is not configured to test wasm32-wasi-preview1. // If this module is stabilized, // you may want to remove those attributes // (assuming no other unstable modules need them). diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index caa7417011ecc..52e726a9f9894 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -306,7 +306,7 @@ fn copy_self_contained_objects( .unwrap_or_else(|| { panic!("Target {:?} does not have a \"wasi-root\" key", target.triple) }) - .join("lib/wasm32-wasi"); + .join("lib/wasm32-wasi-preview1"); for &obj in &["libc.a", "crt1-command.o", "crt1-reactor.o"] { copy_and_stamp( builder, @@ -408,7 +408,7 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car if target.ends_with("-wasi") { if let Some(p) = builder.wasi_root(target) { - let root = format!("native={}/lib/wasm32-wasi", p.to_str().unwrap()); + let root = format!("native={}/lib/wasm32-wasi-preview1", p.to_str().unwrap()); cargo.rustflag("-L").rustflag(&root); } } diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index 0f5df95a0dd4b..edc3797a7d07d 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -135,7 +135,7 @@ ENV TARGETS=$TARGETS,x86_64-unknown-uefi RUN ln -s /usr/include/asm-generic /usr/local/include/asm ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \ - --set target.wasm32-wasi.wasi-root=/wasm32-wasi \ + --set target.wasm32-wasi-preview1.wasi-root=/wasm32-wasi-preview1 \ --musl-root-armv7=/musl-armv7 ENV SCRIPT python3 ../x.py dist --host='' --target $TARGETS diff --git a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh b/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh index b867db6a1b5c8..a536367830586 100755 --- a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh +++ b/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh @@ -15,7 +15,7 @@ make -j$(nproc) \ CC="$bin/clang" \ NM="$bin/llvm-nm" \ AR="$bin/llvm-ar" \ - INSTALL_DIR=/wasm32-wasi \ + INSTALL_DIR=/wasm32-wasi-preview1 \ install cd .. diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index d2a25e612ec7b..9cdae0e1f0a87 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -178,7 +178,7 @@ target | std | notes `thumbv8m.main-none-eabihf` | * | Bare ARMv8-M Mainline, hardfloat `wasm32-unknown-emscripten` | ✓ | WebAssembly via Emscripten `wasm32-unknown-unknown` | ✓ | WebAssembly -`wasm32-wasi` | ✓ | WebAssembly with WASI +`wasm32-wasi-preview1` | ✓ | WebAssembly with WASI `x86_64-apple-ios` | ✓ | 64-bit x86 iOS [`x86_64-fortanix-unknown-sgx`](platform-support/x86_64-fortanix-unknown-sgx.md) | ✓ | [Fortanix ABI] for 64-bit Intel SGX `x86_64-fuchsia` | ✓ | Alias for `x86_64-unknown-fuchsia` diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 8b28c68e04fe9..ca6ed2d2e1eb9 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -136,7 +136,7 @@ static TARGETS: &[&str] = &[ "thumbv8m.main-none-eabihf", "wasm32-unknown-emscripten", "wasm32-unknown-unknown", - "wasm32-wasi", + "wasm32-wasi-preview1", "x86_64-apple-darwin", "x86_64-apple-ios", "x86_64-fortanix-unknown-sgx", diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 362fba11697be..045c3355f2639 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -446,10 +446,10 @@ fn wasm_special() { ("wasm32-unknown-emscripten", "emscripten", true), ("wasm32-unknown-emscripten", "wasm32", true), ("wasm32-unknown-emscripten", "wasm32-bare", false), - ("wasm32-wasi", "emscripten", false), - ("wasm32-wasi", "wasm32", true), - ("wasm32-wasi", "wasm32-bare", false), - ("wasm32-wasi", "wasi", true), + ("wasm32-wasi-preview1", "emscripten", false), + ("wasm32-wasi-preview1", "wasm32", true), + ("wasm32-wasi-preview1", "wasm32-bare", false), + ("wasm32-wasi-preview1", "wasi", true), ("wasm64-unknown-unknown", "emscripten", false), ("wasm64-unknown-unknown", "wasm32", false), ("wasm64-unknown-unknown", "wasm32-bare", false), diff --git a/src/tools/miri/ci.sh b/src/tools/miri/ci.sh index a8aae524e7101..d74ca281c51eb 100755 --- a/src/tools/miri/ci.sh +++ b/src/tools/miri/ci.sh @@ -110,7 +110,7 @@ case $HOST_TARGET in MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple atomic data_race env/var MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic - MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings + MIRI_TEST_TARGET=wasm32-wasi-preview1 run_tests_minimal no_std integer strings MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings MIRI_TEST_TARGET=thumbv7em-none-eabihf MIRI_NO_STD=1 run_tests_minimal no_std # no_std embedded architecture MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std # JSON target file diff --git a/tests/assembly/stack-protector/stack-protector-target-support.rs b/tests/assembly/stack-protector/stack-protector-target-support.rs index d5b48105ef267..ce8055c72d09f 100644 --- a/tests/assembly/stack-protector/stack-protector-target-support.rs +++ b/tests/assembly/stack-protector/stack-protector-target-support.rs @@ -150,7 +150,7 @@ // [r71] needs-llvm-components: webassembly // [r72] compile-flags:--target wasm32-unknown-unknown // [r72] needs-llvm-components: webassembly -// [r73] compile-flags:--target wasm32-wasi +// [r73] compile-flags:--target wasm32-wasi-preview1 // [r73] needs-llvm-components: webassembly // [r74] compile-flags:--target x86_64-apple-ios // [r74] needs-llvm-components: x86 From 6afae812667f627759d9731f203cbaee4c3af5b2 Mon Sep 17 00:00:00 2001 From: Yosh Date: Thu, 20 Apr 2023 14:01:56 +0200 Subject: [PATCH 02/16] move `src/spec/wasm32_wasi{,_preview1}` --- compiler/rustc_target/src/spec/mod.rs | 2 +- .../src/spec/{wasm32_wasi.rs => wasm32_wasi_preview1.rs} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename compiler/rustc_target/src/spec/{wasm32_wasi.rs => wasm32_wasi_preview1.rs} (100%) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 4867d3dbe3d9d..07555d48591ba 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1400,7 +1400,7 @@ supported_targets! { ("asmjs-unknown-emscripten", asmjs_unknown_emscripten), ("wasm32-unknown-emscripten", wasm32_unknown_emscripten), ("wasm32-unknown-unknown", wasm32_unknown_unknown), - ("wasm32-wasi-preview1", wasm32_wasi), + ("wasm32-wasi-preview1", wasm32_wasi_preview1), ("wasm64-unknown-unknown", wasm64_unknown_unknown), ("thumbv6m-none-eabi", thumbv6m_none_eabi), diff --git a/compiler/rustc_target/src/spec/wasm32_wasi.rs b/compiler/rustc_target/src/spec/wasm32_wasi_preview1.rs similarity index 100% rename from compiler/rustc_target/src/spec/wasm32_wasi.rs rename to compiler/rustc_target/src/spec/wasm32_wasi_preview1.rs From 7bb19c418ae4a261e0cc54075749d65e5d2202fc Mon Sep 17 00:00:00 2001 From: Yosh Date: Thu, 20 Apr 2023 15:53:37 +0200 Subject: [PATCH 03/16] undo llvm flags --- .../assembly/stack-protector/stack-protector-target-support.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/assembly/stack-protector/stack-protector-target-support.rs b/tests/assembly/stack-protector/stack-protector-target-support.rs index ce8055c72d09f..d5b48105ef267 100644 --- a/tests/assembly/stack-protector/stack-protector-target-support.rs +++ b/tests/assembly/stack-protector/stack-protector-target-support.rs @@ -150,7 +150,7 @@ // [r71] needs-llvm-components: webassembly // [r72] compile-flags:--target wasm32-unknown-unknown // [r72] needs-llvm-components: webassembly -// [r73] compile-flags:--target wasm32-wasi-preview1 +// [r73] compile-flags:--target wasm32-wasi // [r73] needs-llvm-components: webassembly // [r74] compile-flags:--target x86_64-apple-ios // [r74] needs-llvm-components: x86 From 24347f2b06e440b3d93b2d6732ef80f6f57c99f9 Mon Sep 17 00:00:00 2001 From: Yosh Date: Thu, 20 Apr 2023 16:00:56 +0200 Subject: [PATCH 04/16] update platform support --- src/doc/rustc/src/platform-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 9cdae0e1f0a87..4eae9cdc196a0 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -178,7 +178,7 @@ target | std | notes `thumbv8m.main-none-eabihf` | * | Bare ARMv8-M Mainline, hardfloat `wasm32-unknown-emscripten` | ✓ | WebAssembly via Emscripten `wasm32-unknown-unknown` | ✓ | WebAssembly -`wasm32-wasi-preview1` | ✓ | WebAssembly with WASI +`wasm32-wasi-preview1` | ✓ | WebAssembly with WASI Preview 1 `x86_64-apple-ios` | ✓ | 64-bit x86 iOS [`x86_64-fortanix-unknown-sgx`](platform-support/x86_64-fortanix-unknown-sgx.md) | ✓ | [Fortanix ABI] for 64-bit Intel SGX `x86_64-fuchsia` | ✓ | Alias for `x86_64-unknown-fuchsia` From e2cef50bce99d6d5c4f04a752afc83f8a8de4df1 Mon Sep 17 00:00:00 2001 From: Yosh Date: Thu, 20 Apr 2023 16:21:27 +0200 Subject: [PATCH 05/16] Revert "undo llvm flags" This reverts commit fda83c1416a0472a43fcf8e81c242918c2becccc. --- .../assembly/stack-protector/stack-protector-target-support.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/assembly/stack-protector/stack-protector-target-support.rs b/tests/assembly/stack-protector/stack-protector-target-support.rs index d5b48105ef267..ce8055c72d09f 100644 --- a/tests/assembly/stack-protector/stack-protector-target-support.rs +++ b/tests/assembly/stack-protector/stack-protector-target-support.rs @@ -150,7 +150,7 @@ // [r71] needs-llvm-components: webassembly // [r72] compile-flags:--target wasm32-unknown-unknown // [r72] needs-llvm-components: webassembly -// [r73] compile-flags:--target wasm32-wasi +// [r73] compile-flags:--target wasm32-wasi-preview1 // [r73] needs-llvm-components: webassembly // [r74] compile-flags:--target x86_64-apple-ios // [r74] needs-llvm-components: x86 From 70800653e9534fc3d603a4070e3b23d817c3eba2 Mon Sep 17 00:00:00 2001 From: Yosh Date: Fri, 21 Apr 2023 15:08:19 +0200 Subject: [PATCH 06/16] fix feedback from review --- config.example.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.example.toml b/config.example.toml index de1f8863c9ac5..1cba40bfa82d0 100644 --- a/config.example.toml +++ b/config.example.toml @@ -786,7 +786,7 @@ changelog-seen = 2 # The full path to the musl libdir. #musl-libdir = musl-root/lib -# The root location of the `wasm32-wasi-preview1-preview1-preview1-preview1` sysroot. Only used for the +# The root location of the `wasm32-wasi-preview1` sysroot. Only used for the # `wasm32-wasi-preview1-preview1` target. If you are building wasm32-wasi-preview1 target, make sure to # create a `[target.wasm32-wasi-preview1]` section and move this field there. #wasi-root = (path) From fa04cc1968cae4f422fe4cb2bb287c2677ce1856 Mon Sep 17 00:00:00 2001 From: Yosh Date: Fri, 21 Apr 2023 19:17:08 +0200 Subject: [PATCH 07/16] Fix final nit from review --- config.example.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.example.toml b/config.example.toml index 1cba40bfa82d0..89e202ceb5c65 100644 --- a/config.example.toml +++ b/config.example.toml @@ -787,7 +787,7 @@ changelog-seen = 2 #musl-libdir = musl-root/lib # The root location of the `wasm32-wasi-preview1` sysroot. Only used for the -# `wasm32-wasi-preview1-preview1` target. If you are building wasm32-wasi-preview1 target, make sure to +# `wasm32-wasi-preview1` target. If you are building wasm32-wasi-preview1 target, make sure to # create a `[target.wasm32-wasi-preview1]` section and move this field there. #wasi-root = (path) From 07d3b4b93ea7b9cf545803c0c53612bad7bfac3b Mon Sep 17 00:00:00 2001 From: Yosh Date: Mon, 3 Jul 2023 18:49:06 +0200 Subject: [PATCH 08/16] fix dockerfile for bors --- src/ci/docker/host-x86_64/dist-various-2/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index edc3797a7d07d..2457b190f9776 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -114,6 +114,7 @@ ENV TARGETS=x86_64-unknown-fuchsia ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia ENV TARGETS=$TARGETS,wasm32-unknown-unknown ENV TARGETS=$TARGETS,wasm32-wasi +ENV TARGETS=$TARGETS,wasm32-wasi-preview1 ENV TARGETS=$TARGETS,sparcv9-sun-solaris ENV TARGETS=$TARGETS,x86_64-pc-solaris ENV TARGETS=$TARGETS,x86_64-sun-solaris From fae26c9b56d070350d07f84c97bb03158924dea5 Mon Sep 17 00:00:00 2001 From: Yosh Date: Tue, 4 Jul 2023 17:14:12 +0200 Subject: [PATCH 09/16] Update Dockerfile --- src/ci/docker/host-x86_64/dist-various-2/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index 2457b190f9776..e27fdbf82c235 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -113,7 +113,6 @@ ENV CARGO_TARGET_AARCH64_UNKNOWN_FUCHSIA_RUSTFLAGS \ ENV TARGETS=x86_64-unknown-fuchsia ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia ENV TARGETS=$TARGETS,wasm32-unknown-unknown -ENV TARGETS=$TARGETS,wasm32-wasi ENV TARGETS=$TARGETS,wasm32-wasi-preview1 ENV TARGETS=$TARGETS,sparcv9-sun-solaris ENV TARGETS=$TARGETS,x86_64-pc-solaris From f066a51119103627c4d748c32d6e01c7cf3e6cf2 Mon Sep 17 00:00:00 2001 From: Yosh Date: Wed, 5 Jul 2023 14:03:28 +0200 Subject: [PATCH 10/16] conditional compile test for wasm --- src/bootstrap/test.rs | 7 ++++-- src/tools/compiletest/src/header/tests.rs | 27 ++++++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index a34465ebffb57..f670bdcbb077b 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -706,6 +706,7 @@ impl Step for Miri { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct CompiletestTest { + stage: u32, host: TargetSelection, } @@ -717,13 +718,14 @@ impl Step for CompiletestTest { } fn make_run(run: RunConfig<'_>) { - run.builder.ensure(CompiletestTest { host: run.target }); + run.builder.ensure(CompiletestTest { stage: run.builder.top_stage, host: run.target }); } /// Runs `cargo test` for compiletest. fn run(self, builder: &Builder<'_>) { let host = self.host; - let compiler = builder.compiler(builder.top_stage, host); + let stage = self.stage; + let compiler = builder.compiler(stage, host); // We need `ToolStd` for the locally-built sysroot because // compiletest uses unstable features of the `test` crate. @@ -739,6 +741,7 @@ impl Step for CompiletestTest { &[], ); cargo.allow_features("test"); + cargo.env("RUSTC_STAGE", stage.to_string()); run_cargo_test(cargo, &[], &[], "compiletest", compiler, host, builder); } } diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 045c3355f2639..b5e5fd6b1fbb9 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -435,7 +435,7 @@ fn pointer_width() { #[test] fn wasm_special() { - let ignores = [ + let mut ignores = vec![ ("wasm32-unknown-unknown", "emscripten", true), ("wasm32-unknown-unknown", "wasm32", true), ("wasm32-unknown-unknown", "wasm32-bare", true), @@ -446,15 +446,32 @@ fn wasm_special() { ("wasm32-unknown-emscripten", "emscripten", true), ("wasm32-unknown-emscripten", "wasm32", true), ("wasm32-unknown-emscripten", "wasm32-bare", false), - ("wasm32-wasi-preview1", "emscripten", false), - ("wasm32-wasi-preview1", "wasm32", true), - ("wasm32-wasi-preview1", "wasm32-bare", false), - ("wasm32-wasi-preview1", "wasi", true), ("wasm64-unknown-unknown", "emscripten", false), ("wasm64-unknown-unknown", "wasm32", false), ("wasm64-unknown-unknown", "wasm32-bare", false), ("wasm64-unknown-unknown", "wasm64", true), ]; + + // FIXME(yosh): We're updating the "wasm32-wasi" target name to "wasm32-wasi-preview1". + // The MinGW tests run a beta compiler on stage 0 which means we're having a target mismatch + // for a brief period. When a new beta release is cut, the `if` part of this conditional should be + // removed, and the `else` part should be re-inlined in the original `ignores` list. + if env!("RUSTC_STAGE") == "0" { + ignores.append(&mut vec![ + ("wasm32-wasi", "emscripten", false), + ("wasm32-wasi", "wasm32", true), + ("wasm32-wasi", "wasm32-bare", false), + ("wasm32-wasi", "wasi", true), + ]); + } else { + ignores.append(&mut vec![ + ("wasm32-wasi-preview1", "emscripten", false), + ("wasm32-wasi-preview1", "wasm32", true), + ("wasm32-wasi-preview1", "wasm32-bare", false), + ("wasm32-wasi-preview1", "wasi", true), + ]); + } + for (target, pattern, ignore) in ignores { let mut config = config(); config.target = target.to_string(); From a04c8a0df4b5a7ffce23f421a390bbaab07f91f3 Mon Sep 17 00:00:00 2001 From: Yosh Date: Wed, 5 Jul 2023 15:41:07 +0200 Subject: [PATCH 11/16] update feedback from review Co-Authored-By: jyn --- src/bootstrap/test.rs | 8 +++----- src/tools/compiletest/src/header/tests.rs | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index f670bdcbb077b..95cc6916d785d 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -706,7 +706,6 @@ impl Step for Miri { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct CompiletestTest { - stage: u32, host: TargetSelection, } @@ -718,14 +717,13 @@ impl Step for CompiletestTest { } fn make_run(run: RunConfig<'_>) { - run.builder.ensure(CompiletestTest { stage: run.builder.top_stage, host: run.target }); + run.builder.ensure(CompiletestTest { host: run.target }); } /// Runs `cargo test` for compiletest. fn run(self, builder: &Builder<'_>) { let host = self.host; - let stage = self.stage; - let compiler = builder.compiler(stage, host); + let compiler = builder.compiler(builder.top_stage, host); // We need `ToolStd` for the locally-built sysroot because // compiletest uses unstable features of the `test` crate. @@ -741,7 +739,7 @@ impl Step for CompiletestTest { &[], ); cargo.allow_features("test"); - cargo.env("RUSTC_STAGE", stage.to_string()); + cargo.env("RUSTC_STAGE", builder.top_stage.to_string()); run_cargo_test(cargo, &[], &[], "compiletest", compiler, host, builder); } } diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index b5e5fd6b1fbb9..ceed2510a8a5b 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -456,6 +456,7 @@ fn wasm_special() { // The MinGW tests run a beta compiler on stage 0 which means we're having a target mismatch // for a brief period. When a new beta release is cut, the `if` part of this conditional should be // removed, and the `else` part should be re-inlined in the original `ignores` list. + // cfg(bootstrap) if env!("RUSTC_STAGE") == "0" { ignores.append(&mut vec![ ("wasm32-wasi", "emscripten", false), From e9f5aaa5f73ae439c0572a96a6389f93103e8e9f Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 8 Jul 2023 21:27:13 -0400 Subject: [PATCH 12/16] Re-enable docs on try --- src/tools/opt-dist/src/main.rs | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index 39fa7e1fb2afd..8c5b583c2ad7f 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -17,10 +17,6 @@ mod timer; mod training; mod utils; -fn is_try_build() -> bool { - std::env::var("DIST_TRY_BUILD").unwrap_or_else(|_| "0".to_string()) != "0" -} - fn execute_pipeline( env: &dyn Environment, timer: &mut Timer, @@ -117,14 +113,6 @@ fn execute_pipeline( // The previous PGO optimized rustc build and PGO optimized LLVM builds should be reused. timer.section("Stage 4 (final build)", |stage| dist.run(stage))?; - // After dist has finished, run a subset of the test suite on the optimized artifacts to discover - // possible regressions. - // The tests are not executed for try builds, which can be in various broken states, so we don't - // want to gatekeep them with tests. - if !is_try_build() { - timer.section("Run tests", |_| run_tests(env))?; - } - Ok(()) } @@ -146,23 +134,6 @@ fn main() -> anyhow::Result<()> { log::info!("Contents of `config.toml`:\n{config}"); } - // Skip components that are not needed for try builds to speed them up - if is_try_build() { - log::info!("Skipping building of unimportant components for a try build"); - for target in [ - "rust-docs", - "rustc-docs", - "rust-docs-json", - "rust-analyzer", - "rustc-src", - "clippy", - "miri", - "rustfmt", - ] { - build_args.extend(["--exclude".to_string(), target.to_string()]); - } - } - let mut timer = Timer::new(); let env = create_environment(); From 453bc91a2109b712b07b70fcfd09d87a7c5cac9b Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 8 Jul 2023 21:29:04 -0400 Subject: [PATCH 13/16] Build wasm32-wasi in try builds --- .github/workflows/ci.yml | 3 +++ src/ci/github-actions/ci.yml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0842b69c219c8..e12c115384e6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -565,6 +565,9 @@ jobs: - name: dist-x86_64-linux os: ubuntu-20.04-16core-64gb env: {} + - name: dist-various-2 + os: ubuntu-20.04-8core-32gb + env: {} timeout-minutes: 600 runs-on: "${{ matrix.os }}" steps: diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 55fd6cca85a5d..f84be6f1ea3b7 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -720,6 +720,8 @@ jobs: - &dist-x86_64-linux name: dist-x86_64-linux <<: *job-linux-16c + - name: dist-various-2 + <<: *job-linux-8c master: name: master From 734c8c99b45e8d1c7f6675fe7790c5340c47997a Mon Sep 17 00:00:00 2001 From: Yosh Date: Wed, 12 Jul 2023 17:26:32 +0200 Subject: [PATCH 14/16] fix errors from unused code in opt-dist --- src/tools/opt-dist/src/main.rs | 4 +- src/tools/opt-dist/src/tests.rs | 101 ----------------------------- src/tools/opt-dist/src/utils/io.rs | 12 ---- 3 files changed, 1 insertion(+), 116 deletions(-) delete mode 100644 src/tools/opt-dist/src/tests.rs diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index 8c5b583c2ad7f..a0926aae29ad0 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -3,7 +3,6 @@ use log::LevelFilter; use crate::environment::{create_environment, Environment}; use crate::exec::Bootstrap; -use crate::tests::run_tests; use crate::timer::Timer; use crate::training::{gather_llvm_bolt_profiles, gather_llvm_profiles, gather_rustc_profiles}; use crate::utils::io::reset_directory; @@ -12,7 +11,6 @@ use crate::utils::{clear_llvm_files, format_env_variables, print_free_disk_space mod environment; mod exec; mod metrics; -mod tests; mod timer; mod training; mod utils; @@ -126,7 +124,7 @@ fn main() -> anyhow::Result<()> { .parse_default_env() .init(); - let mut build_args: Vec = std::env::args().skip(1).collect(); + let build_args: Vec = std::env::args().skip(1).collect(); log::info!("Running optimized build pipeline with args `{}`", build_args.join(" ")); log::info!("Environment values\n{}", format_env_variables()); diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs deleted file mode 100644 index 6b35b13e58624..0000000000000 --- a/src/tools/opt-dist/src/tests.rs +++ /dev/null @@ -1,101 +0,0 @@ -use crate::environment::Environment; -use crate::exec::cmd; -use crate::utils::io::{copy_directory, unpack_archive}; -use anyhow::Context; -use camino::Utf8PathBuf; - -/// Run tests on optimized dist artifacts. -pub fn run_tests(env: &dyn Environment) -> anyhow::Result<()> { - // After `dist` is executed, we extract its archived components into a sysroot directory, - // and then use that extracted rustc as a stage0 compiler. - // Then we run a subset of tests using that compiler, to have a basic smoke test which checks - // whether the optimization pipeline hasn't broken something. - let build_dir = env.build_root().join("build"); - let dist_dir = build_dir.join("dist"); - let unpacked_dist_dir = build_dir.join("unpacked-dist"); - std::fs::create_dir_all(&unpacked_dist_dir)?; - - let extract_dist_dir = |name: &str| -> anyhow::Result { - unpack_archive(&dist_dir.join(format!("{name}.tar.xz")), &unpacked_dist_dir)?; - let extracted_path = unpacked_dist_dir.join(name); - assert!(extracted_path.is_dir()); - Ok(extracted_path) - }; - let host_triple = env.host_triple(); - - // Extract rustc, libstd, cargo and src archives to create the optimized sysroot - let rustc_dir = extract_dist_dir(&format!("rustc-nightly-{host_triple}"))?.join("rustc"); - let libstd_dir = extract_dist_dir(&format!("rust-std-nightly-{host_triple}"))? - .join(format!("rust-std-{host_triple}")); - let cargo_dir = extract_dist_dir(&format!("cargo-nightly-{host_triple}"))?.join("cargo"); - let extracted_src_dir = extract_dist_dir("rust-src-nightly")?.join("rust-src"); - - // We need to manually copy libstd to the extracted rustc sysroot - copy_directory( - &libstd_dir.join("lib").join("rustlib").join(&host_triple).join("lib"), - &rustc_dir.join("lib").join("rustlib").join(&host_triple).join("lib"), - )?; - - // Extract sources - they aren't in the `rustc-nightly-{host}` tarball, so we need to manually copy libstd - // sources to the extracted sysroot. We need sources available so that `-Zsimulate-remapped-rust-src-base` - // works correctly. - copy_directory( - &extracted_src_dir.join("lib").join("rustlib").join("src"), - &rustc_dir.join("lib").join("rustlib").join("src"), - )?; - - let rustc_path = rustc_dir.join("bin").join(format!("rustc{}", env.executable_extension())); - assert!(rustc_path.is_file()); - let cargo_path = cargo_dir.join("bin").join(format!("cargo{}", env.executable_extension())); - assert!(cargo_path.is_file()); - - // Specify path to a LLVM config so that LLVM is not rebuilt. - // It doesn't really matter which LLVM config we choose, because no sysroot will be compiled. - let llvm_config = env - .build_artifacts() - .join("llvm") - .join("bin") - .join(format!("llvm-config{}", env.executable_extension())); - assert!(llvm_config.is_file()); - - let config_content = format!( - r#"profile = "user" -changelog-seen = 2 - -[build] -rustc = "{rustc}" -cargo = "{cargo}" - -[target.{host_triple}] -llvm-config = "{llvm_config}" -"#, - rustc = rustc_path.to_string().replace('\\', "/"), - cargo = cargo_path.to_string().replace('\\', "/"), - llvm_config = llvm_config.to_string().replace('\\', "/") - ); - log::info!("Using following `config.toml` for running tests:\n{config_content}"); - - // Simulate a stage 0 compiler with the extracted optimized dist artifacts. - std::fs::write("config.toml", config_content)?; - - let x_py = env.checkout_path().join("x.py"); - let mut args = vec![ - env.python_binary(), - x_py.as_str(), - "test", - "--stage", - "0", - "tests/assembly", - "tests/codegen", - "tests/codegen-units", - "tests/incremental", - "tests/mir-opt", - "tests/pretty", - "tests/run-pass-valgrind", - "tests/ui", - ]; - for test_path in env.skipped_tests() { - args.extend(["--exclude", test_path]); - } - cmd(&args).env("COMPILETEST_FORCE_STAGE0", "1").run().context("Cannot execute tests") -} diff --git a/src/tools/opt-dist/src/utils/io.rs b/src/tools/opt-dist/src/utils/io.rs index 43546e5fcfa67..47d9f35bae2ea 100644 --- a/src/tools/opt-dist/src/utils/io.rs +++ b/src/tools/opt-dist/src/utils/io.rs @@ -1,7 +1,6 @@ use anyhow::Context; use camino::Utf8Path; use fs_extra::dir::CopyOptions; -use std::fs::File; /// Delete and re-create the directory. pub fn reset_directory(path: &Utf8Path) -> anyhow::Result<()> { @@ -35,14 +34,3 @@ pub fn delete_directory(path: &Utf8Path) -> anyhow::Result<()> { .context(format!("Cannot remove directory {path}"))?; Ok(()) } - -pub fn unpack_archive(path: &Utf8Path, dest_dir: &Utf8Path) -> anyhow::Result<()> { - log::info!("Unpacking directory `{path}` into `{dest_dir}`"); - - assert!(path.as_str().ends_with(".tar.xz")); - let file = File::open(path.as_std_path())?; - let file = xz::read::XzDecoder::new(file); - let mut archive = tar::Archive::new(file); - archive.unpack(dest_dir.as_std_path())?; - Ok(()) -} From eb08ddd6a89acb6c870045b608426a3b446e9423 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 18 Jul 2023 15:43:54 +0100 Subject: [PATCH 15/16] Fix wasi-libc target --- src/bootstrap/compile.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 520e84208d032..b8d31c706803a 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -287,13 +287,13 @@ fn copy_self_contained_objects( let libunwind_path = copy_llvm_libunwind(builder, target, &libdir_self_contained); target_deps.push((libunwind_path, DependencyType::TargetSelfContained)); } - } else if target.ends_with("-wasi") { + } else if target.contains("-wasi") { let srcdir = builder .wasi_root(target) .unwrap_or_else(|| { panic!("Target {:?} does not have a \"wasi-root\" key", target.triple) }) - .join("lib/wasm32-wasi-preview1"); + .join("lib/wasm32-wasi"); for &obj in &["libc.a", "crt1-command.o", "crt1-reactor.o"] { copy_and_stamp( builder, @@ -393,9 +393,9 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car } } - if target.ends_with("-wasi") { + if target.contains("-wasi") { if let Some(p) = builder.wasi_root(target) { - let root = format!("native={}/lib/wasm32-wasi-preview1", p.to_str().unwrap()); + let root = format!("native={}/lib/wasm32-wasi", p.to_str().unwrap()); cargo.rustflag("-L").rustflag(&root); } } From 6cd03a30ff8f8392e612d85be304c6a93fe5e178 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 18 Jul 2023 15:45:22 +0100 Subject: [PATCH 16/16] tidy --- src/tools/opt-dist/src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index 541a61b31aca3..86979be351bf7 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -128,7 +128,6 @@ fn main() -> anyhow::Result<()> { .parse_default_env() .init(); - let mut build_args: Vec = std::env::args().skip(1).collect(); log::info!("Running optimized build pipeline with args `{}`", build_args.join(" ")); log::info!("Environment values\n{}", format_env_variables());