From 0e6601f630743939443c7a9f5c0164cae7f46ade Mon Sep 17 00:00:00 2001 From: Diggory Blake Date: Thu, 11 Jan 2018 17:51:49 +0000 Subject: [PATCH] Add wasm_syscall feature to build system --- config.toml.example | 5 +++++ src/bootstrap/config.rs | 3 +++ src/bootstrap/lib.rs | 3 +++ src/bootstrap/test.rs | 8 ++++++++ 4 files changed, 19 insertions(+) diff --git a/config.toml.example b/config.toml.example index 1d60d8c9494..9ca0f563d0a 100644 --- a/config.toml.example +++ b/config.toml.example @@ -312,6 +312,11 @@ # bootstrap) #codegen-backends = ["llvm"] +# Flag indicating whether `libstd` calls an imported function to hande basic IO +# when targetting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown` +# target, as without this option the test output will not be captured. +#wasm-syscall = false + # ============================================================================= # Options for specific targets # diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index dbeb27cbfb7..0da04bebac5 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -107,6 +107,7 @@ pub struct Config { pub debug_jemalloc: bool, pub use_jemalloc: bool, pub backtrace: bool, // support for RUST_BACKTRACE + pub wasm_syscall: bool, // misc pub low_priority: bool, @@ -282,6 +283,7 @@ struct Rust { test_miri: Option, save_toolstates: Option, codegen_backends: Option>, + wasm_syscall: Option, } /// TOML representation of how each build target is configured. @@ -463,6 +465,7 @@ impl Config { set(&mut config.rust_dist_src, rust.dist_src); set(&mut config.quiet_tests, rust.quiet_tests); set(&mut config.test_miri, rust.test_miri); + set(&mut config.wasm_syscall, rust.wasm_syscall); config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false); config.rustc_default_linker = rust.default_linker.clone(); config.musl_root = rust.musl_root.clone().map(PathBuf::from); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index aae0a4f056f..f2a7ce30c8a 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -423,6 +423,9 @@ impl Build { if self.config.profiler { features.push_str(" profiler"); } + if self.config.wasm_syscall { + features.push_str(" wasm_syscall"); + } features } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index a316b0f7ef9..5fdc6e00920 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1286,6 +1286,14 @@ impl Step for Crate { cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), build.config.nodejs.as_ref().expect("nodejs not configured")); } else if target.starts_with("wasm32") { + // Warn about running tests without the `wasm_syscall` feature enabled. + // The javascript shim implements the syscall interface so that test + // output can be correctly reported. + if !build.config.wasm_syscall { + println!("Libstd was built without `wasm_syscall` feature enabled: \ + test output may not be visible."); + } + // On the wasm32-unknown-unknown target we're using LTO which is // incompatible with `-C prefer-dynamic`, so disable that here cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");