Skip to content

Commit 31bbd9e

Browse files
committed
Add wasm_syscall feature to build system
1 parent 445358a commit 31bbd9e

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
@@ -305,6 +305,11 @@
305305
# result (broken, compiling, testing) into this JSON file.
306306
#save-toolstates = "/path/to/toolstates.json"
307307

308+
# Flag indicating whether `libstd` calls an imported function to hande basic IO
309+
# when targetting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown`
310+
# target, as without this option the test output will not be captured.
311+
#wasm-syscall = false
312+
308313
# =============================================================================
309314
# Options for specific targets
310315
#

src/bootstrap/check.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,14 @@ impl Step for Crate {
12401240
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
12411241
build.config.nodejs.as_ref().expect("nodejs not configured"));
12421242
} else if target.starts_with("wasm32") {
1243+
// Warn about running tests without the `wasm_syscall` feature enabled.
1244+
// The javascript shim implements the syscall interface so that test
1245+
// output can be correctly reported.
1246+
if !build.config.wasm_syscall {
1247+
println!("Libstd was built without `wasm_syscall` feature enabled: \
1248+
test output may not be visible.");
1249+
}
1250+
12431251
// On the wasm32-unknown-unknown target we're using LTO which is
12441252
// incompatible with `-C prefer-dynamic`, so disable that here
12451253
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub struct Config {
106106
pub debug_jemalloc: bool,
107107
pub use_jemalloc: bool,
108108
pub backtrace: bool, // support for RUST_BACKTRACE
109+
pub wasm_syscall: bool,
109110

110111
// misc
111112
pub low_priority: bool,
@@ -281,6 +282,7 @@ struct Rust {
281282
quiet_tests: Option<bool>,
282283
test_miri: Option<bool>,
283284
save_toolstates: Option<String>,
285+
wasm_syscall: Option<bool>,
284286
}
285287

286288
/// TOML representation of how each build target is configured.
@@ -461,6 +463,7 @@ impl Config {
461463
set(&mut config.rust_dist_src, rust.dist_src);
462464
set(&mut config.quiet_tests, rust.quiet_tests);
463465
set(&mut config.test_miri, rust.test_miri);
466+
set(&mut config.wasm_syscall, rust.wasm_syscall);
464467
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false);
465468
config.rustc_default_linker = rust.default_linker.clone();
466469
config.musl_root = rust.musl_root.clone().map(PathBuf::from);

src/bootstrap/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ impl Build {
420420
if self.config.profiler {
421421
features.push_str(" profiler");
422422
}
423+
if self.config.wasm_syscall {
424+
features.push_str(" wasm_syscall");
425+
}
423426
features
424427
}
425428

0 commit comments

Comments
 (0)