Skip to content

Commit 0e6601f

Browse files
committed
Add wasm_syscall feature to build system
1 parent 36695a3 commit 0e6601f

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

config.toml.example

+5
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@
312312
# bootstrap)
313313
#codegen-backends = ["llvm"]
314314

315+
# Flag indicating whether `libstd` calls an imported function to hande basic IO
316+
# when targetting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown`
317+
# target, as without this option the test output will not be captured.
318+
#wasm-syscall = false
319+
315320
# =============================================================================
316321
# Options for specific targets
317322
#

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ pub struct Config {
107107
pub debug_jemalloc: bool,
108108
pub use_jemalloc: bool,
109109
pub backtrace: bool, // support for RUST_BACKTRACE
110+
pub wasm_syscall: bool,
110111

111112
// misc
112113
pub low_priority: bool,
@@ -282,6 +283,7 @@ struct Rust {
282283
test_miri: Option<bool>,
283284
save_toolstates: Option<String>,
284285
codegen_backends: Option<Vec<String>>,
286+
wasm_syscall: Option<bool>,
285287
}
286288

287289
/// TOML representation of how each build target is configured.
@@ -463,6 +465,7 @@ impl Config {
463465
set(&mut config.rust_dist_src, rust.dist_src);
464466
set(&mut config.quiet_tests, rust.quiet_tests);
465467
set(&mut config.test_miri, rust.test_miri);
468+
set(&mut config.wasm_syscall, rust.wasm_syscall);
466469
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false);
467470
config.rustc_default_linker = rust.default_linker.clone();
468471
config.musl_root = rust.musl_root.clone().map(PathBuf::from);

src/bootstrap/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ impl Build {
423423
if self.config.profiler {
424424
features.push_str(" profiler");
425425
}
426+
if self.config.wasm_syscall {
427+
features.push_str(" wasm_syscall");
428+
}
426429
features
427430
}
428431

src/bootstrap/test.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,14 @@ impl Step for Crate {
12861286
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
12871287
build.config.nodejs.as_ref().expect("nodejs not configured"));
12881288
} else if target.starts_with("wasm32") {
1289+
// Warn about running tests without the `wasm_syscall` feature enabled.
1290+
// The javascript shim implements the syscall interface so that test
1291+
// output can be correctly reported.
1292+
if !build.config.wasm_syscall {
1293+
println!("Libstd was built without `wasm_syscall` feature enabled: \
1294+
test output may not be visible.");
1295+
}
1296+
12891297
// On the wasm32-unknown-unknown target we're using LTO which is
12901298
// incompatible with `-C prefer-dynamic`, so disable that here
12911299
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");

0 commit comments

Comments
 (0)