From 7d9690a3bcb4ce57165341e5f5d0a2161283076d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 6 Mar 2024 12:41:08 -0800 Subject: Remove old support for emscripten/wasm32-u-u This commit removes the `wasm32-shim.js` file, for example, and deletes old support for Emscripten which hasn't been exercised in some time. --- src/bootstrap/src/core/build_steps/test.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/bootstrap') diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 248d831b6e3..47b0637538b 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1657,8 +1657,8 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the // ensure that `libproc_macro` is available on the host. builder.ensure(compile::Std::new(compiler, compiler.host)); - // As well as the target, except for plain wasm32, which can't build it - if suite != "mir-opt" && !target.contains("wasm") && !target.contains("emscripten") { + // As well as the target + if suite != "mir-opt" { builder.ensure(TestHelpers { target }); } @@ -2511,16 +2511,7 @@ fn prepare_cargo_test( dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target))); cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); - if target.contains("emscripten") { - cargo.env( - format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), - builder.config.nodejs.as_ref().expect("nodejs not configured"), - ); - } else if target.starts_with("wasm32") { - let node = builder.config.nodejs.as_ref().expect("nodejs not configured"); - let runner = format!("{} {}/src/etc/wasm32-shim.js", node.display(), builder.src.display()); - cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), &runner); - } else if builder.remote_tested(target) { + if builder.remote_tested(target) { cargo.env( format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()), -- cgit 1.4.1-3-g733a5 From 341215c51daf9db2281e989dd559ab0fcc6c73f1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 6 Mar 2024 12:41:46 -0800 Subject: Configure a default `runner` for WASI targets If one is not explicitly configured look in the system environment to try and find one. For now just probing for `wasmtime` is implemented. --- src/bootstrap/src/lib.rs | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src/bootstrap') diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 938b95cc60e..39bdece8127 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -1360,9 +1360,36 @@ impl Build { /// An example of this would be a WebAssembly runtime when testing the wasm /// targets. fn runner(&self, target: TargetSelection) -> Option { - let target = self.config.target_config.get(&target)?; - let runner = target.runner.as_ref()?; - Some(runner.to_owned()) + let configured_runner = + self.config.target_config.get(&target).and_then(|t| t.runner.as_ref()).map(|p| &**p); + if let Some(runner) = configured_runner { + return Some(runner.to_owned()); + } + + if target.starts_with("wasm") && target.contains("wasi") { + self.default_wasi_runner() + } else { + None + } + } + + /// When a `runner` configuration is not provided and a WASI-looking target + /// is being tested this is consulted to prove the environment to see if + /// there's a runtime already lying around that seems reasonable to use. + fn default_wasi_runner(&self) -> Option { + let mut finder = crate::core::sanity::Finder::new(); + + // Look for Wasmtime, and for its default options be sure to disable + // its caching system since we're executing quite a lot of tests and + // ideally shouldn't pollute the cache too much. + if let Some(path) = finder.maybe_have("wasmtime") { + if let Ok(mut path) = path.into_os_string().into_string() { + path.push_str(" run -C cache=n --dir ."); + return Some(path); + } + } + + None } /// Returns the root of the "rootfs" image that this target will be using, -- cgit 1.4.1-3-g733a5