From 939bd4733977a0c88f9c3b131d486b5ffc6007b1 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Sat, 6 Aug 2016 12:52:17 +0200 Subject: [PATCH 01/27] Configure LLVM to use js backend Initialize the asmjs backend for LLVM --- src/bootstrap/native.rs | 2 +- src/librustc_llvm/lib.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index df6408e5fe1c8..63fc59e43286e 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -65,7 +65,7 @@ pub fn llvm(build: &Build, target: &str) { .out_dir(&dst) .profile(if build.config.llvm_optimize {"Release"} else {"Debug"}) .define("LLVM_ENABLE_ASSERTIONS", assertions) - .define("LLVM_TARGETS_TO_BUILD", "X86;ARM;AArch64;Mips;PowerPC;SystemZ") + .define("LLVM_TARGETS_TO_BUILD", "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend") .define("LLVM_INCLUDE_EXAMPLES", "OFF") .define("LLVM_INCLUDE_TESTS", "OFF") .define("LLVM_INCLUDE_DOCS", "OFF") diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index eb45d3d25c5c0..3946b44ead578 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -434,6 +434,10 @@ pub fn initialize_available_targets() { LLVMInitializeSystemZTargetMC, LLVMInitializeSystemZAsmPrinter, LLVMInitializeSystemZAsmParser); + init_target!(llvm_component = "jsbackend", + LLVMInitializeJSBackendTargetInfo, + LLVMInitializeJSBackendTarget, + LLVMInitializeJSBackendTargetMC); } pub fn last_error() -> Option { From cb3f5799f4c1e5786eb3976dfa33f527a0415168 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Sat, 6 Aug 2016 21:13:14 +0200 Subject: [PATCH 02/27] Make the jsbackend an optional component --- mk/main.mk | 2 +- src/librustc_llvm/build.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mk/main.mk b/mk/main.mk index cc843add50d1b..e68a8f3005561 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -300,7 +300,7 @@ endif # LLVM macros ###################################################################### -LLVM_OPTIONAL_COMPONENTS=x86 arm aarch64 mips powerpc pnacl systemz +LLVM_OPTIONAL_COMPONENTS=x86 arm aarch64 mips powerpc pnacl systemz jsbackend LLVM_REQUIRED_COMPONENTS=ipo bitreader bitwriter linker asmparser mcjit \ interpreter instrumentation diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 3f551476e2b46..c805fd7c7b641 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -66,7 +66,7 @@ fn main() { let host = env::var("HOST").expect("HOST was not set"); let is_crossed = target != host; - let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz"]; + let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz", "jsbackend"]; // FIXME: surely we don't need all these components, right? Stuff like mcjit // or interpreter the compiler itself never uses. From 86fd661bcbf84f8f387b824d05f4803fc00ee34f Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Sun, 7 Aug 2016 00:14:33 +0200 Subject: [PATCH 03/27] Patch panic_unwind to compile, but this is surely broken --- src/libpanic_unwind/gcc.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libpanic_unwind/gcc.rs b/src/libpanic_unwind/gcc.rs index 33b24fbaa2659..e4730a7320464 100644 --- a/src/libpanic_unwind/gcc.rs +++ b/src/libpanic_unwind/gcc.rs @@ -133,6 +133,12 @@ const UNWIND_DATA_REG: (i32, i32) = (3, 4); // R3, R4 / X3, X4 #[cfg(target_arch = "s390x")] const UNWIND_DATA_REG: (i32, i32) = (6, 7); // R6, R7 +// FIXME: This is completely and utterly wrong. +// I copy'n'pasted the x86 thing just to see if asmjs-unknown-emscripten compiles at all +// (the happy path) +#[cfg(target_arch = "asmjs")] +const UNWIND_DATA_REG: (i32, i32) = (0, 2); // EAX, EDX + // The following code is based on GCC's C and C++ personality routines. For reference, see: // https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc // https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c From 1231ce33db8ea6f782df1fb016198e07d6efa3d7 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 30 Aug 2016 22:56:26 +0000 Subject: [PATCH 04/27] Support emscripten in rustbuild --- src/bootstrap/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 3d1cf47cb7e90..80726951ad87a 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -975,7 +975,7 @@ impl Build { // than an entry here. let mut base = Vec::new(); - if target != self.config.build && !target.contains("msvc") { + if target != self.config.build && !target.contains("msvc") && !target.contains("emscripten") { base.push(format!("-Clinker={}", self.cc(target).display())); } return base From c62d8b12bf68ea09a9a588b58da89e7925de21b1 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 31 Aug 2016 20:47:11 +0000 Subject: [PATCH 05/27] Update gcc-rs for emscripten --- src/bootstrap/Cargo.lock | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index 36b94e4ebea32..babbb6a16bae0 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -5,16 +5,16 @@ dependencies = [ "build_helper 0.1.0", "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.31 (git+https://github.com/alexcrichton/gcc-rs)", + "gcc 0.3.35 (git+https://github.com/alexcrichton/gcc-rs)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "md5 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -34,7 +34,7 @@ name = "cmake" version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -42,17 +42,17 @@ name = "filetime" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gcc" -version = "0.3.31" -source = "git+https://github.com/alexcrichton/gcc-rs#b8e2400883f1a2749b323354dad372cdd1c838c7" +version = "0.3.35" +source = "git+https://github.com/alexcrichton/gcc-rs#8ff5360b6e0dc4f3c9d3f71036f1ff403c68469d" [[package]] name = "gcc" -version = "0.3.31" +version = "0.3.35" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -65,13 +65,13 @@ name = "kernel32-sys" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libc" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -84,15 +84,15 @@ name = "memchr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num_cpus" -version = "0.2.11" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -123,7 +123,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -136,7 +136,7 @@ dependencies = [ [[package]] name = "toml" -version = "0.1.28" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -149,7 +149,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -161,20 +161,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum aho-corasick 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2b3fb52b09c1710b961acb35390d514be82e4ac96a9969a8e38565a29b878dc9" "checksum cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "dfcf5bcece56ef953b8ea042509e9dcbdfe97820b7e20d86beb53df30ed94978" "checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922" -"checksum gcc 0.3.31 (git+https://github.com/alexcrichton/gcc-rs)" = "" -"checksum gcc 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "cfe877476e53690ebb0ce7325d0bf43e198d9500291b54b3c65e518de5039b07" +"checksum gcc 0.3.35 (git+https://github.com/alexcrichton/gcc-rs)" = "" +"checksum gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "91ecd03771effb0c968fd6950b37e89476a578aaf1c70297d8e92b6516ec3312" "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "55f3730be7e803cf350d32061958171731c2395831fbd67a61083782808183e0" +"checksum libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "23e3757828fa702a20072c37ff47938e9dd331b92fac6e223d26d4b7a55f7ee2" "checksum md5 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5539a8dee9b4ae308c9c406a379838b435a8f2c84cf9fedc6d5a576be9888db" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" -"checksum num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "51fedae97a05f7353612fe017ab705a37e6db8f4d67c5c6fe739a9e70d6eed09" +"checksum num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "cee7e88156f3f9e19bdd598f8d6c9db7bf4078f99f8381f43a55b09648d1a6e3" "checksum regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)" = "56b7ee9f764ecf412c6e2fff779bca4b22980517ae335a21aeaf4e32625a5df2" "checksum regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31040aad7470ad9d8c46302dcffba337bb4289ca5da2e3cd6e37b64109a85199" "checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "55dd963dbaeadc08aa7266bf7f91c3154a7805e32bb94b820b769d2ef3b4744d" -"checksum toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "fcd27a04ca509aff336ba5eb2abc58d456f52c4ff64d9724d88acb85ead560b6" +"checksum toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "0590d72182e50e879c4da3b11c6488dae18fccb1ae0c7a3eda18e16795844796" "checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" -"checksum winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "4dfaaa8fbdaa618fa6914b59b2769d690dd7521920a18d84b42d254678dd5fd4" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" From ad9184c9bfd47e1be43726c7f68fa8a4f879cb94 Mon Sep 17 00:00:00 2001 From: Ross Schulman Date: Mon, 5 Sep 2016 19:56:48 -0400 Subject: [PATCH 06/27] Adapting bootstrap to run tests on asmjs. --- src/bootstrap/check.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 2b9d717cbd48d..8a844f710313f 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -323,6 +323,9 @@ pub fn krate(build: &Build, if target.contains("android") { build.run(cargo.arg("--no-run")); krate_android(build, compiler, target, mode); + } else if target.contains("asmjs") { + build.run(cargo.arg("--no-run")); + krate_asmjs(build, compiler, target, mode); } else { cargo.args(&build.flags.args); build.run(&mut cargo); @@ -371,6 +374,23 @@ fn krate_android(build: &Build, } } +fn krate_asmjs(build: &Build, + compiler: &Compiler, + target: &str, + mode: Mode) { + let mut tests = Vec::new(); + let out_dir = build.cargo_out(compiler, mode, target); + find_tests(&out_dir, target, &mut tests); + find_tests(&out_dir.join("deps"), target, &mut tests); + + for test in tests { + let test_file_name = test.to_string_lossy().into_owned(); + let output = output(Command::new("node").arg(&test_file_name)); + println!("{}", output); + } + } + + fn find_tests(dir: &Path, target: &str, dst: &mut Vec) { @@ -381,7 +401,8 @@ fn find_tests(dir: &Path, } let filename = e.file_name().into_string().unwrap(); if (target.contains("windows") && filename.ends_with(".exe")) || - (!target.contains("windows") && !filename.contains(".")) { + (!target.contains("windows") && !filename.contains(".")) || + (target.contains("asmjs") && filename.contains(".js")){ dst.push(e.path()); } } From b2dfeac6907ab63a3261cfa66c04db239d138433 Mon Sep 17 00:00:00 2001 From: Ross Schulman Date: Mon, 5 Sep 2016 20:00:09 -0400 Subject: [PATCH 07/27] Adding ignore-emscripten to failing tests. --- src/test/compile-fail/allocator-dylib-is-system.rs | 2 ++ src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs | 2 ++ src/test/run-fail/panic-task-name-none.rs | 1 + src/test/run-fail/panic-task-name-owned.rs | 1 + src/test/run-fail/run-unexported-tests.rs | 1 + src/test/run-fail/task-spawn-barefn.rs | 1 + src/test/run-fail/test-panic.rs | 1 + src/test/run-fail/test-should-fail-bad-message.rs | 1 + src/test/run-fail/test-tasks-invalid-value.rs | 1 + src/test/run-pass/allocator-override.rs | 1 + src/test/run-pass/extern-pass-empty.rs | 1 + src/test/run-pass/issue-16597.rs | 1 + src/test/run-pass/issue-20823.rs | 1 + src/test/run-pass/issue-29663.rs | 1 + src/test/run-pass/packed-struct-layout.rs | 1 + src/test/run-pass/packed-struct-vec.rs | 1 + src/test/run-pass/packed-tuple-struct-layout.rs | 1 + .../run-pass/panic-runtime/abort-link-to-unwinding-crates.rs | 1 + src/test/run-pass/panic-runtime/abort.rs | 1 + src/test/run-pass/panic-runtime/lto-abort.rs | 1 + src/test/run-pass/panic-runtime/lto-unwind.rs | 1 + src/test/run-pass/process-status-inherits-stdin.rs | 1 + src/test/run-pass/simd-intrinsic-generic-cast.rs | 1 + .../test-fn-signature-verification-for-explicit-return-type.rs | 1 + src/test/run-pass/test-should-fail-good-message.rs | 1 + 25 files changed, 27 insertions(+) diff --git a/src/test/compile-fail/allocator-dylib-is-system.rs b/src/test/compile-fail/allocator-dylib-is-system.rs index db7f304227f01..0097de75f94fc 100644 --- a/src/test/compile-fail/allocator-dylib-is-system.rs +++ b/src/test/compile-fail/allocator-dylib-is-system.rs @@ -18,6 +18,8 @@ // system allocator. Do this by linking in jemalloc and making sure that we get // an error. +// ignore-emscripten TODO: What "other allocator" should we use for emcc? + #![feature(alloc_jemalloc)] extern crate allocator_dylib; diff --git a/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs b/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs index 46ad226d25564..a6b49ec86cc78 100644 --- a/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs +++ b/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs @@ -16,6 +16,8 @@ // Ensure that rust dynamic libraries use jemalloc as their allocator, verifying // by linking in the system allocator here and ensuring that we get a complaint. +// ignore-emscripten TODO: What "other allocator" is correct for emscripten? + #![feature(alloc_system)] extern crate allocator_dylib2; diff --git a/src/test/run-fail/panic-task-name-none.rs b/src/test/run-fail/panic-task-name-none.rs index ab50503830534..36e2a4b86aa39 100644 --- a/src/test/run-fail/panic-task-name-none.rs +++ b/src/test/run-fail/panic-task-name-none.rs @@ -9,6 +9,7 @@ // except according to those terms. // error-pattern:thread '' panicked at 'test' +// ignore-emscripten Needs threads use std::thread; diff --git a/src/test/run-fail/panic-task-name-owned.rs b/src/test/run-fail/panic-task-name-owned.rs index 2d2371f5ce77c..4da40c3158b84 100644 --- a/src/test/run-fail/panic-task-name-owned.rs +++ b/src/test/run-fail/panic-task-name-owned.rs @@ -9,6 +9,7 @@ // except according to those terms. // error-pattern:thread 'owned name' panicked at 'test' +// ignore-emscripten Needs threads. use std::thread::Builder; diff --git a/src/test/run-fail/run-unexported-tests.rs b/src/test/run-fail/run-unexported-tests.rs index 8158333ade818..bc7b3540d1e99 100644 --- a/src/test/run-fail/run-unexported-tests.rs +++ b/src/test/run-fail/run-unexported-tests.rs @@ -12,6 +12,7 @@ // compile-flags:--test // check-stdout // ignore-pretty: does not work well with `--test` +// ignore-emscripten Needs threads. mod m { pub fn exported() {} diff --git a/src/test/run-fail/task-spawn-barefn.rs b/src/test/run-fail/task-spawn-barefn.rs index ede055acd61ff..108430848b9b2 100644 --- a/src/test/run-fail/task-spawn-barefn.rs +++ b/src/test/run-fail/task-spawn-barefn.rs @@ -9,6 +9,7 @@ // except according to those terms. // error-pattern:Ensure that the child thread runs by panicking +// ignore-emscripten Needs threads. use std::thread; diff --git a/src/test/run-fail/test-panic.rs b/src/test/run-fail/test-panic.rs index fa360570253b0..070095534a4b9 100644 --- a/src/test/run-fail/test-panic.rs +++ b/src/test/run-fail/test-panic.rs @@ -12,6 +12,7 @@ // error-pattern:thread 'test_foo' panicked at // compile-flags: --test // ignore-pretty: does not work well with `--test` +// ignore-emscripten #[test] fn test_foo() { diff --git a/src/test/run-fail/test-should-fail-bad-message.rs b/src/test/run-fail/test-should-fail-bad-message.rs index e18c5d9631a70..bd25df3dabd1d 100644 --- a/src/test/run-fail/test-should-fail-bad-message.rs +++ b/src/test/run-fail/test-should-fail-bad-message.rs @@ -12,6 +12,7 @@ // error-pattern:thread 'test_foo' panicked at // compile-flags: --test // ignore-pretty: does not work well with `--test` +// ignore-emscripten #[test] #[should_panic(expected = "foobar")] diff --git a/src/test/run-fail/test-tasks-invalid-value.rs b/src/test/run-fail/test-tasks-invalid-value.rs index 94ed641c79c93..b5c222764d243 100644 --- a/src/test/run-fail/test-tasks-invalid-value.rs +++ b/src/test/run-fail/test-tasks-invalid-value.rs @@ -15,6 +15,7 @@ // compile-flags: --test // exec-env:RUST_TEST_THREADS=foo // ignore-pretty: does not work well with `--test` +// ignore-emscripten #[test] fn do_nothing() {} diff --git a/src/test/run-pass/allocator-override.rs b/src/test/run-pass/allocator-override.rs index d7a8e79bfbee8..ca2dbdf2b3de3 100644 --- a/src/test/run-pass/allocator-override.rs +++ b/src/test/run-pass/allocator-override.rs @@ -10,6 +10,7 @@ // no-prefer-dynamic // aux-build:allocator-dummy.rs +// ignore-emscripten #![feature(test)] diff --git a/src/test/run-pass/extern-pass-empty.rs b/src/test/run-pass/extern-pass-empty.rs index 21948d2e5ad23..801a3c40ab47d 100644 --- a/src/test/run-pass/extern-pass-empty.rs +++ b/src/test/run-pass/extern-pass-empty.rs @@ -12,6 +12,7 @@ // pretty-expanded FIXME #23616 // ignore-msvc +// ignore-emscripten struct TwoU8s { one: u8, diff --git a/src/test/run-pass/issue-16597.rs b/src/test/run-pass/issue-16597.rs index 7f0a341f14715..77c4554522158 100644 --- a/src/test/run-pass/issue-16597.rs +++ b/src/test/run-pass/issue-16597.rs @@ -10,6 +10,7 @@ // compile-flags:--test // ignore-pretty turns out the pretty-printer doesn't handle gensym'd things... +// ignore-emscripten mod tests { use super::*; diff --git a/src/test/run-pass/issue-20823.rs b/src/test/run-pass/issue-20823.rs index c297998b6493a..aa5d0151446de 100644 --- a/src/test/run-pass/issue-20823.rs +++ b/src/test/run-pass/issue-20823.rs @@ -10,6 +10,7 @@ // compile-flags: --test // no-pretty-expanded +// ignore-emscripten #![deny(unstable)] diff --git a/src/test/run-pass/issue-29663.rs b/src/test/run-pass/issue-29663.rs index 9a77be049feeb..88958744fe916 100644 --- a/src/test/run-pass/issue-29663.rs +++ b/src/test/run-pass/issue-29663.rs @@ -9,6 +9,7 @@ // except according to those terms. // write_volatile causes an LLVM assert with composite types +// ignore-emscripten write_volatile doesn't work on arrays of structs? #![feature(volatile)] use std::ptr::{read_volatile, write_volatile}; diff --git a/src/test/run-pass/packed-struct-layout.rs b/src/test/run-pass/packed-struct-layout.rs index 92308c9fc3e4e..d1e05e5a0184c 100644 --- a/src/test/run-pass/packed-struct-layout.rs +++ b/src/test/run-pass/packed-struct-layout.rs @@ -7,6 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten Not sure what's happening here. use std::mem; diff --git a/src/test/run-pass/packed-struct-vec.rs b/src/test/run-pass/packed-struct-vec.rs index 4b32b881be738..9873f23137b4c 100644 --- a/src/test/run-pass/packed-struct-vec.rs +++ b/src/test/run-pass/packed-struct-vec.rs @@ -7,6 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten Right side of comparison is screwed up. No idea how. use std::mem; diff --git a/src/test/run-pass/packed-tuple-struct-layout.rs b/src/test/run-pass/packed-tuple-struct-layout.rs index 411c1807a16b7..ee4eb86ed0de3 100644 --- a/src/test/run-pass/packed-tuple-struct-layout.rs +++ b/src/test/run-pass/packed-tuple-struct-layout.rs @@ -7,6 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten use std::mem; diff --git a/src/test/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs b/src/test/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs index 71c1a61062d10..1c273fcba02da 100644 --- a/src/test/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs +++ b/src/test/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs @@ -11,6 +11,7 @@ // compile-flags:-C panic=abort // aux-build:exit-success-if-unwind.rs // no-prefer-dynamic +// ignore-emscripten Function not implemented extern crate exit_success_if_unwind; diff --git a/src/test/run-pass/panic-runtime/abort.rs b/src/test/run-pass/panic-runtime/abort.rs index 2fc9d6cfd04a1..be38f6ea3643a 100644 --- a/src/test/run-pass/panic-runtime/abort.rs +++ b/src/test/run-pass/panic-runtime/abort.rs @@ -10,6 +10,7 @@ // compile-flags:-C panic=abort // no-prefer-dynamic +// ignore-emscripten Function not implemented. use std::process::Command; use std::env; diff --git a/src/test/run-pass/panic-runtime/lto-abort.rs b/src/test/run-pass/panic-runtime/lto-abort.rs index 09e33b88189fe..e4cd4e809a4c6 100644 --- a/src/test/run-pass/panic-runtime/lto-abort.rs +++ b/src/test/run-pass/panic-runtime/lto-abort.rs @@ -10,6 +10,7 @@ // compile-flags:-C lto -C panic=abort // no-prefer-dynamic +// ignore-emscripten Function not implemented. use std::process::Command; use std::env; diff --git a/src/test/run-pass/panic-runtime/lto-unwind.rs b/src/test/run-pass/panic-runtime/lto-unwind.rs index 10e633b3775b3..768b88fd09e0b 100644 --- a/src/test/run-pass/panic-runtime/lto-unwind.rs +++ b/src/test/run-pass/panic-runtime/lto-unwind.rs @@ -10,6 +10,7 @@ // compile-flags:-C lto -C panic=unwind // no-prefer-dynamic +// ignore-emscripten Function not implemented. use std::process::Command; use std::env; diff --git a/src/test/run-pass/process-status-inherits-stdin.rs b/src/test/run-pass/process-status-inherits-stdin.rs index 2ad47c4f116ae..ff389bec899ef 100644 --- a/src/test/run-pass/process-status-inherits-stdin.rs +++ b/src/test/run-pass/process-status-inherits-stdin.rs @@ -7,6 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten Function not implemented. use std::env; use std::io; diff --git a/src/test/run-pass/simd-intrinsic-generic-cast.rs b/src/test/run-pass/simd-intrinsic-generic-cast.rs index 2efd9333999b2..d32fa01c7b945 100644 --- a/src/test/run-pass/simd-intrinsic-generic-cast.rs +++ b/src/test/run-pass/simd-intrinsic-generic-cast.rs @@ -7,6 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten linking with emcc failed #![feature(repr_simd, platform_intrinsics, concat_idents, test)] #![allow(non_camel_case_types)] diff --git a/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs b/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs index d58b5d3a00fec..b5f303b8760fb 100644 --- a/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs +++ b/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs @@ -7,6 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten needs threads? #![feature(test)] diff --git a/src/test/run-pass/test-should-fail-good-message.rs b/src/test/run-pass/test-should-fail-good-message.rs index 28698499303a9..95378df41c680 100644 --- a/src/test/run-pass/test-should-fail-good-message.rs +++ b/src/test/run-pass/test-should-fail-good-message.rs @@ -10,6 +10,7 @@ // compile-flags: --test // ignore-pretty: does not work well with `--test` +// ignore-emscripten needs threads? #[test] #[should_panic(expected = "foo")] From b8b50f0eda08e19e7c96377681f82ac17c76775d Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 6 Sep 2016 00:41:50 +0000 Subject: [PATCH 08/27] Preliminary wasm32 support --- mk/cfg/wasm32-unknown-emscripten.mk | 24 +++++++++++ src/bootstrap/check.rs | 12 +++--- src/liballoc_system/lib.rs | 3 +- src/libpanic_unwind/gcc.rs | 4 ++ src/librustc_back/target/mod.rs | 3 +- .../target/wasm32_unknown_emscripten.rs | 41 +++++++++++++++++++ src/librustc_trans/abi.rs | 1 + src/libstd/env.rs | 18 +++++++- src/libstd/os/linux/raw.rs | 3 +- src/libtest/lib.rs | 4 +- src/libunwind/libunwind.rs | 2 +- src/tools/compiletest/src/runtest.rs | 7 ++-- src/tools/compiletest/src/util.rs | 3 +- 13 files changed, 107 insertions(+), 18 deletions(-) create mode 100644 mk/cfg/wasm32-unknown-emscripten.mk create mode 100644 src/librustc_back/target/wasm32_unknown_emscripten.rs diff --git a/mk/cfg/wasm32-unknown-emscripten.mk b/mk/cfg/wasm32-unknown-emscripten.mk new file mode 100644 index 0000000000000..997bdfbf03ab1 --- /dev/null +++ b/mk/cfg/wasm32-unknown-emscripten.mk @@ -0,0 +1,24 @@ +# wasm32-unknown-emscripten configuration +CC_wasm32-unknown-emscripten=emcc +CXX_wasm32-unknown-emscripten=em++ +CPP_wasm32-unknown-emscripten=$(CPP) +AR_wasm32-unknown-emscripten=emar +CFG_LIB_NAME_wasm32-unknown-emscripten=lib$(1).so +CFG_STATIC_LIB_NAME_wasm32-unknown-emscripten=lib$(1).a +CFG_LIB_GLOB_wasm32-unknown-emscripten=lib$(1)-*.so +CFG_LIB_DSYM_GLOB_wasm32-unknown-emscripten=lib$(1)-*.dylib.dSYM +CFG_JEMALLOC_CFLAGS_wasm32-unknown-emscripten := -m32 $(CFLAGS) +CFG_GCCISH_CFLAGS_wasm32-unknown-emscripten := -g -fPIC -m32 -s BINARYEN=1 $(CFLAGS) +CFG_GCCISH_CXXFLAGS_wasm32-unknown-emscripten := -fno-rtti -s BINARYEN=1 $(CXXFLAGS) +CFG_GCCISH_LINK_FLAGS_wasm32-unknown-emscripten := -shared -fPIC -ldl -pthread -lrt -g -m32 -s BINARYEN=1 +CFG_GCCISH_DEF_FLAG_wasm32-unknown-emscripten := -Wl,--export-dynamic,--dynamic-list= +CFG_LLC_FLAGS_wasm32-unknown-emscripten := +CFG_INSTALL_NAME_wasm32-unknown-emscripten = +CFG_EXE_SUFFIX_wasm32-unknown-emscripten = +CFG_WINDOWSY_wasm32-unknown-emscripten := +CFG_UNIXY_wasm32-unknown-emscripten := 1 +CFG_LDPATH_wasm32-unknown-emscripten := +CFG_RUN_wasm32-unknown-emscripten=$(2) +CFG_RUN_TARG_wasm32-unknown-emscripten=$(call CFG_RUN_wasm32-unknown-emscripten,,$(2)) +CFG_GNU_TRIPLE_wasm32-unknown-emscripten := wasm32-unknown-emscripten +CFG_DISABLE_JEMALLOC_wasm32-unknown-emscripten := 1 diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 8a844f710313f..c839e40535329 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -323,9 +323,9 @@ pub fn krate(build: &Build, if target.contains("android") { build.run(cargo.arg("--no-run")); krate_android(build, compiler, target, mode); - } else if target.contains("asmjs") { + } else if target.contains("emscripten") { build.run(cargo.arg("--no-run")); - krate_asmjs(build, compiler, target, mode); + krate_emscripten(build, compiler, target, mode); } else { cargo.args(&build.flags.args); build.run(&mut cargo); @@ -374,10 +374,10 @@ fn krate_android(build: &Build, } } -fn krate_asmjs(build: &Build, - compiler: &Compiler, - target: &str, - mode: Mode) { +fn krate_emscripten(build: &Build, + compiler: &Compiler, + target: &str, + mode: Mode) { let mut tests = Vec::new(); let out_dir = build.cargo_out(compiler, mode, target); find_tests(&out_dir, target, &mut tests); diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index 01407d1acd2ec..dacafe771edc2 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -29,7 +29,8 @@ target_arch = "mips", target_arch = "powerpc", target_arch = "powerpc64", - target_arch = "asmjs")))] + target_arch = "asmjs", + target_arch = "wasm32")))] const MIN_ALIGN: usize = 8; #[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64", diff --git a/src/libpanic_unwind/gcc.rs b/src/libpanic_unwind/gcc.rs index e4730a7320464..5bfa77cba7acf 100644 --- a/src/libpanic_unwind/gcc.rs +++ b/src/libpanic_unwind/gcc.rs @@ -139,6 +139,10 @@ const UNWIND_DATA_REG: (i32, i32) = (6, 7); // R6, R7 #[cfg(target_arch = "asmjs")] const UNWIND_DATA_REG: (i32, i32) = (0, 2); // EAX, EDX +// FIXME: Ditto the above +#[cfg(target_arch = "wasm32")] +const UNWIND_DATA_REG: (i32, i32) = (0, 2); // EAX, EDX + // The following code is based on GCC's C and C++ personality routines. For reference, see: // https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc // https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 3eddd911749e5..6e2f7b1bf5313 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -190,7 +190,8 @@ supported_targets! { ("i586-pc-windows-msvc", i586_pc_windows_msvc), ("le32-unknown-nacl", le32_unknown_nacl), - ("asmjs-unknown-emscripten", asmjs_unknown_emscripten) + ("asmjs-unknown-emscripten", asmjs_unknown_emscripten), + ("wasm32-unknown-emscripten", wasm32_unknown_emscripten) } /// Everything `rustc` knows about how to compile for a specific target. diff --git a/src/librustc_back/target/wasm32_unknown_emscripten.rs b/src/librustc_back/target/wasm32_unknown_emscripten.rs new file mode 100644 index 0000000000000..412fb868086c5 --- /dev/null +++ b/src/librustc_back/target/wasm32_unknown_emscripten.rs @@ -0,0 +1,41 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::{Target, TargetOptions}; + +pub fn target() -> Result { + let opts = TargetOptions { + linker: "emcc".to_string(), + ar: "emar".to_string(), + + dynamic_linking: false, + executables: true, + // Today emcc emits two files - a .js file to bootstrap and + // possibly interpret the wasm, and a .wasm file + exe_suffix: ".js".to_string(), + linker_is_gnu: true, + allow_asm: false, + obj_is_bitcode: true, + max_atomic_width: 32, + post_link_args: vec!["-s".to_string(), "BINARYEN=1".to_string()], + .. Default::default() + }; + Ok(Target { + llvm_target: "asmjs-unknown-emscripten".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + target_os: "emscripten".to_string(), + target_env: "".to_string(), + target_vendor: "unknown".to_string(), + data_layout: "e-p:32:32-i64:64-v128:32:128-n32-S128".to_string(), + arch: "wasm32".to_string(), + options: opts, + }) +} diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs index b82c5629f9da1..0a5b013c79ac2 100644 --- a/src/librustc_trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -519,6 +519,7 @@ impl FnType { "powerpc64" => cabi_powerpc64::compute_abi_info(ccx, self), "s390x" => cabi_s390x::compute_abi_info(ccx, self), "asmjs" => cabi_asmjs::compute_abi_info(ccx, self), + "wasm32" => cabi_asmjs::compute_abi_info(ccx, self), a => ccx.sess().fatal(&format!("unrecognized arch \"{}\" in target specification", a)) } diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 5171fbdf03e80..5da6e5a8b80dc 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -892,7 +892,18 @@ mod os { pub const EXE_EXTENSION: &'static str = "pexe"; } -#[cfg(target_os = "emscripten")] +#[cfg(all(target_os = "emscripten", target_arch = "asmjs"))] +mod os { + pub const FAMILY: &'static str = "unix"; + pub const OS: &'static str = "emscripten"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".so"; + pub const DLL_EXTENSION: &'static str = "so"; + pub const EXE_SUFFIX: &'static str = ".js"; + pub const EXE_EXTENSION: &'static str = "js"; +} + +#[cfg(all(target_os = "emscripten", target_arch = "wasm32"))] mod os { pub const FAMILY: &'static str = "unix"; pub const OS: &'static str = "emscripten"; @@ -969,6 +980,11 @@ mod arch { pub const ARCH: &'static str = "asmjs"; } +#[cfg(target_arch = "wasm32")] +mod arch { + pub const ARCH: &'static str = "wasm32"; +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/libstd/os/linux/raw.rs b/src/libstd/os/linux/raw.rs index 1c19e58818d74..e6a95bc831ffb 100644 --- a/src/libstd/os/linux/raw.rs +++ b/src/libstd/os/linux/raw.rs @@ -34,7 +34,8 @@ pub use self::arch::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t}; target_arch = "le32", target_arch = "powerpc", target_arch = "arm", - target_arch = "asmjs"))] + target_arch = "asmjs", + target_arch = "wasm32"))] mod arch { use os::raw::{c_long, c_short, c_uint}; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index dcfd3f754c720..12dd8e615e8d0 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1291,7 +1291,7 @@ impl MetricMap { /// /// This function is a no-op, and does not even read from `dummy`. #[cfg(not(any(all(target_os = "nacl", target_arch = "le32"), - target_arch = "asmjs")))] + target_arch = "asmjs", target_arch = "wasm32")))] pub fn black_box(dummy: T) -> T { // we need to "use" the argument in some way LLVM can't // introspect. @@ -1299,7 +1299,7 @@ pub fn black_box(dummy: T) -> T { dummy } #[cfg(any(all(target_os = "nacl", target_arch = "le32"), - target_arch = "asmjs"))] + target_arch = "asmjs", target_arch = "wasm32"))] #[inline(never)] pub fn black_box(dummy: T) -> T { dummy diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index 30de859f1501a..5d69a95da820c 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -65,7 +65,7 @@ pub const unwinder_private_data_size: usize = 2; #[cfg(target_arch = "s390x")] pub const unwinder_private_data_size: usize = 2; -#[cfg(target_arch = "asmjs")] +#[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))] pub const unwinder_private_data_size: usize = 20; #[repr(C)] diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 8fdb882164af8..5885e464b4f14 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1168,7 +1168,6 @@ actual:\n\ "arm-linux-androideabi" | "armv7-linux-androideabi" | "aarch64-linux-android" => { self._arm_exec_compiled_test(env) } - _=> { let aux_dir = self.aux_output_dir_name(); self.compose_and_run(self.make_run_args(), @@ -1421,7 +1420,7 @@ actual:\n\ fn make_exe_name(&self) -> PathBuf { let mut f = self.output_base_name(); // FIXME: This is using the host architecture exe suffix, not target! - if self.config.target == "asmjs-unknown-emscripten" { + if self.config.target.contains("emscripten") { let mut fname = f.file_name().unwrap().to_os_string(); fname.push(".js"); f.set_file_name(&fname); @@ -1439,8 +1438,8 @@ actual:\n\ let mut args = self.split_maybe_args(&self.config.runtool); // If this is emscripten, then run tests under nodejs - if self.config.target == "asmjs-unknown-emscripten" { - args.push("nodejs".to_owned()); + if self.config.target.contains("emscripten") { + args.push("node".to_owned()); } let exe_file = self.make_exe_name(); diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 428bbcfe5761d..cad71c59f0a4a 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -43,7 +43,8 @@ const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[("aarch64", "aarch ("sparc", "sparc"), ("x86_64", "x86_64"), ("xcore", "xcore"), - ("asmjs", "asmjs")]; + ("asmjs", "asmjs"), + ("wasm32", "wasm32")]; pub fn get_os(triple: &str) -> &'static str { for &(triple_os, os) in OS_TABLE { From f41b363ea315509040a20e59acae97955dc8e601 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 6 Sep 2016 20:16:56 +0000 Subject: [PATCH 09/27] Update libtest for single-threaded emscripten support --- src/libtest/lib.rs | 69 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 12dd8e615e8d0..49a7f6589d2b6 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1182,26 +1182,63 @@ pub fn run_test(opts: &TestOpts, } } - thread::spawn(move || { - let data = Arc::new(Mutex::new(Vec::new())); - let data2 = data.clone(); - let cfg = thread::Builder::new().name(match desc.name { - DynTestName(ref name) => name.clone(), - StaticTestName(name) => name.to_owned(), + // If the platform is single-threaded we're just going to run + // the test synchronously, regardless of the concurrency + // level. + let supports_threads = !cfg!(target_os = "emscripten"); + + // Buffer for capturing standard I/O + let data = Arc::new(Mutex::new(Vec::new())); + let data2 = data.clone(); + + if supports_threads { + thread::spawn(move || { + let cfg = thread::Builder::new().name(match desc.name { + DynTestName(ref name) => name.clone(), + StaticTestName(name) => name.to_owned(), + }); + + let result_guard = cfg.spawn(move || { + if !nocapture { + io::set_print(box Sink(data2.clone())); + io::set_panic(box Sink(data2)); + } + testfn() + }) + .unwrap(); + let test_result = calc_result(&desc, result_guard.join()); + let stdout = data.lock().unwrap().to_vec(); + monitor_ch.send((desc.clone(), test_result, stdout)).unwrap(); }); + } else { + let oldio = if !nocapture { + Some(( + io::set_print(box Sink(data2.clone())), + io::set_panic(box Sink(data2)) + )) + } else { + None + }; + + use std::panic::{catch_unwind, AssertUnwindSafe}; - let result_guard = cfg.spawn(move || { - if !nocapture { - io::set_print(box Sink(data2.clone())); - io::set_panic(box Sink(data2)); - } - testfn() - }) - .unwrap(); - let test_result = calc_result(&desc, result_guard.join()); + let result = catch_unwind(AssertUnwindSafe(|| { + testfn() + })); + + if let Some((printio, panicio)) = oldio { + if let Some(printio) = printio { + io::set_print(printio); + } + if let Some(panicio) = panicio { + io::set_panic(panicio); + } + }; + + let test_result = calc_result(&desc, result); let stdout = data.lock().unwrap().to_vec(); monitor_ch.send((desc.clone(), test_result, stdout)).unwrap(); - }); + } } match testfn { From fcd3279f36214e6915a3b14074f154da3c7cd88a Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 6 Sep 2016 20:36:14 +0000 Subject: [PATCH 10/27] Improve bootstrap crate testing for emscripten --- src/bootstrap/check.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index c839e40535329..0bd9355098f26 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -385,8 +385,19 @@ fn krate_emscripten(build: &Build, for test in tests { let test_file_name = test.to_string_lossy().into_owned(); - let output = output(Command::new("node").arg(&test_file_name)); - println!("{}", output); + println!("running {}", test_file_name); + let output = Command::new("node") + .arg(&test_file_name) + .stderr(::std::process::Stdio::inherit()) + .output(); + let output = match output { + Ok(status) => status, + Err(e) => panic!(format!("failed to execute command: {}", e)), + }; + println!("{}", String::from_utf8(output.stdout).unwrap()); + if !output.status.success() { + panic!("some tests failed"); + } } } @@ -402,7 +413,7 @@ fn find_tests(dir: &Path, let filename = e.file_name().into_string().unwrap(); if (target.contains("windows") && filename.ends_with(".exe")) || (!target.contains("windows") && !filename.contains(".")) || - (target.contains("asmjs") && filename.contains(".js")){ + (target.contains("emscripten") && filename.contains(".js")){ dst.push(e.path()); } } From 9c4a01ee9eea6fc50252f08afbf98a91270e9d5e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 7 Sep 2016 05:34:15 +0000 Subject: [PATCH 11/27] Ignore lots and lots of std tests on emscripten --- src/liballoc/arc.rs | 1 + src/libcollections/linked_list.rs | 1 + src/libcollectionstest/slice.rs | 1 + src/libstd/env.rs | 3 ++ src/libstd/fs.rs | 49 ++++++++++++++++++++++++++++ src/libstd/io/buffered.rs | 1 + src/libstd/io/mod.rs | 2 ++ src/libstd/io/stdio.rs | 1 + src/libstd/net/addr.rs | 3 ++ src/libstd/net/tcp.rs | 30 +++++++++++++++++ src/libstd/net/udp.rs | 13 ++++++++ src/libstd/process.rs | 17 ++++++++++ src/libstd/rand/mod.rs | 1 + src/libstd/sync/barrier.rs | 1 + src/libstd/sync/condvar.rs | 4 +++ src/libstd/sync/mpsc/mod.rs | 52 ++++++++++++++++++++++++++++++ src/libstd/sync/mpsc/mpsc_queue.rs | 1 + src/libstd/sync/mpsc/select.rs | 11 +++++++ src/libstd/sync/mpsc/spsc_queue.rs | 1 + src/libstd/sync/mutex.rs | 8 +++++ src/libstd/sync/once.rs | 2 ++ src/libstd/sync/rwlock.rs | 9 ++++++ src/libstd/sys/common/io.rs | 1 + src/libstd/sys/common/remutex.rs | 3 ++ src/libstd/sys/unix/ext/net.rs | 13 ++++++++ src/libstd/sys/unix/process.rs | 1 + src/libstd/thread/local.rs | 6 ++++ src/libstd/thread/mod.rs | 19 +++++++++++ 28 files changed, 255 insertions(+) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index e3c92fc1aa830..29e18781ce2a5 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -1000,6 +1000,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn manually_share_arc() { let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let arc_v = Arc::new(v); diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs index 690c4f4af3589..67f3708a62b91 100644 --- a/src/libcollections/linked_list.rs +++ b/src/libcollections/linked_list.rs @@ -1294,6 +1294,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_send() { let n = list_from(&[1, 2, 3]); thread::spawn(move || { diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs index 5b341ab62d097..9580714075ad7 100644 --- a/src/libcollectionstest/slice.rs +++ b/src/libcollectionstest/slice.rs @@ -1116,6 +1116,7 @@ fn test_box_slice_clone() { } #[test] +#[cfg_attr(target_os = "emscripten", ignore)] fn test_box_slice_clone_panics() { use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 5da6e5a8b80dc..76a2f93c162e7 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -1033,6 +1033,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_var_big() { let mut s = "".to_string(); let mut i = 0; @@ -1046,6 +1047,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_self_exe_path() { let path = current_exe(); assert!(path.is_ok()); @@ -1056,6 +1058,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_env_set_get_huge() { let n = make_rand_name(); let s = repeat("x").take(10000).collect::(); diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 576198564dbd4..08d71c1d9f8c9 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1745,6 +1745,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_smoke_test() { let message = "it's alright. have a good time"; let tmpdir = tmpdir(); @@ -1766,6 +1767,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn invalid_path_raises() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_that_does_not_exist.txt"); @@ -1780,6 +1782,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_iounlinking_invalid_path_should_raise_condition() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_another_file_that_does_not_exist.txt"); @@ -1795,6 +1798,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_non_positional_read() { let message: &str = "ten-four"; let mut read_mem = [0; 8]; @@ -1821,6 +1825,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_and_tell_smoke_test() { let message = "ten-four"; let mut read_mem = [0; 4]; @@ -1848,6 +1853,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_and_write() { let initial_msg = "food-is-yummy"; let overwrite_msg = "-the-bar!!"; @@ -1872,6 +1878,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_shakedown() { // 01234567890123 let initial_msg = "qwer-asdf-zxcv"; @@ -1904,6 +1911,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_stat_is_correct_on_is_file() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_file.txt"); @@ -1925,6 +1933,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_stat_is_correct_on_is_dir() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_dir"); @@ -1937,6 +1946,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_fileinfo_false_when_checking_is_file_on_a_directory() { let tmpdir = tmpdir(); let dir = &tmpdir.join("fileinfo_false_on_dir"); @@ -1946,6 +1956,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_fileinfo_check_exists_before_and_after_file_creation() { let tmpdir = tmpdir(); let file = &tmpdir.join("fileinfo_check_exists_b_and_a.txt"); @@ -1956,6 +1967,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_directoryinfo_check_exists_before_and_after_mkdir() { let tmpdir = tmpdir(); let dir = &tmpdir.join("before_and_after_dir"); @@ -1968,6 +1980,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_directoryinfo_readdir() { let tmpdir = tmpdir(); let dir = &tmpdir.join("di_readdir"); @@ -1997,6 +2010,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_create_new_already_exists_error() { let tmpdir = tmpdir(); let file = &tmpdir.join("file_create_new_error_exists"); @@ -2006,6 +2020,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn mkdir_path_already_exists_error() { let tmpdir = tmpdir(); let dir = &tmpdir.join("mkdir_error_twice"); @@ -2015,6 +2030,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir() { let tmpdir = tmpdir(); let dir = tmpdir.join("d1/d2"); @@ -2023,6 +2039,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir_failure() { let tmpdir = tmpdir(); let dir = tmpdir.join("d1"); @@ -2037,11 +2054,13 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir_slash() { check!(fs::create_dir_all(&Path::new("/"))); } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_rmdir() { let tmpdir = tmpdir(); let d1 = tmpdir.join("d1"); @@ -2061,6 +2080,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_rmdir_of_symlink() { // test we do not recursively delete a symlink but only dirs. let tmpdir = tmpdir(); @@ -2094,6 +2114,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn unicode_path_is_dir() { assert!(Path::new(".").is_dir()); assert!(!Path::new("test/stdtest/fs.rs").is_dir()); @@ -2113,6 +2134,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn unicode_path_exists() { assert!(Path::new(".").exists()); assert!(!Path::new("test/nonexistent-bogus-path").exists()); @@ -2126,6 +2148,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_does_not_exist() { let from = Path::new("test/nonexistent-bogus-path"); let to = Path::new("test/other-bogus-path"); @@ -2140,6 +2163,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_src_does_not_exist() { let tmpdir = tmpdir(); let from = Path::new("test/nonexistent-bogus-path"); @@ -2153,6 +2177,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_ok() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2169,6 +2194,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_dst_dir() { let tmpdir = tmpdir(); let out = tmpdir.join("out"); @@ -2180,6 +2206,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_dst_exists() { let tmpdir = tmpdir(); let input = tmpdir.join("in"); @@ -2195,6 +2222,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_src_dir() { let tmpdir = tmpdir(); let out = tmpdir.join("out"); @@ -2206,6 +2234,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_preserves_perm_bits() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2234,6 +2263,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn symlinks_work() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2252,6 +2282,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn symlink_noexist() { // Symlinks can point to things that don't exist let tmpdir = tmpdir(); @@ -2265,6 +2296,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn read_link() { if cfg!(windows) { // directory symlink @@ -2285,6 +2317,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn readlink_not_symlink() { let tmpdir = tmpdir(); match fs::read_link(tmpdir.path()) { @@ -2294,6 +2327,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn links_work() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2322,6 +2356,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn chmod_works() { let tmpdir = tmpdir(); let file = tmpdir.join("in.txt"); @@ -2345,6 +2380,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn sync_doesnt_kill_anything() { let tmpdir = tmpdir(); let path = tmpdir.join("in.txt"); @@ -2358,6 +2394,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn truncate_works() { let tmpdir = tmpdir(); let path = tmpdir.join("in.txt"); @@ -2392,6 +2429,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn open_flavors() { use fs::OpenOptions as OO; fn c(t: &T) -> T { t.clone() } @@ -2511,6 +2549,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn binary_file() { let mut bytes = [0; 1024]; StdRng::new().unwrap().fill_bytes(&mut bytes); @@ -2524,6 +2563,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn file_try_clone() { let tmpdir = tmpdir(); @@ -2546,6 +2586,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] #[cfg(not(windows))] fn unlink_readonly() { let tmpdir = tmpdir(); @@ -2558,6 +2599,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn mkdir_trailing_slash() { let tmpdir = tmpdir(); let path = tmpdir.join("file"); @@ -2565,6 +2607,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn canonicalize_works_simple() { let tmpdir = tmpdir(); let tmpdir = fs::canonicalize(tmpdir.path()).unwrap(); @@ -2574,6 +2617,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn realpath_works() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2599,6 +2643,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn realpath_works_tricky() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2628,6 +2673,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn dir_entry_methods() { let tmpdir = tmpdir(); @@ -2662,12 +2708,14 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn read_dir_not_found() { let res = fs::read_dir("/path/that/does/not/exist"); assert_eq!(res.err().unwrap().kind(), ErrorKind::NotFound); } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn create_dir_all_with_junctions() { let tmpdir = tmpdir(); let target = tmpdir.join("target"); @@ -2695,6 +2743,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn metadata_access_times() { let tmpdir = tmpdir(); diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 4ff8c6ac128bd..21a0cc1fb3b13 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -1107,6 +1107,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn panic_in_write_doesnt_flush_in_drop() { static WRITES: AtomicUsize = AtomicUsize::new(0); diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 0de02cbf19c9f..2ba2e8de71b54 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1761,6 +1761,7 @@ mod tests { use super::repeat; #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn read_until() { let mut buf = Cursor::new(&b"12"[..]); let mut v = Vec::new(); @@ -1971,6 +1972,7 @@ mod tests { } #[bench] + #[cfg_attr(target_os = "emscripten", ignore)] fn bench_read_to_end(b: &mut test::Bencher) { b.iter(|| { let mut lr = repeat(1).take(10000000); diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 9a782e95f6e5f..89cb9909956ee 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -668,6 +668,7 @@ mod tests { use super::*; #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn panic_doesnt_poison() { thread::spawn(|| { let _a = stdin(); diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index d0b59b42c1798..930f2c721a7b7 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -533,6 +533,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str_u16() { let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 24352); assert_eq!(Ok(vec![a]), tsa(("77.88.21.11", 24352))); @@ -545,6 +546,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str() { let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 24352); assert_eq!(Ok(vec![a]), tsa("77.88.21.11:24352")); @@ -559,6 +561,7 @@ mod tests { // FIXME: figure out why this fails on openbsd and bitrig and fix it #[test] #[cfg(not(any(windows, target_os = "openbsd", target_os = "bitrig")))] + #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str_bad() { assert!(tsa("1200::AB00:1234::2552:7777:1313:34300").is_err()); } diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 3c5f07c3e33a6..d34fce2be43ca 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -454,6 +454,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn bind_error() { match TcpListener::bind("1.1.1.1:9999") { Ok(..) => panic!(), @@ -463,6 +464,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn connect_error() { match TcpStream::connect("0.0.0.0:1") { Ok(..) => panic!(), @@ -475,6 +477,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn listen_localhost() { let socket_addr = next_test_ip4(); let listener = t!(TcpListener::bind(&socket_addr)); @@ -492,6 +495,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn connect_loopback() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -513,6 +517,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_test() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -533,6 +538,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn read_eof() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -552,6 +558,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn write_close() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -578,6 +585,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn multiple_connect_serial() { each_ip(&mut |addr| { let max = 10; @@ -600,6 +608,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn multiple_connect_interleaved_greedy_schedule() { const MAX: usize = 10; each_ip(&mut |addr| { @@ -635,6 +644,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn multiple_connect_interleaved_lazy_schedule() { const MAX: usize = 10; each_ip(&mut |addr| { @@ -668,6 +678,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn socket_and_peer_name() { each_ip(&mut |addr| { let listener = t!(TcpListener::bind(&addr)); @@ -683,6 +694,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn partial_read() { each_ip(&mut |addr| { let (tx, rx) = channel(); @@ -704,6 +716,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn double_bind() { each_ip(&mut |addr| { let _listener = t!(TcpListener::bind(&addr)); @@ -720,6 +733,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn fast_rebind() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -735,6 +749,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn tcp_clone_smoke() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -766,6 +781,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn tcp_clone_two_read() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -800,6 +816,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn tcp_clone_two_write() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -827,6 +844,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn shutdown_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -847,6 +865,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn close_readwrite_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -885,6 +904,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn close_read_wakes_up() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -912,6 +932,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn clone_while_reading() { each_ip(&mut |addr| { let accept = t!(TcpListener::bind(&addr)); @@ -952,6 +973,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn clone_accept_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -970,6 +992,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn clone_accept_concurrent() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -998,6 +1021,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn debug() { let name = if cfg!(windows) {"socket"} else {"fd"}; let socket_addr = next_test_ip4(); @@ -1024,6 +1048,7 @@ mod tests { // no longer has rounding errors. #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)] #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn timeouts() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -1050,6 +1075,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_timeout() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -1066,6 +1092,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_with_timeout() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -1088,6 +1115,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn nodelay() { let addr = next_test_ip4(); let _listener = t!(TcpListener::bind(&addr)); @@ -1102,6 +1130,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn ttl() { let ttl = 100; @@ -1118,6 +1147,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn set_nonblocking() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 781f026c12c77..7315b6aaeb6ed 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -378,6 +378,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn bind_error() { match UdpSocket::bind("1.1.1.1:9999") { Ok(..) => panic!(), @@ -388,6 +389,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn socket_smoke_test_ip4() { each_ip(&mut |server_ip, client_ip| { let (tx1, rx1) = channel(); @@ -412,6 +414,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn socket_name_ip4() { each_ip(&mut |addr, _| { let server = t!(UdpSocket::bind(&addr)); @@ -420,6 +423,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn udp_clone_smoke() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -449,6 +453,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn udp_clone_two_read() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -481,6 +486,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn udp_clone_two_write() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -519,6 +525,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn debug() { let name = if cfg!(windows) {"socket"} else {"fd"}; let socket_addr = next_test_ip4(); @@ -534,6 +541,7 @@ mod tests { // no longer has rounding errors. #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)] #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn timeouts() { let addr = next_test_ip4(); @@ -558,6 +566,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_timeout() { let addr = next_test_ip4(); @@ -573,6 +582,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_with_timeout() { let addr = next_test_ip4(); @@ -592,6 +602,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn connect_send_recv() { let addr = next_test_ip4(); @@ -606,6 +617,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn ttl() { let ttl = 100; @@ -618,6 +630,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn set_nonblocking() { let addr = next_test_ip4(); diff --git a/src/libstd/process.rs b/src/libstd/process.rs index f0c4443070074..233a4d3639c3b 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -819,6 +819,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke() { let p = Command::new("true").spawn(); assert!(p.is_ok()); @@ -837,6 +838,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn exit_reported_right() { let p = Command::new("false").spawn(); assert!(p.is_ok()); @@ -848,6 +850,7 @@ mod tests { #[test] #[cfg(unix)] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn signal_reported_right() { use os::unix::process::ExitStatusExt; @@ -876,6 +879,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn stdout_works() { let mut cmd = Command::new("echo"); cmd.arg("foobar").stdout(Stdio::piped()); @@ -884,6 +888,7 @@ mod tests { #[test] #[cfg_attr(any(windows, target_os = "android"), ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn set_current_dir_works() { let mut cmd = Command::new("/bin/sh"); cmd.arg("-c").arg("pwd") @@ -894,6 +899,7 @@ mod tests { #[test] #[cfg_attr(any(windows, target_os = "android"), ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn stdin_works() { let mut p = Command::new("/bin/sh") .arg("-c").arg("read line; echo $line") @@ -912,6 +918,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] #[cfg(unix)] + #[cfg_attr(target_os = "emscripten", ignore)] fn uid_works() { use os::unix::prelude::*; use libc; @@ -938,6 +945,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_status() { let mut status = Command::new("false").status().unwrap(); assert!(status.code() == Some(1)); @@ -947,6 +955,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_output_fail_to_start() { match Command::new("/no-binary-by-this-name-should-exist").output() { Err(e) => assert_eq!(e.kind(), ErrorKind::NotFound), @@ -956,6 +965,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_output_output() { let Output {status, stdout, stderr} = Command::new("echo").arg("hello").output().unwrap(); @@ -968,6 +978,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_output_error() { let Output {status, stdout, stderr} = Command::new("mkdir").arg(".").output().unwrap(); @@ -979,6 +990,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_finish_once() { let mut prog = Command::new("false").spawn().unwrap(); assert!(prog.wait().unwrap().code() == Some(1)); @@ -986,6 +998,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_finish_twice() { let mut prog = Command::new("false").spawn().unwrap(); assert!(prog.wait().unwrap().code() == Some(1)); @@ -994,6 +1007,7 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_wait_with_output_once() { let prog = Command::new("echo").arg("hello").stdout(Stdio::piped()) .spawn().unwrap(); @@ -1024,6 +1038,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_inherit_env() { use env; @@ -1049,6 +1064,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_override_env() { use env; @@ -1069,6 +1085,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_add_to_env() { let result = env_cmd().env("RUN_TEST_NEW_ENV", "123").output().unwrap(); let output = String::from_utf8_lossy(&result.stdout).to_string(); diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 3f14fcd239f1d..69cd37651d5c2 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -242,6 +242,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_os_rng_tasks() { let mut txs = vec!(); diff --git a/src/libstd/sync/barrier.rs b/src/libstd/sync/barrier.rs index ac0f400379e3c..f46eab6848463 100644 --- a/src/libstd/sync/barrier.rs +++ b/src/libstd/sync/barrier.rs @@ -118,6 +118,7 @@ mod tests { use thread; #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_barrier() { const N: usize = 10; diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 3db8b05b954c3..a983ae716a481 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -270,6 +270,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn notify_one() { let m = Arc::new(Mutex::new(())); let m2 = m.clone(); @@ -286,6 +287,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn notify_all() { const N: usize = 10; @@ -322,6 +324,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn wait_timeout_ms() { let m = Arc::new(Mutex::new(())); let m2 = m.clone(); @@ -343,6 +346,7 @@ mod tests { #[test] #[should_panic] + #[cfg_attr(target_os = "emscripten", ignore)] fn two_mutexes() { let m = Arc::new(Mutex::new(())); let m2 = m.clone(); diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 3d9f81413dc73..b8101ae85cff3 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1314,6 +1314,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_threads() { let (tx, rx) = channel::(); let _t = thread::spawn(move|| { @@ -1346,6 +1347,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent() { let (tx, rx) = channel::(); let _t = thread::spawn(move|| { @@ -1355,6 +1357,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent_shared() { let (tx, rx) = channel::(); let tx2 = tx.clone(); @@ -1381,6 +1384,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn chan_gone_concurrent() { let (tx, rx) = channel::(); let _t = thread::spawn(move|| { @@ -1391,6 +1395,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { let (tx, rx) = channel::(); let t = thread::spawn(move|| { @@ -1403,6 +1408,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_shared() { const AMT: u32 = 10000; const NTHREADS: u32 = 8; @@ -1429,6 +1435,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn send_from_outside_runtime() { let (tx1, rx1) = channel::<()>(); let (tx2, rx2) = channel::(); @@ -1449,6 +1456,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn recv_from_outside_runtime() { let (tx, rx) = channel::(); let t = thread::spawn(move|| { @@ -1463,6 +1471,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn no_runtime() { let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::(); @@ -1501,6 +1510,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = thread::spawn(move|| { @@ -1570,6 +1580,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_send() { let (tx, rx) = channel::>(); let _t = thread::spawn(move|| { @@ -1580,6 +1591,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_close() { let (tx, rx) = channel::>(); let _t = thread::spawn(move|| { @@ -1592,6 +1604,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::(); @@ -1603,6 +1616,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::(); @@ -1616,6 +1630,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_recv_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::(); @@ -1634,6 +1649,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::>(); @@ -1645,6 +1661,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stream_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel(); @@ -1683,6 +1700,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_two_threads() { let (tx, rx) = channel(); let stress = stress_factor() + 100; @@ -1724,6 +1742,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_shared() { let (tx, rx) = channel(); let stress = stress_factor() + 100; @@ -1762,6 +1781,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn shared_recv_timeout() { let (tx, rx) = channel(); let total = 5; @@ -1780,6 +1800,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn shared_chan_stress() { let (tx, rx) = channel(); let total = stress_factor() + 100; @@ -1796,6 +1817,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_nested_recv_iter() { let (tx, rx) = channel::(); let (total_tx, total_rx) = channel::(); @@ -1816,6 +1838,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_recv_iter_break() { let (tx, rx) = channel::(); let (count_tx, count_rx) = channel(); @@ -1841,6 +1864,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_recv_try_iter() { let (request_tx, request_rx) = channel(); let (response_tx, response_rx) = channel(); @@ -1895,6 +1919,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn try_recv_states() { let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::<()>(); @@ -1921,6 +1946,7 @@ mod tests { // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = channel(); let (tx2, rx2) = channel(); @@ -1988,6 +2014,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_threads() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { @@ -2013,6 +2040,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { @@ -2022,6 +2050,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent_shared() { let (tx, rx) = sync_channel::(0); let tx2 = tx.clone(); @@ -2048,6 +2077,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn chan_gone_concurrent() { let (tx, rx) = sync_channel::(0); thread::spawn(move|| { @@ -2058,6 +2088,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { let (tx, rx) = sync_channel::(0); thread::spawn(move|| { @@ -2069,6 +2100,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_two_threads() { let (tx, rx) = sync_channel::(0); @@ -2092,6 +2124,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_shared() { const AMT: u32 = 1000; const NTHREADS: u32 = 8; @@ -2130,6 +2163,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress_shared() { const AMT: u32 = 1000; const NTHREADS: u32 = 8; @@ -2180,6 +2214,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = thread::spawn(move|| { @@ -2264,6 +2299,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_send() { let (tx, rx) = sync_channel::>(0); let _t = thread::spawn(move|| { @@ -2274,6 +2310,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_close() { let (tx, rx) = sync_channel::>(0); let _t = thread::spawn(move|| { @@ -2286,6 +2323,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::(0); @@ -2297,6 +2335,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::(0); @@ -2310,6 +2349,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_recv_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::(0); @@ -2328,6 +2368,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::>(0); @@ -2339,6 +2380,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stream_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::>(0); @@ -2375,6 +2417,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn shared_chan_stress() { let (tx, rx) = sync_channel(0); let total = stress_factor() + 100; @@ -2391,6 +2434,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_nested_recv_iter() { let (tx, rx) = sync_channel::(0); let (total_tx, total_rx) = sync_channel::(0); @@ -2411,6 +2455,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_recv_iter_break() { let (tx, rx) = sync_channel::(0); let (count_tx, count_rx) = sync_channel(0); @@ -2436,6 +2481,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn try_recv_states() { let (tx1, rx1) = sync_channel::(1); let (tx2, rx2) = sync_channel::<()>(1); @@ -2462,6 +2508,7 @@ mod sync_tests { // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = sync_channel::<()>(0); let (tx2, rx2) = sync_channel::<()>(0); @@ -2483,6 +2530,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn send1() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { rx.recv().unwrap(); }); @@ -2490,6 +2538,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn send2() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { drop(rx); }); @@ -2497,6 +2546,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn send3() { let (tx, rx) = sync_channel::(1); assert_eq!(tx.send(1), Ok(())); @@ -2505,6 +2555,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn send4() { let (tx, rx) = sync_channel::(0); let tx2 = tx.clone(); @@ -2545,6 +2596,7 @@ mod sync_tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn issue_15761() { fn repro() { let (tx1, rx1) = sync_channel::<()>(3); diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index d926043fbbcd0..2ff9ffe6d0810 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -161,6 +161,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test() { let nthreads = 8; let nmsgs = 1000; diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 51b08bd75c4bc..3058282edf337 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -444,6 +444,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn unblocks() { let (tx1, rx1) = channel::(); let (_tx2, rx2) = channel::(); @@ -468,6 +469,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn both_ready() { let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::(); @@ -494,6 +496,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { const AMT: i32 = 10000; let (tx1, rx1) = channel::(); @@ -521,6 +524,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn cloning() { let (tx1, rx1) = channel::(); let (_tx2, rx2) = channel::(); @@ -543,6 +547,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn cloning2() { let (tx1, rx1) = channel::(); let (_tx2, rx2) = channel::(); @@ -565,6 +570,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn cloning3() { let (tx1, rx1) = channel::<()>(); let (tx2, rx2) = channel::<()>(); @@ -682,6 +688,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); @@ -698,6 +705,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stream_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); @@ -718,6 +726,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn shared_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); @@ -746,6 +755,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn sync2() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { @@ -758,6 +768,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn sync3() { let (tx1, rx1) = sync_channel::(0); let (tx2, rx2): (Sender, Receiver) = channel(); diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index 724d7b1be730d..cb9577f155ea1 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -305,6 +305,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { unsafe { stress_bound(0); diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 098a3e44258c7..07d60f0610f8c 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -375,6 +375,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn lots_and_lots() { const J: u32 = 1000; const K: u32 = 3; @@ -435,6 +436,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_into_inner_poison() { let m = Arc::new(Mutex::new(NonCopy(10))); let m2 = m.clone(); @@ -458,6 +460,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_get_mut_poison() { let m = Arc::new(Mutex::new(NonCopy(10))); let m2 = m.clone(); @@ -474,6 +477,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_condvar() { let packet = Packet(Arc::new((Mutex::new(false), Condvar::new()))); let packet2 = Packet(packet.0.clone()); @@ -497,6 +501,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_arc_condvar_poison() { let packet = Packet(Arc::new((Mutex::new(1), Condvar::new()))); let packet2 = Packet(packet.0.clone()); @@ -526,6 +531,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_poison() { let arc = Arc::new(Mutex::new(1)); assert!(!arc.is_poisoned()); @@ -539,6 +545,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_nested() { // Tests nested mutexes and access // to underlying data. @@ -555,6 +562,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_access_in_unwind() { let arc = Arc::new(Mutex::new(1)); let arc2 = arc.clone(); diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 86d2986959c99..64c3e2bb42f49 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -385,6 +385,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn stampede_once() { static O: Once = Once::new(); static mut run: bool = false; @@ -447,6 +448,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn wait_for_force_to_finish() { static O: Once = Once::new(); diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 7f053c6704b56..cb46b694f37e5 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -403,6 +403,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn frob() { const N: usize = 10; const M: usize = 1000; @@ -430,6 +431,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_poison_wr() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -441,6 +443,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_poison_ww() { let arc = Arc::new(RwLock::new(1)); assert!(!arc.is_poisoned()); @@ -454,6 +457,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_no_poison_rr() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -465,6 +469,7 @@ mod tests { assert_eq!(*lock, 1); } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_no_poison_rw() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -477,6 +482,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc() { let arc = Arc::new(RwLock::new(0)); let arc2 = arc.clone(); @@ -515,6 +521,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_access_in_unwind() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -587,6 +594,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_into_inner_poison() { let m = Arc::new(RwLock::new(NonCopy(10))); let m2 = m.clone(); @@ -610,6 +618,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_get_mut_poison() { let m = Arc::new(RwLock::new(NonCopy(10))); let m2 = m.clone(); diff --git a/src/libstd/sys/common/io.rs b/src/libstd/sys/common/io.rs index 3cd70eddb858c..2778ed9326c07 100644 --- a/src/libstd/sys/common/io.rs +++ b/src/libstd/sys/common/io.rs @@ -165,6 +165,7 @@ mod tests { } #[bench] + #[cfg_attr(target_os = "emscripten", ignore)] fn bench_uninitialized(b: &mut ::test::Bencher) { b.iter(|| { let mut lr = repeat(1).take(10000000); diff --git a/src/libstd/sys/common/remutex.rs b/src/libstd/sys/common/remutex.rs index cbdeaad7f6bd3..4935afe6afc42 100644 --- a/src/libstd/sys/common/remutex.rs +++ b/src/libstd/sys/common/remutex.rs @@ -181,6 +181,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn is_mutex() { let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); let m2 = m.clone(); @@ -198,6 +199,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn trylock_works() { let m = Arc::new(ReentrantMutex::new(())); let m2 = m.clone(); @@ -218,6 +220,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn poison_works() { let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); let mc = m.clone(); diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 3f93fce193561..8224696db2f8d 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -806,6 +806,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn basic() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -834,6 +835,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn pair() { let msg1 = b"hello"; let msg2 = b"world!"; @@ -857,6 +859,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn try_clone() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -883,6 +886,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn iter() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -905,6 +909,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn long_path() { let dir = tmpdir(); let socket_path = dir.path() @@ -930,6 +935,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn timeouts() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -957,6 +963,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_timeout() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -972,6 +979,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_with_timeout() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -993,6 +1001,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1009,6 +1018,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_unnamed_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1026,6 +1036,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_connect_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1052,6 +1063,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_unix_datagram_recv() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1069,6 +1081,7 @@ mod test { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn datagram_pair() { let msg1 = b"hello"; let msg2 = b"world!"; diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 50014f51f6cf4..85aba4b9b156b 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -630,6 +630,7 @@ mod tests { #[test] #[cfg_attr(target_os = "macos", ignore)] #[cfg_attr(target_os = "nacl", ignore)] // no signals on NaCl. + #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_mask() { unsafe { // Test to make sure that a signal mask does not get inherited. diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index c44dee49f14a6..59748b47d8157 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -541,6 +541,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_no_dtor() { thread_local!(static FOO: Cell = Cell::new(1)); @@ -563,6 +564,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn states() { struct Foo; impl Drop for Foo { @@ -586,6 +588,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_dtor() { thread_local!(static FOO: UnsafeCell> = UnsafeCell::new(None)); @@ -600,6 +603,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn circular() { struct S1; struct S2; @@ -640,6 +644,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn self_referential() { struct S1; thread_local!(static K1: UnsafeCell> = UnsafeCell::new(None)); @@ -661,6 +666,7 @@ mod tests { // test on OSX. #[test] #[cfg_attr(target_os = "macos", ignore)] + #[cfg_attr(target_os = "emscripten", ignore)] fn dtors_in_dtors_in_dtors() { struct S1(Sender<()>); thread_local!(static K1: UnsafeCell> = UnsafeCell::new(None)); diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index d8e021bb04ff9..b42a0fa3ac130 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -755,6 +755,7 @@ mod tests { // !!! instead of exiting cleanly. This might wedge the buildbots. !!! #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_unnamed_thread() { thread::spawn(move|| { assert!(thread::current().name().is_none()); @@ -762,6 +763,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_named_thread() { Builder::new().name("ada lovelace".to_string()).spawn(move|| { assert!(thread::current().name().unwrap() == "ada lovelace".to_string()); @@ -770,11 +772,13 @@ mod tests { #[test] #[should_panic] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_invalid_named_thread() { let _ = Builder::new().name("ada l\0velace".to_string()).spawn(|| {}); } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_run_basic() { let (tx, rx) = channel(); thread::spawn(move|| { @@ -784,6 +788,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_join_panic() { match thread::spawn(move|| { panic!() @@ -794,6 +799,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_spawn_sched() { let (tx, rx) = channel(); @@ -813,6 +819,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_spawn_sched_childs_on_default_sched() { let (tx, rx) = channel(); @@ -841,6 +848,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_spawn() { avoid_copying_the_body(|v| { thread::spawn(move || v()); @@ -848,6 +856,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_thread_spawn() { avoid_copying_the_body(|f| { thread::spawn(move|| { @@ -857,6 +866,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_join() { avoid_copying_the_body(|f| { let _ = thread::spawn(move|| { @@ -866,6 +876,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_child_doesnt_ref_parent() { // If the child refcounts the parent thread, this will stack overflow when // climbing the thread tree to dereference each ancestor. (See #1789) @@ -883,11 +894,13 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_simple_newsched_spawn() { thread::spawn(move || {}); } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_static_str() { match thread::spawn(move|| { panic!("static string"); @@ -902,6 +915,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_owned_str() { match thread::spawn(move|| { panic!("owned string".to_string()); @@ -916,6 +930,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_any() { match thread::spawn(move|| { panic!(box 413u16 as Box); @@ -932,6 +947,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_unit_struct() { struct Juju; @@ -944,6 +960,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_before() { for _ in 0..10 { thread::current().unpark(); @@ -952,6 +969,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_not_called() { for _ in 0..10 { thread::park_timeout(Duration::from_millis(10)); @@ -959,6 +977,7 @@ mod tests { } #[test] + #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_called_other_thread() { for _ in 0..10 { let th = thread::current(); From 00e377c1619e09fa5480c0630a7969372185cb8c Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 7 Sep 2016 15:10:57 +0000 Subject: [PATCH 12/27] Ignore all debuginfo tests on emscripten --- src/tools/compiletest/src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 114cfaf7972ea..6e92a32cfeb67 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -431,10 +431,17 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn } }; + // Debugging emscripten code doesn't make sense today + let mut ignore = early_props.ignore; + if (config.mode == DebugInfoGdb || config.mode == DebugInfoLldb) && + config.target.contains("emscripten") { + ignore = true; + } + test::TestDescAndFn { desc: test::TestDesc { name: make_test_name(config, testpaths), - ignore: early_props.ignore, + ignore: ignore, should_panic: should_panic, }, testfn: make_test_closure(config, testpaths), From 10a52d507d984ff6e4a4d5f42fb387db1fe25c11 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 7 Sep 2016 15:13:24 +0000 Subject: [PATCH 13/27] Update LLVM with fastcomp patches --- src/llvm | 2 +- src/rustllvm/llvm-auto-clean-trigger | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/llvm b/src/llvm index 7801978ec1f36..3e03f7374169c 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 7801978ec1f3637fcda1b564048ebc732bf586af +Subproject commit 3e03f7374169cd41547d75e62ac2ab8a103a913c diff --git a/src/rustllvm/llvm-auto-clean-trigger b/src/rustllvm/llvm-auto-clean-trigger index ea8d59290df2e..979f5f07abea1 100644 --- a/src/rustllvm/llvm-auto-clean-trigger +++ b/src/rustllvm/llvm-auto-clean-trigger @@ -1,4 +1,4 @@ # If this file is modified, then llvm will be forcibly cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2016-09-17 +2016-09-25 From 37abec06e502b147b9ebc730030efe10bf235765 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 8 Sep 2016 01:58:00 +0000 Subject: [PATCH 14/27] Tidy --- src/bootstrap/lib.rs | 3 ++- src/librustc_llvm/build.rs | 3 ++- src/test/compile-fail/allocator-dylib-is-system.rs | 2 +- src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs | 2 +- src/test/run-fail/test-panic.rs | 2 +- src/test/run-fail/test-should-fail-bad-message.rs | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 80726951ad87a..033cefb8dea36 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -975,7 +975,8 @@ impl Build { // than an entry here. let mut base = Vec::new(); - if target != self.config.build && !target.contains("msvc") && !target.contains("emscripten") { + if target != self.config.build && !target.contains("msvc") && + !target.contains("emscripten") { base.push(format!("-Clinker={}", self.cc(target).display())); } return base diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index c805fd7c7b641..5257575a94e8b 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -66,7 +66,8 @@ fn main() { let host = env::var("HOST").expect("HOST was not set"); let is_crossed = target != host; - let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz", "jsbackend"]; + let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz", + "jsbackend"]; // FIXME: surely we don't need all these components, right? Stuff like mcjit // or interpreter the compiler itself never uses. diff --git a/src/test/compile-fail/allocator-dylib-is-system.rs b/src/test/compile-fail/allocator-dylib-is-system.rs index 0097de75f94fc..4c576de22021c 100644 --- a/src/test/compile-fail/allocator-dylib-is-system.rs +++ b/src/test/compile-fail/allocator-dylib-is-system.rs @@ -18,7 +18,7 @@ // system allocator. Do this by linking in jemalloc and making sure that we get // an error. -// ignore-emscripten TODO: What "other allocator" should we use for emcc? +// ignore-emscripten FIXME: What "other allocator" should we use for emcc? #![feature(alloc_jemalloc)] diff --git a/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs b/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs index a6b49ec86cc78..02c271ab24da3 100644 --- a/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs +++ b/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs @@ -16,7 +16,7 @@ // Ensure that rust dynamic libraries use jemalloc as their allocator, verifying // by linking in the system allocator here and ensuring that we get a complaint. -// ignore-emscripten TODO: What "other allocator" is correct for emscripten? +// ignore-emscripten FIXME: What "other allocator" is correct for emscripten? #![feature(alloc_system)] diff --git a/src/test/run-fail/test-panic.rs b/src/test/run-fail/test-panic.rs index 070095534a4b9..21ced01d9d69e 100644 --- a/src/test/run-fail/test-panic.rs +++ b/src/test/run-fail/test-panic.rs @@ -12,7 +12,7 @@ // error-pattern:thread 'test_foo' panicked at // compile-flags: --test // ignore-pretty: does not work well with `--test` -// ignore-emscripten +// ignore-emscripten #[test] fn test_foo() { diff --git a/src/test/run-fail/test-should-fail-bad-message.rs b/src/test/run-fail/test-should-fail-bad-message.rs index bd25df3dabd1d..74b5f17bcf9ba 100644 --- a/src/test/run-fail/test-should-fail-bad-message.rs +++ b/src/test/run-fail/test-should-fail-bad-message.rs @@ -12,7 +12,7 @@ // error-pattern:thread 'test_foo' panicked at // compile-flags: --test // ignore-pretty: does not work well with `--test` -// ignore-emscripten +// ignore-emscripten #[test] #[should_panic(expected = "foobar")] From 183b2ddce4771df3bcfe36eb229a1791fe4b0f8f Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 14 Sep 2016 17:10:43 +0000 Subject: [PATCH 15/27] Ignore entire test modules on emscripten instead of individual tests --- src/libstd/net/addr.rs | 2 +- src/libstd/net/ip.rs | 2 +- src/libstd/net/mod.rs | 3 +- src/libstd/net/tcp.rs | 32 +------------------ src/libstd/net/udp.rs | 15 +-------- src/libstd/process.rs | 19 +----------- src/libstd/sync/mpsc/mod.rs | 56 ++-------------------------------- src/libstd/sync/mpsc/select.rs | 13 +------- 8 files changed, 10 insertions(+), 132 deletions(-) diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index 930f2c721a7b7..a77d83a23ce73 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -519,7 +519,7 @@ impl<'a, T: ToSocketAddrs + ?Sized> ToSocketAddrs for &'a T { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use net::*; use net::test::{tsa, sa6, sa4}; diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 05ef559422f33..ba2cd70e0d777 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -669,7 +669,7 @@ impl From<[u8; 16]> for Ipv6Addr { } // Tests for this module -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use net::*; use net::Ipv6MulticastScope::*; diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs index ad2fe3c1c0dbc..7dd0e30df0368 100644 --- a/src/libstd/net/mod.rs +++ b/src/libstd/net/mod.rs @@ -31,7 +31,8 @@ mod addr; mod tcp; mod udp; mod parser; -#[cfg(test)] mod test; +#[cfg(all(test, not(target_os = "emscripten")))] +mod test; /// Possible values which can be passed to the [`shutdown`] method of /// [`TcpStream`]. diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index d34fce2be43ca..0e7c5b06713fb 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -428,7 +428,7 @@ impl fmt::Debug for TcpListener { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use io::ErrorKind; use io::prelude::*; @@ -454,7 +454,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn bind_error() { match TcpListener::bind("1.1.1.1:9999") { Ok(..) => panic!(), @@ -464,7 +463,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn connect_error() { match TcpStream::connect("0.0.0.0:1") { Ok(..) => panic!(), @@ -477,7 +475,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn listen_localhost() { let socket_addr = next_test_ip4(); let listener = t!(TcpListener::bind(&socket_addr)); @@ -495,7 +492,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn connect_loopback() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -517,7 +513,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_test() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -538,7 +533,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn read_eof() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -558,7 +552,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn write_close() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -585,7 +578,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn multiple_connect_serial() { each_ip(&mut |addr| { let max = 10; @@ -608,7 +600,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn multiple_connect_interleaved_greedy_schedule() { const MAX: usize = 10; each_ip(&mut |addr| { @@ -644,7 +635,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn multiple_connect_interleaved_lazy_schedule() { const MAX: usize = 10; each_ip(&mut |addr| { @@ -678,7 +668,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn socket_and_peer_name() { each_ip(&mut |addr| { let listener = t!(TcpListener::bind(&addr)); @@ -694,7 +683,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn partial_read() { each_ip(&mut |addr| { let (tx, rx) = channel(); @@ -716,7 +704,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn double_bind() { each_ip(&mut |addr| { let _listener = t!(TcpListener::bind(&addr)); @@ -733,7 +720,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn fast_rebind() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -749,7 +735,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn tcp_clone_smoke() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -781,7 +766,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn tcp_clone_two_read() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -816,7 +800,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn tcp_clone_two_write() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -844,7 +827,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn shutdown_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -865,7 +847,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn close_readwrite_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -904,7 +885,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn close_read_wakes_up() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -932,7 +912,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn clone_while_reading() { each_ip(&mut |addr| { let accept = t!(TcpListener::bind(&addr)); @@ -973,7 +952,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn clone_accept_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -992,7 +970,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn clone_accept_concurrent() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -1021,7 +998,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn debug() { let name = if cfg!(windows) {"socket"} else {"fd"}; let socket_addr = next_test_ip4(); @@ -1048,7 +1024,6 @@ mod tests { // no longer has rounding errors. #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)] #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn timeouts() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -1075,7 +1050,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_timeout() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -1092,7 +1066,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_with_timeout() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -1115,7 +1088,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn nodelay() { let addr = next_test_ip4(); let _listener = t!(TcpListener::bind(&addr)); @@ -1130,7 +1102,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn ttl() { let ttl = 100; @@ -1147,7 +1118,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn set_nonblocking() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 7315b6aaeb6ed..c03ac496adbb2 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -353,7 +353,7 @@ impl fmt::Debug for UdpSocket { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use io::ErrorKind; use net::*; @@ -378,7 +378,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn bind_error() { match UdpSocket::bind("1.1.1.1:9999") { Ok(..) => panic!(), @@ -389,7 +388,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn socket_smoke_test_ip4() { each_ip(&mut |server_ip, client_ip| { let (tx1, rx1) = channel(); @@ -414,7 +412,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn socket_name_ip4() { each_ip(&mut |addr, _| { let server = t!(UdpSocket::bind(&addr)); @@ -423,7 +420,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn udp_clone_smoke() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -453,7 +449,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn udp_clone_two_read() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -486,7 +481,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn udp_clone_two_write() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -525,7 +519,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn debug() { let name = if cfg!(windows) {"socket"} else {"fd"}; let socket_addr = next_test_ip4(); @@ -541,7 +534,6 @@ mod tests { // no longer has rounding errors. #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)] #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn timeouts() { let addr = next_test_ip4(); @@ -566,7 +558,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_timeout() { let addr = next_test_ip4(); @@ -582,7 +573,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_with_timeout() { let addr = next_test_ip4(); @@ -602,7 +592,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn connect_send_recv() { let addr = next_test_ip4(); @@ -617,7 +606,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn ttl() { let ttl = 100; @@ -630,7 +618,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn set_nonblocking() { let addr = next_test_ip4(); diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 233a4d3639c3b..9434815577981 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -807,7 +807,7 @@ pub fn exit(code: i32) -> ! { ::sys::os::exit(code) } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use io::prelude::*; @@ -819,7 +819,6 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn smoke() { let p = Command::new("true").spawn(); assert!(p.is_ok()); @@ -838,7 +837,6 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn exit_reported_right() { let p = Command::new("false").spawn(); assert!(p.is_ok()); @@ -850,7 +848,6 @@ mod tests { #[test] #[cfg(unix)] #[cfg_attr(target_os = "android", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn signal_reported_right() { use os::unix::process::ExitStatusExt; @@ -879,7 +876,6 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn stdout_works() { let mut cmd = Command::new("echo"); cmd.arg("foobar").stdout(Stdio::piped()); @@ -888,7 +884,6 @@ mod tests { #[test] #[cfg_attr(any(windows, target_os = "android"), ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn set_current_dir_works() { let mut cmd = Command::new("/bin/sh"); cmd.arg("-c").arg("pwd") @@ -899,7 +894,6 @@ mod tests { #[test] #[cfg_attr(any(windows, target_os = "android"), ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn stdin_works() { let mut p = Command::new("/bin/sh") .arg("-c").arg("read line; echo $line") @@ -918,7 +912,6 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] #[cfg(unix)] - #[cfg_attr(target_os = "emscripten", ignore)] fn uid_works() { use os::unix::prelude::*; use libc; @@ -945,7 +938,6 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_status() { let mut status = Command::new("false").status().unwrap(); assert!(status.code() == Some(1)); @@ -955,7 +947,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_output_fail_to_start() { match Command::new("/no-binary-by-this-name-should-exist").output() { Err(e) => assert_eq!(e.kind(), ErrorKind::NotFound), @@ -965,7 +956,6 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_output_output() { let Output {status, stdout, stderr} = Command::new("echo").arg("hello").output().unwrap(); @@ -978,7 +968,6 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_output_error() { let Output {status, stdout, stderr} = Command::new("mkdir").arg(".").output().unwrap(); @@ -990,7 +979,6 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_finish_once() { let mut prog = Command::new("false").spawn().unwrap(); assert!(prog.wait().unwrap().code() == Some(1)); @@ -998,7 +986,6 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_finish_twice() { let mut prog = Command::new("false").spawn().unwrap(); assert!(prog.wait().unwrap().code() == Some(1)); @@ -1007,7 +994,6 @@ mod tests { #[test] #[cfg_attr(target_os = "android", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_wait_with_output_once() { let prog = Command::new("echo").arg("hello").stdout(Stdio::piped()) .spawn().unwrap(); @@ -1038,7 +1024,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_inherit_env() { use env; @@ -1064,7 +1049,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_override_env() { use env; @@ -1085,7 +1069,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_add_to_env() { let result = env_cmd().env("RUN_TEST_NEW_ENV", "123").output().unwrap(); let output = String::from_utf8_lossy(&result.stdout).to_string(); diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index b8101ae85cff3..d9c14ef2f771e 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1268,7 +1268,7 @@ impl error::Error for TryRecvError { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use env; use super::*; @@ -1314,7 +1314,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_threads() { let (tx, rx) = channel::(); let _t = thread::spawn(move|| { @@ -1347,7 +1346,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent() { let (tx, rx) = channel::(); let _t = thread::spawn(move|| { @@ -1357,7 +1355,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent_shared() { let (tx, rx) = channel::(); let tx2 = tx.clone(); @@ -1384,7 +1381,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn chan_gone_concurrent() { let (tx, rx) = channel::(); let _t = thread::spawn(move|| { @@ -1395,7 +1391,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { let (tx, rx) = channel::(); let t = thread::spawn(move|| { @@ -1408,7 +1403,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress_shared() { const AMT: u32 = 10000; const NTHREADS: u32 = 8; @@ -1435,7 +1429,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn send_from_outside_runtime() { let (tx1, rx1) = channel::<()>(); let (tx2, rx2) = channel::(); @@ -1456,7 +1449,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recv_from_outside_runtime() { let (tx, rx) = channel::(); let t = thread::spawn(move|| { @@ -1471,7 +1463,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn no_runtime() { let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::(); @@ -1510,7 +1501,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = thread::spawn(move|| { @@ -1580,7 +1570,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_send() { let (tx, rx) = channel::>(); let _t = thread::spawn(move|| { @@ -1591,7 +1580,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_close() { let (tx, rx) = channel::>(); let _t = thread::spawn(move|| { @@ -1604,7 +1592,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::(); @@ -1616,7 +1603,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::(); @@ -1630,7 +1616,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_recv_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::(); @@ -1649,7 +1634,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel::>(); @@ -1661,7 +1645,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stream_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = channel(); @@ -1700,7 +1683,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_two_threads() { let (tx, rx) = channel(); let stress = stress_factor() + 100; @@ -1742,7 +1724,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_shared() { let (tx, rx) = channel(); let stress = stress_factor() + 100; @@ -1781,7 +1762,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn shared_recv_timeout() { let (tx, rx) = channel(); let total = 5; @@ -1800,7 +1780,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn shared_chan_stress() { let (tx, rx) = channel(); let total = stress_factor() + 100; @@ -1817,7 +1796,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_nested_recv_iter() { let (tx, rx) = channel::(); let (total_tx, total_rx) = channel::(); @@ -1838,7 +1816,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_recv_iter_break() { let (tx, rx) = channel::(); let (count_tx, count_rx) = channel(); @@ -1864,7 +1841,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_recv_try_iter() { let (request_tx, request_rx) = channel(); let (response_tx, response_rx) = channel(); @@ -1919,7 +1895,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn try_recv_states() { let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::<()>(); @@ -1946,7 +1921,6 @@ mod tests { // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = channel(); let (tx2, rx2) = channel(); @@ -1968,7 +1942,7 @@ mod tests { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod sync_tests { use env; use thread; @@ -2014,7 +1988,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_threads() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { @@ -2040,7 +2013,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { @@ -2050,7 +2022,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn port_gone_concurrent_shared() { let (tx, rx) = sync_channel::(0); let tx2 = tx.clone(); @@ -2077,7 +2048,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn chan_gone_concurrent() { let (tx, rx) = sync_channel::(0); thread::spawn(move|| { @@ -2088,7 +2058,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { let (tx, rx) = sync_channel::(0); thread::spawn(move|| { @@ -2100,7 +2069,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_two_threads() { let (tx, rx) = sync_channel::(0); @@ -2124,7 +2092,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress_recv_timeout_shared() { const AMT: u32 = 1000; const NTHREADS: u32 = 8; @@ -2163,7 +2130,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress_shared() { const AMT: u32 = 1000; const NTHREADS: u32 = 8; @@ -2214,7 +2180,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = thread::spawn(move|| { @@ -2299,7 +2264,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_send() { let (tx, rx) = sync_channel::>(0); let _t = thread::spawn(move|| { @@ -2310,7 +2274,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_task_recv_then_close() { let (tx, rx) = sync_channel::>(0); let _t = thread::spawn(move|| { @@ -2323,7 +2286,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::(0); @@ -2335,7 +2297,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::(0); @@ -2349,7 +2310,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_recv_close_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::(0); @@ -2368,7 +2328,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::>(0); @@ -2380,7 +2339,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stream_send_recv_stress() { for _ in 0..stress_factor() { let (tx, rx) = sync_channel::>(0); @@ -2417,7 +2375,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn shared_chan_stress() { let (tx, rx) = sync_channel(0); let total = stress_factor() + 100; @@ -2434,7 +2391,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_nested_recv_iter() { let (tx, rx) = sync_channel::(0); let (total_tx, total_rx) = sync_channel::(0); @@ -2455,7 +2411,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_recv_iter_break() { let (tx, rx) = sync_channel::(0); let (count_tx, count_rx) = sync_channel(0); @@ -2481,7 +2436,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn try_recv_states() { let (tx1, rx1) = sync_channel::(1); let (tx2, rx2) = sync_channel::<()>(1); @@ -2508,7 +2462,6 @@ mod sync_tests { // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = sync_channel::<()>(0); let (tx2, rx2) = sync_channel::<()>(0); @@ -2530,7 +2483,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn send1() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { rx.recv().unwrap(); }); @@ -2538,7 +2490,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn send2() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { drop(rx); }); @@ -2546,7 +2497,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn send3() { let (tx, rx) = sync_channel::(1); assert_eq!(tx.send(1), Ok(())); @@ -2555,7 +2505,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn send4() { let (tx, rx) = sync_channel::(0); let tx2 = tx.clone(); @@ -2596,7 +2545,6 @@ mod sync_tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn issue_15761() { fn repro() { let (tx1, rx1) = sync_channel::<()>(3); diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 3058282edf337..91896e1ab85dc 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -366,7 +366,7 @@ impl<'rx, T:Send+'rx> fmt::Debug for Handle<'rx, T> { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] #[allow(unused_imports)] mod tests { use thread; @@ -444,7 +444,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn unblocks() { let (tx1, rx1) = channel::(); let (_tx2, rx2) = channel::(); @@ -469,7 +468,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn both_ready() { let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::(); @@ -496,7 +494,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { const AMT: i32 = 10000; let (tx1, rx1) = channel::(); @@ -524,7 +521,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn cloning() { let (tx1, rx1) = channel::(); let (_tx2, rx2) = channel::(); @@ -547,7 +543,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn cloning2() { let (tx1, rx1) = channel::(); let (_tx2, rx2) = channel::(); @@ -570,7 +565,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn cloning3() { let (tx1, rx1) = channel::<()>(); let (tx2, rx2) = channel::<()>(); @@ -688,7 +682,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn oneshot_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); @@ -705,7 +698,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stream_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); @@ -726,7 +718,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn shared_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); @@ -755,7 +746,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn sync2() { let (tx, rx) = sync_channel::(0); let _t = thread::spawn(move|| { @@ -768,7 +758,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn sync3() { let (tx1, rx1) = sync_channel::(0); let (tx2, rx2): (Sender, Receiver) = channel(); From a4c328812997540c82f5039d346d0b30bc1feac4 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 14 Sep 2016 17:15:48 +0000 Subject: [PATCH 16/27] Change the sigs of set_print/set_panic to allow restoring the default objects --- src/librustc_driver/lib.rs | 4 ++-- src/librustdoc/test.rs | 2 +- src/libstd/io/stdio.rs | 8 ++++---- src/libtest/lib.rs | 16 ++++++---------- src/test/run-pass/task-stderr.rs | 2 +- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 5ac4512fe3900..492165e2f2a8e 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1075,7 +1075,7 @@ pub fn monitor(f: F) { } let thread = cfg.spawn(move || { - io::set_panic(box err); + io::set_panic(Some(box err)); f() }); @@ -1121,7 +1121,7 @@ fn exit_on_err() -> ! { // Panic so the process returns a failure code, but don't pollute the // output with some unnecessary panic messages, we've already // printed everything that we needed to. - io::set_panic(box io::sink()); + io::set_panic(Some(box io::sink())); panic!(); } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 1ab86cf7e8920..02f0916de0ef3 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -228,7 +228,7 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec, libs: SearchPaths, let codemap = Rc::new(CodeMap::new()); let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()), Some(codemap.clone())); - let old = io::set_panic(box Sink(data.clone())); + let old = io::set_panic(Some(box Sink(data.clone()))); let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); // Compile the code diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 89cb9909956ee..6421595a009a7 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -593,11 +593,11 @@ impl<'a> Write for StderrLock<'a> { with a more general mechanism", issue = "0")] #[doc(hidden)] -pub fn set_panic(sink: Box) -> Option> { +pub fn set_panic(sink: Option>) -> Option> { use panicking::LOCAL_STDERR; use mem; LOCAL_STDERR.with(move |slot| { - mem::replace(&mut *slot.borrow_mut(), Some(sink)) + mem::replace(&mut *slot.borrow_mut(), sink) }).and_then(|mut s| { let _ = s.flush(); Some(s) @@ -617,10 +617,10 @@ pub fn set_panic(sink: Box) -> Option> { with a more general mechanism", issue = "0")] #[doc(hidden)] -pub fn set_print(sink: Box) -> Option> { +pub fn set_print(sink: Option>) -> Option> { use mem; LOCAL_STDOUT.with(move |slot| { - mem::replace(&mut *slot.borrow_mut(), Some(sink)) + mem::replace(&mut *slot.borrow_mut(), sink) }).and_then(|mut s| { let _ = s.flush(); Some(s) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 49a7f6589d2b6..5949afe0ff167 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1200,8 +1200,8 @@ pub fn run_test(opts: &TestOpts, let result_guard = cfg.spawn(move || { if !nocapture { - io::set_print(box Sink(data2.clone())); - io::set_panic(box Sink(data2)); + io::set_print(Some(box Sink(data2.clone()))); + io::set_panic(Some(box Sink(data2))); } testfn() }) @@ -1213,8 +1213,8 @@ pub fn run_test(opts: &TestOpts, } else { let oldio = if !nocapture { Some(( - io::set_print(box Sink(data2.clone())), - io::set_panic(box Sink(data2)) + io::set_print(Some(box Sink(data2.clone()))), + io::set_panic(Some(box Sink(data2))) )) } else { None @@ -1227,12 +1227,8 @@ pub fn run_test(opts: &TestOpts, })); if let Some((printio, panicio)) = oldio { - if let Some(printio) = printio { - io::set_print(printio); - } - if let Some(panicio) = panicio { - io::set_panic(panicio); - } + io::set_print(printio); + io::set_panic(panicio); }; let test_result = calc_result(&desc, result); diff --git a/src/test/run-pass/task-stderr.rs b/src/test/run-pass/task-stderr.rs index 1f64f40c5255b..13d5cc989e94d 100644 --- a/src/test/run-pass/task-stderr.rs +++ b/src/test/run-pass/task-stderr.rs @@ -30,7 +30,7 @@ fn main() { let data = Arc::new(Mutex::new(Vec::new())); let sink = Sink(data.clone()); let res = thread::Builder::new().spawn(move|| -> () { - io::set_panic(Box::new(sink)); + io::set_panic(Some(Box::new(sink))); panic!("Hello, world!") }).unwrap().join(); assert!(res.is_err()); From 8401e37495e5f0794a8833a385ee7c37cb8cf47e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 15 Sep 2016 19:42:26 +0000 Subject: [PATCH 17/27] Update bootstrap and compiletest to use the detected nodejs --- src/bootstrap/check.rs | 7 ++++++- src/tools/compiletest/src/common.rs | 1 + src/tools/compiletest/src/main.rs | 2 ++ src/tools/compiletest/src/runtest.rs | 3 ++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 0bd9355098f26..95c909aef773c 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -108,6 +108,10 @@ pub fn compiletest(build: &Build, cmd.arg("--host").arg(compiler.host); cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(&build.config.build)); + if let Some(nodejs) = build.config.nodejs.as_ref() { + cmd.arg("--nodejs").arg(nodejs); + } + let mut flags = vec!["-Crpath".to_string()]; if build.config.rust_optimize_tests { flags.push("-O".to_string()); @@ -386,7 +390,8 @@ fn krate_emscripten(build: &Build, for test in tests { let test_file_name = test.to_string_lossy().into_owned(); println!("running {}", test_file_name); - let output = Command::new("node") + let nodejs = build.config.nodejs.as_ref().expect("nodejs not configured"); + let output = Command::new(nodejs) .arg(&test_file_name) .stderr(::std::process::Stdio::inherit()) .output(); diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 5d522736089ea..81cb927f26b02 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -183,4 +183,5 @@ pub struct Config { pub cflags: String, pub llvm_components: String, pub llvm_cxxflags: String, + pub nodejs: Option, } diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 6e92a32cfeb67..ff91ab7c70b3e 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -109,6 +109,7 @@ pub fn parse_config(args: Vec ) -> Config { reqopt("", "cflags", "flags for the C compiler", "FLAGS"), reqopt("", "llvm-components", "list of LLVM components built in", "LIST"), reqopt("", "llvm-cxxflags", "C++ flags for LLVM", "FLAGS"), + optopt("", "nodejs", "the name of nodejs", "PATH"), optflag("h", "help", "show this message")); let (argv0, args_) = args.split_first().unwrap(); @@ -190,6 +191,7 @@ pub fn parse_config(args: Vec ) -> Config { cflags: matches.opt_str("cflags").unwrap(), llvm_components: matches.opt_str("llvm-components").unwrap(), llvm_cxxflags: matches.opt_str("llvm-cxxflags").unwrap(), + nodejs: matches.opt_str("nodejs"), } } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 5885e464b4f14..35b93392baf2c 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1439,7 +1439,8 @@ actual:\n\ // If this is emscripten, then run tests under nodejs if self.config.target.contains("emscripten") { - args.push("node".to_owned()); + let nodejs = self.config.nodejs.clone().unwrap_or("nodejs".to_string()); + args.push(nodejs); } let exe_file = self.make_exe_name(); From 7c0bf41cffc39d011bde4ca722c94d58617c4c91 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 16 Sep 2016 18:07:17 +0000 Subject: [PATCH 18/27] Ignore another emscripten test because missing intrinsics --- src/libcoretest/num/flt2dec/estimator.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcoretest/num/flt2dec/estimator.rs b/src/libcoretest/num/flt2dec/estimator.rs index 857aae72c8a5b..e20881fd3296b 100644 --- a/src/libcoretest/num/flt2dec/estimator.rs +++ b/src/libcoretest/num/flt2dec/estimator.rs @@ -11,6 +11,8 @@ use core::num::flt2dec::estimator::*; #[test] +// FIXME https://github.com/kripken/emscripten/issues/4563 +#[cfg_attr(target_os = "emscripten", ignore)] fn test_estimate_scaling_factor() { macro_rules! assert_almost_eq { ($actual:expr, $expected:expr) => ({ From 525a798ca6513a204de8bd434bf260d79cbdfc9f Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 22 Sep 2016 19:55:42 +0000 Subject: [PATCH 19/27] Rewrite emscripten unwinding to use libcxx --- src/libpanic_unwind/Cargo.lock | 9 ++++ src/libpanic_unwind/emcc.rs | 76 ++++++++++++++++++++++++++++++++++ src/libpanic_unwind/gcc.rs | 10 ----- src/libpanic_unwind/lib.rs | 8 +++- src/libunwind/libunwind.rs | 2 +- 5 files changed, 93 insertions(+), 12 deletions(-) create mode 100644 src/libpanic_unwind/emcc.rs diff --git a/src/libpanic_unwind/Cargo.lock b/src/libpanic_unwind/Cargo.lock index 20d826d4a470e..0cf75c941508b 100644 --- a/src/libpanic_unwind/Cargo.lock +++ b/src/libpanic_unwind/Cargo.lock @@ -5,6 +5,7 @@ dependencies = [ "alloc 0.0.0", "core 0.0.0", "libc 0.0.0", + "unwind 0.0.0", ] [[package]] @@ -25,3 +26,11 @@ dependencies = [ "core 0.0.0", ] +[[package]] +name = "unwind" +version = "0.0.0" +dependencies = [ + "core 0.0.0", + "libc 0.0.0", +] + diff --git a/src/libpanic_unwind/emcc.rs b/src/libpanic_unwind/emcc.rs new file mode 100644 index 0000000000000..598f99ba27bf1 --- /dev/null +++ b/src/libpanic_unwind/emcc.rs @@ -0,0 +1,76 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(private_no_mangle_fns)] + +use core::any::Any; +use core::ptr; +use alloc::boxed::Box; +use libc::{self, c_int}; +use unwind as uw; +use core::mem; + +pub fn payload() -> *mut u8 { + ptr::null_mut() +} + +pub unsafe fn cleanup(ptr: *mut u8) -> Box { + assert!(!ptr.is_null()); + let ex = ptr::read(ptr as *mut _); + __cxa_free_exception(ptr as *mut _); + ex +} + +pub unsafe fn panic(data: Box) -> u32 { + let sz = mem::size_of_val(&data); + let exception = __cxa_allocate_exception(sz); + if exception == ptr::null_mut() { + return uw::_URC_FATAL_PHASE1_ERROR as u32; + } + let exception = exception as *mut Box; + ptr::write(exception, data); + __cxa_throw(exception as *mut _, ptr::null_mut(), ptr::null_mut()); + + unreachable!() +} + +#[lang = "eh_personality"] +#[no_mangle] +unsafe extern "C" fn rust_eh_personality(version: c_int, + actions: uw::_Unwind_Action, + exception_class: uw::_Unwind_Exception_Class, + exception_object: *mut uw::_Unwind_Exception, + context: *mut uw::_Unwind_Context) + -> uw::_Unwind_Reason_Code { + __gxx_personality_v0(version, actions, + exception_class, + exception_object, + context) +} + +#[lang = "eh_unwind_resume"] +#[unwind] +unsafe extern "C" fn rust_eh_unwind_resume(panic_ctx: *mut u8) -> ! { + uw::_Unwind_Resume(panic_ctx as *mut uw::_Unwind_Exception); +} + +extern { + fn __cxa_allocate_exception(thrown_size: libc::size_t) -> *mut libc::c_void; + fn __cxa_free_exception(thrown_exception: *mut libc::c_void); + fn __cxa_throw(thrown_exception: *mut libc::c_void, + tinfo: *mut libc::c_void, + dest: *mut libc::c_void); + fn __gxx_personality_v0(version: c_int, + actions: uw::_Unwind_Action, + exception_class: uw::_Unwind_Exception_Class, + exception_object: *mut uw::_Unwind_Exception, + context: *mut uw::_Unwind_Context) + -> uw::_Unwind_Reason_Code; +} diff --git a/src/libpanic_unwind/gcc.rs b/src/libpanic_unwind/gcc.rs index 5bfa77cba7acf..33b24fbaa2659 100644 --- a/src/libpanic_unwind/gcc.rs +++ b/src/libpanic_unwind/gcc.rs @@ -133,16 +133,6 @@ const UNWIND_DATA_REG: (i32, i32) = (3, 4); // R3, R4 / X3, X4 #[cfg(target_arch = "s390x")] const UNWIND_DATA_REG: (i32, i32) = (6, 7); // R6, R7 -// FIXME: This is completely and utterly wrong. -// I copy'n'pasted the x86 thing just to see if asmjs-unknown-emscripten compiles at all -// (the happy path) -#[cfg(target_arch = "asmjs")] -const UNWIND_DATA_REG: (i32, i32) = (0, 2); // EAX, EDX - -// FIXME: Ditto the above -#[cfg(target_arch = "wasm32")] -const UNWIND_DATA_REG: (i32, i32) = (0, 2); // EAX, EDX - // The following code is based on GCC's C and C++ personality routines. For reference, see: // https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc // https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c diff --git a/src/libpanic_unwind/lib.rs b/src/libpanic_unwind/lib.rs index 11dd9befe0a82..ff483fa823e0c 100644 --- a/src/libpanic_unwind/lib.rs +++ b/src/libpanic_unwind/lib.rs @@ -68,10 +68,16 @@ mod imp; mod imp; // i686-pc-windows-gnu and all others -#[cfg(any(unix, all(windows, target_arch = "x86", target_env = "gnu")))] +#[cfg(any(all(unix, not(target_os = "emscripten")), + all(windows, target_arch = "x86", target_env = "gnu")))] #[path = "gcc.rs"] mod imp; +// emscripten +#[cfg(target_os = "emscripten")] +#[path = "emcc.rs"] +mod imp; + mod dwarf; mod windows; diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index 5d69a95da820c..c2edf754e49c1 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -65,7 +65,7 @@ pub const unwinder_private_data_size: usize = 2; #[cfg(target_arch = "s390x")] pub const unwinder_private_data_size: usize = 2; -#[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))] +#[cfg(target_os = "emscripten")] pub const unwinder_private_data_size: usize = 20; #[repr(C)] From 096670ca41a2aada11722acf4d0ab35a422448f6 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 22 Sep 2016 20:04:48 +0000 Subject: [PATCH 20/27] Ignore various entire test modules on emscripten --- src/libstd/fs.rs | 51 +----------------------------- src/libstd/net/addr.rs | 3 -- src/libstd/sync/mpsc/mpsc_queue.rs | 3 +- src/libstd/sync/mpsc/spsc_queue.rs | 3 +- src/libstd/sync/mutex.rs | 10 +----- src/libstd/sync/once.rs | 4 +-- src/libstd/sync/rwlock.rs | 11 +------ src/libstd/sys/common/io.rs | 2 +- src/libstd/sys/common/remutex.rs | 5 +-- src/libstd/sys/unix/ext/net.rs | 15 +-------- src/libstd/thread/local.rs | 8 +---- src/libstd/thread/mod.rs | 21 +----------- 12 files changed, 11 insertions(+), 125 deletions(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 08d71c1d9f8c9..2f2969b110db1 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1686,7 +1686,7 @@ impl AsInnerMut for DirBuilder { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use io::prelude::*; @@ -1745,7 +1745,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_smoke_test() { let message = "it's alright. have a good time"; let tmpdir = tmpdir(); @@ -1767,7 +1766,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn invalid_path_raises() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_that_does_not_exist.txt"); @@ -1782,7 +1780,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_iounlinking_invalid_path_should_raise_condition() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_another_file_that_does_not_exist.txt"); @@ -1798,7 +1795,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_non_positional_read() { let message: &str = "ten-four"; let mut read_mem = [0; 8]; @@ -1825,7 +1821,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_and_tell_smoke_test() { let message = "ten-four"; let mut read_mem = [0; 4]; @@ -1853,7 +1848,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_and_write() { let initial_msg = "food-is-yummy"; let overwrite_msg = "-the-bar!!"; @@ -1878,7 +1872,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_io_seek_shakedown() { // 01234567890123 let initial_msg = "qwer-asdf-zxcv"; @@ -1911,7 +1904,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_stat_is_correct_on_is_file() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_file.txt"); @@ -1933,7 +1925,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_stat_is_correct_on_is_dir() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_dir"); @@ -1946,7 +1937,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_fileinfo_false_when_checking_is_file_on_a_directory() { let tmpdir = tmpdir(); let dir = &tmpdir.join("fileinfo_false_on_dir"); @@ -1956,7 +1946,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_fileinfo_check_exists_before_and_after_file_creation() { let tmpdir = tmpdir(); let file = &tmpdir.join("fileinfo_check_exists_b_and_a.txt"); @@ -1967,7 +1956,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_directoryinfo_check_exists_before_and_after_mkdir() { let tmpdir = tmpdir(); let dir = &tmpdir.join("before_and_after_dir"); @@ -1980,7 +1968,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_test_directoryinfo_readdir() { let tmpdir = tmpdir(); let dir = &tmpdir.join("di_readdir"); @@ -2010,7 +1997,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_create_new_already_exists_error() { let tmpdir = tmpdir(); let file = &tmpdir.join("file_create_new_error_exists"); @@ -2020,7 +2006,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn mkdir_path_already_exists_error() { let tmpdir = tmpdir(); let dir = &tmpdir.join("mkdir_error_twice"); @@ -2030,7 +2015,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir() { let tmpdir = tmpdir(); let dir = tmpdir.join("d1/d2"); @@ -2039,7 +2023,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir_failure() { let tmpdir = tmpdir(); let dir = tmpdir.join("d1"); @@ -2054,13 +2037,11 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_mkdir_slash() { check!(fs::create_dir_all(&Path::new("/"))); } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_rmdir() { let tmpdir = tmpdir(); let d1 = tmpdir.join("d1"); @@ -2080,7 +2061,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn recursive_rmdir_of_symlink() { // test we do not recursively delete a symlink but only dirs. let tmpdir = tmpdir(); @@ -2114,7 +2094,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn unicode_path_is_dir() { assert!(Path::new(".").is_dir()); assert!(!Path::new("test/stdtest/fs.rs").is_dir()); @@ -2134,7 +2113,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn unicode_path_exists() { assert!(Path::new(".").exists()); assert!(!Path::new("test/nonexistent-bogus-path").exists()); @@ -2148,7 +2126,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_does_not_exist() { let from = Path::new("test/nonexistent-bogus-path"); let to = Path::new("test/other-bogus-path"); @@ -2163,7 +2140,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_src_does_not_exist() { let tmpdir = tmpdir(); let from = Path::new("test/nonexistent-bogus-path"); @@ -2177,7 +2153,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_ok() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2194,7 +2169,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_dst_dir() { let tmpdir = tmpdir(); let out = tmpdir.join("out"); @@ -2206,7 +2180,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_dst_exists() { let tmpdir = tmpdir(); let input = tmpdir.join("in"); @@ -2222,7 +2195,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_src_dir() { let tmpdir = tmpdir(); let out = tmpdir.join("out"); @@ -2234,7 +2206,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn copy_file_preserves_perm_bits() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2263,7 +2234,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn symlinks_work() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2282,7 +2252,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn symlink_noexist() { // Symlinks can point to things that don't exist let tmpdir = tmpdir(); @@ -2296,7 +2265,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn read_link() { if cfg!(windows) { // directory symlink @@ -2317,7 +2285,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn readlink_not_symlink() { let tmpdir = tmpdir(); match fs::read_link(tmpdir.path()) { @@ -2327,7 +2294,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn links_work() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -2356,7 +2322,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn chmod_works() { let tmpdir = tmpdir(); let file = tmpdir.join("in.txt"); @@ -2380,7 +2345,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn sync_doesnt_kill_anything() { let tmpdir = tmpdir(); let path = tmpdir.join("in.txt"); @@ -2394,7 +2358,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn truncate_works() { let tmpdir = tmpdir(); let path = tmpdir.join("in.txt"); @@ -2429,7 +2392,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn open_flavors() { use fs::OpenOptions as OO; fn c(t: &T) -> T { t.clone() } @@ -2549,7 +2511,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn binary_file() { let mut bytes = [0; 1024]; StdRng::new().unwrap().fill_bytes(&mut bytes); @@ -2563,7 +2524,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn file_try_clone() { let tmpdir = tmpdir(); @@ -2586,7 +2546,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] #[cfg(not(windows))] fn unlink_readonly() { let tmpdir = tmpdir(); @@ -2599,7 +2558,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn mkdir_trailing_slash() { let tmpdir = tmpdir(); let path = tmpdir.join("file"); @@ -2607,7 +2565,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn canonicalize_works_simple() { let tmpdir = tmpdir(); let tmpdir = fs::canonicalize(tmpdir.path()).unwrap(); @@ -2617,7 +2574,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn realpath_works() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2643,7 +2599,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn realpath_works_tricky() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { return }; @@ -2673,7 +2628,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn dir_entry_methods() { let tmpdir = tmpdir(); @@ -2708,14 +2662,12 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn read_dir_not_found() { let res = fs::read_dir("/path/that/does/not/exist"); assert_eq!(res.err().unwrap().kind(), ErrorKind::NotFound); } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn create_dir_all_with_junctions() { let tmpdir = tmpdir(); let target = tmpdir.join("target"); @@ -2743,7 +2695,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn metadata_access_times() { let tmpdir = tmpdir(); diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index a77d83a23ce73..58daa7dbf8dc4 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -533,7 +533,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str_u16() { let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 24352); assert_eq!(Ok(vec![a]), tsa(("77.88.21.11", 24352))); @@ -546,7 +545,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str() { let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 24352); assert_eq!(Ok(vec![a]), tsa("77.88.21.11:24352")); @@ -561,7 +559,6 @@ mod tests { // FIXME: figure out why this fails on openbsd and bitrig and fix it #[test] #[cfg(not(any(windows, target_os = "openbsd", target_os = "bitrig")))] - #[cfg_attr(target_os = "emscripten", ignore)] fn to_socket_addr_str_bad() { assert!(tsa("1200::AB00:1234::2552:7777:1313:34300").is_err()); } diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index 2ff9ffe6d0810..8d80f942ff75c 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -146,7 +146,7 @@ impl Drop for Queue { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use sync::mpsc::channel; use super::{Queue, Data, Empty, Inconsistent}; @@ -161,7 +161,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test() { let nthreads = 8; let nmsgs = 1000; diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index cb9577f155ea1..5858e4b6ddb1f 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -231,7 +231,7 @@ impl Drop for Queue { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use sync::Arc; use super::Queue; @@ -305,7 +305,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stress() { unsafe { stress_bound(0); diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 07d60f0610f8c..812724c7a167e 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -352,7 +352,7 @@ pub fn guard_poison<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a poison::Fla &guard.__lock.poison } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use sync::mpsc::channel; use sync::{Arc, Mutex, Condvar}; @@ -375,7 +375,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn lots_and_lots() { const J: u32 = 1000; const K: u32 = 3; @@ -436,7 +435,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_into_inner_poison() { let m = Arc::new(Mutex::new(NonCopy(10))); let m2 = m.clone(); @@ -460,7 +458,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_get_mut_poison() { let m = Arc::new(Mutex::new(NonCopy(10))); let m2 = m.clone(); @@ -477,7 +474,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_condvar() { let packet = Packet(Arc::new((Mutex::new(false), Condvar::new()))); let packet2 = Packet(packet.0.clone()); @@ -501,7 +497,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_arc_condvar_poison() { let packet = Packet(Arc::new((Mutex::new(1), Condvar::new()))); let packet2 = Packet(packet.0.clone()); @@ -531,7 +526,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_poison() { let arc = Arc::new(Mutex::new(1)); assert!(!arc.is_poisoned()); @@ -545,7 +539,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_nested() { // Tests nested mutexes and access // to underlying data. @@ -562,7 +555,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_mutex_arc_access_in_unwind() { let arc = Arc::new(Mutex::new(1)); let arc2 = arc.clone(); diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 64c3e2bb42f49..ad9d0b3754422 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -367,7 +367,7 @@ impl OnceState { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use panic; use sync::mpsc::channel; @@ -385,7 +385,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn stampede_once() { static O: Once = Once::new(); static mut run: bool = false; @@ -448,7 +447,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn wait_for_force_to_finish() { static O: Once = Once::new(); diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index cb46b694f37e5..48ecae185f95c 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -380,7 +380,7 @@ impl<'a, T: ?Sized> Drop for RwLockWriteGuard<'a, T> { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { #![allow(deprecated)] // rand @@ -403,7 +403,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn frob() { const N: usize = 10; const M: usize = 1000; @@ -431,7 +430,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_poison_wr() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -443,7 +441,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_poison_ww() { let arc = Arc::new(RwLock::new(1)); assert!(!arc.is_poisoned()); @@ -457,7 +454,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_no_poison_rr() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -469,7 +465,6 @@ mod tests { assert_eq!(*lock, 1); } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_no_poison_rw() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -482,7 +477,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc() { let arc = Arc::new(RwLock::new(0)); let arc2 = arc.clone(); @@ -521,7 +515,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_rw_arc_access_in_unwind() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); @@ -594,7 +587,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_into_inner_poison() { let m = Arc::new(RwLock::new(NonCopy(10))); let m2 = m.clone(); @@ -618,7 +610,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_get_mut_poison() { let m = Arc::new(RwLock::new(NonCopy(10))); let m2 = m.clone(); diff --git a/src/libstd/sys/common/io.rs b/src/libstd/sys/common/io.rs index 2778ed9326c07..47cec4ef5c276 100644 --- a/src/libstd/sys/common/io.rs +++ b/src/libstd/sys/common/io.rs @@ -50,7 +50,7 @@ pub unsafe fn read_to_end_uninitialized(r: &mut Read, buf: &mut Vec) -> io:: } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] pub mod test { use path::{Path, PathBuf}; use env; diff --git a/src/libstd/sys/common/remutex.rs b/src/libstd/sys/common/remutex.rs index 4935afe6afc42..4d0407ccf6c89 100644 --- a/src/libstd/sys/common/remutex.rs +++ b/src/libstd/sys/common/remutex.rs @@ -156,7 +156,7 @@ impl<'a, T> Drop for ReentrantMutexGuard<'a, T> { } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; use cell::RefCell; @@ -181,7 +181,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn is_mutex() { let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); let m2 = m.clone(); @@ -199,7 +198,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn trylock_works() { let m = Arc::new(ReentrantMutex::new(())); let m2 = m.clone(); @@ -220,7 +218,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn poison_works() { let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); let mc = m.clone(); diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 8224696db2f8d..40fe24cf10e28 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -786,7 +786,7 @@ impl IntoRawFd for UnixDatagram { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod test { use thread; use io; @@ -806,7 +806,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn basic() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -835,7 +834,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn pair() { let msg1 = b"hello"; let msg2 = b"world!"; @@ -859,7 +857,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn try_clone() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -886,7 +883,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn iter() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -909,7 +905,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn long_path() { let dir = tmpdir(); let socket_path = dir.path() @@ -935,7 +930,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn timeouts() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -963,7 +957,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_timeout() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -979,7 +972,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_read_with_timeout() { let dir = tmpdir(); let socket_path = dir.path().join("sock"); @@ -1001,7 +993,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1018,7 +1009,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_unnamed_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1036,7 +1026,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_connect_unix_datagram() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1063,7 +1052,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_unix_datagram_recv() { let dir = tmpdir(); let path1 = dir.path().join("sock1"); @@ -1081,7 +1069,6 @@ mod test { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn datagram_pair() { let msg1 = b"hello"; let msg2 = b"world!"; diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 59748b47d8157..a333a7d967d24 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -524,7 +524,7 @@ pub mod os { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use sync::mpsc::{channel, Sender}; use cell::{Cell, UnsafeCell}; @@ -541,7 +541,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_no_dtor() { thread_local!(static FOO: Cell = Cell::new(1)); @@ -564,7 +563,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn states() { struct Foo; impl Drop for Foo { @@ -588,7 +586,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn smoke_dtor() { thread_local!(static FOO: UnsafeCell> = UnsafeCell::new(None)); @@ -603,7 +600,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn circular() { struct S1; struct S2; @@ -644,7 +640,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn self_referential() { struct S1; thread_local!(static K1: UnsafeCell> = UnsafeCell::new(None)); @@ -666,7 +661,6 @@ mod tests { // test on OSX. #[test] #[cfg_attr(target_os = "macos", ignore)] - #[cfg_attr(target_os = "emscripten", ignore)] fn dtors_in_dtors_in_dtors() { struct S1(Sender<()>); thread_local!(static K1: UnsafeCell> = UnsafeCell::new(None)); diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index b42a0fa3ac130..775dfababc680 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -741,7 +741,7 @@ fn _assert_sync_and_send() { // Tests //////////////////////////////////////////////////////////////////////////////// -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use any::Any; use sync::mpsc::{channel, Sender}; @@ -755,7 +755,6 @@ mod tests { // !!! instead of exiting cleanly. This might wedge the buildbots. !!! #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_unnamed_thread() { thread::spawn(move|| { assert!(thread::current().name().is_none()); @@ -763,7 +762,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_named_thread() { Builder::new().name("ada lovelace".to_string()).spawn(move|| { assert!(thread::current().name().unwrap() == "ada lovelace".to_string()); @@ -772,13 +770,11 @@ mod tests { #[test] #[should_panic] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_invalid_named_thread() { let _ = Builder::new().name("ada l\0velace".to_string()).spawn(|| {}); } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_run_basic() { let (tx, rx) = channel(); thread::spawn(move|| { @@ -788,7 +784,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_join_panic() { match thread::spawn(move|| { panic!() @@ -799,7 +794,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_spawn_sched() { let (tx, rx) = channel(); @@ -819,7 +813,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_spawn_sched_childs_on_default_sched() { let (tx, rx) = channel(); @@ -848,7 +841,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_spawn() { avoid_copying_the_body(|v| { thread::spawn(move || v()); @@ -856,7 +848,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_thread_spawn() { avoid_copying_the_body(|f| { thread::spawn(move|| { @@ -866,7 +857,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_avoid_copying_the_body_join() { avoid_copying_the_body(|f| { let _ = thread::spawn(move|| { @@ -876,7 +866,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_child_doesnt_ref_parent() { // If the child refcounts the parent thread, this will stack overflow when // climbing the thread tree to dereference each ancestor. (See #1789) @@ -894,13 +883,11 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_simple_newsched_spawn() { thread::spawn(move || {}); } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_static_str() { match thread::spawn(move|| { panic!("static string"); @@ -915,7 +902,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_owned_str() { match thread::spawn(move|| { panic!("owned string".to_string()); @@ -930,7 +916,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_any() { match thread::spawn(move|| { panic!(box 413u16 as Box); @@ -947,7 +932,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_try_panic_message_unit_struct() { struct Juju; @@ -960,7 +944,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_before() { for _ in 0..10 { thread::current().unpark(); @@ -969,7 +952,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_not_called() { for _ in 0..10 { thread::park_timeout(Duration::from_millis(10)); @@ -977,7 +959,6 @@ mod tests { } #[test] - #[cfg_attr(target_os = "emscripten", ignore)] fn test_park_timeout_unpark_called_other_thread() { for _ in 0..10 { let th = thread::current(); From 834bbab11b5b9535cbbec8b02149157fff764bf1 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 23 Sep 2016 01:25:51 +0000 Subject: [PATCH 21/27] rustbuild: Only build 'dist' when building the host Doing this step for the target results in the build system trying to build rustc for asmjs, which doesn't work. --- src/bootstrap/step.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index 4b5a26d205af7..8a96cd1b4d239 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -418,7 +418,6 @@ impl<'a> Step<'a> { self.check_crate_std(compiler), self.check_crate_test(compiler), self.check_debuginfo(compiler), - self.dist(stage), ]; // If we're testing the build triple, then we know we can @@ -463,6 +462,9 @@ impl<'a> Step<'a> { // misc self.check_linkcheck(stage), self.check_tidy(stage), + + // can we make the distributables? + self.dist(stage), ]); } return base From d997a6291f42c9315f9ddd8d4044e8910ced8745 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 25 Sep 2016 20:47:00 +0000 Subject: [PATCH 22/27] Call emcc with ERROR_ON_UNDEFINED_SYMBOLS --- src/libcoretest/num/flt2dec/estimator.rs | 7 +++++-- .../target/asmjs_unknown_emscripten.rs | 1 + .../target/wasm32_unknown_emscripten.rs | 3 ++- src/libstd/sys/unix/process.rs | 5 ++--- src/libstd/sys/unix/thread.rs | 18 ++++++++++++++++-- src/test/run-pass/format-no-std.rs | 2 ++ 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/libcoretest/num/flt2dec/estimator.rs b/src/libcoretest/num/flt2dec/estimator.rs index e20881fd3296b..0bca616ea9abc 100644 --- a/src/libcoretest/num/flt2dec/estimator.rs +++ b/src/libcoretest/num/flt2dec/estimator.rs @@ -8,11 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// FIXME https://github.com/kripken/emscripten/issues/4563 +// NB we have to actually not compile this test to avoid +// an undefined symbol error +#![cfg(not(target_os = "emscripten"))] + use core::num::flt2dec::estimator::*; #[test] -// FIXME https://github.com/kripken/emscripten/issues/4563 -#[cfg_attr(target_os = "emscripten", ignore)] fn test_estimate_scaling_factor() { macro_rules! assert_almost_eq { ($actual:expr, $expected:expr) => ({ diff --git a/src/librustc_back/target/asmjs_unknown_emscripten.rs b/src/librustc_back/target/asmjs_unknown_emscripten.rs index 9ccfdbb129c73..667f7cf2c214a 100644 --- a/src/librustc_back/target/asmjs_unknown_emscripten.rs +++ b/src/librustc_back/target/asmjs_unknown_emscripten.rs @@ -22,6 +22,7 @@ pub fn target() -> Result { allow_asm: false, obj_is_bitcode: true, max_atomic_width: 32, + post_link_args: vec!["-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()], .. Default::default() }; Ok(Target { diff --git a/src/librustc_back/target/wasm32_unknown_emscripten.rs b/src/librustc_back/target/wasm32_unknown_emscripten.rs index 412fb868086c5..2923f2eb92e45 100644 --- a/src/librustc_back/target/wasm32_unknown_emscripten.rs +++ b/src/librustc_back/target/wasm32_unknown_emscripten.rs @@ -24,7 +24,8 @@ pub fn target() -> Result { allow_asm: false, obj_is_bitcode: true, max_atomic_width: 32, - post_link_args: vec!["-s".to_string(), "BINARYEN=1".to_string()], + post_link_args: vec!["-s".to_string(), "BINARYEN=1".to_string(), + "-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()], .. Default::default() }; Ok(Target { diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 85aba4b9b156b..dafc11d9cc8e9 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -369,7 +369,7 @@ impl Command { } // NaCl has no signal support. - if cfg!(not(target_os = "nacl")) { + if cfg!(not(any(target_os = "nacl", target_os = "emscripten"))) { // Reset signal handling so the child process starts in a // standardized state. libstd ignores SIGPIPE, and signal-handling // libraries often set a mask. Child processes inherit ignored @@ -589,7 +589,7 @@ impl Process { } } -#[cfg(test)] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests { use super::*; @@ -630,7 +630,6 @@ mod tests { #[test] #[cfg_attr(target_os = "macos", ignore)] #[cfg_attr(target_os = "nacl", ignore)] // no signals on NaCl. - #[cfg_attr(target_os = "emscripten", ignore)] fn test_process_mask() { unsafe { // Test to make sure that a signal mask does not get inherited. diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 980ef01f549c3..1e879117f73ab 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -29,6 +29,20 @@ pub struct Thread { unsafe impl Send for Thread {} unsafe impl Sync for Thread {} +// The pthread_attr_setstacksize symbol doesn't exist in the emscripten libc, +// so we have to not link to it to satisfy emcc's ERROR_ON_UNDEFINED_SYMBOLS. +#[cfg(not(target_os = "emscripten"))] +unsafe fn pthread_attr_setstacksize(attr: *mut libc::pthread_attr_t, + stack_size: libc::size_t) -> libc::c_int { + libc::pthread_attr_setstacksize(attr, stack_size) +} + +#[cfg(target_os = "emscripten")] +unsafe fn pthread_attr_setstacksize(_attr: *mut libc::pthread_attr_t, + _stack_size: libc::size_t) -> libc::c_int { + panic!() +} + impl Thread { pub unsafe fn new<'a>(stack: usize, p: Box) -> io::Result { @@ -38,8 +52,8 @@ impl Thread { assert_eq!(libc::pthread_attr_init(&mut attr), 0); let stack_size = cmp::max(stack, min_stack_size(&attr)); - match libc::pthread_attr_setstacksize(&mut attr, - stack_size as libc::size_t) { + match pthread_attr_setstacksize(&mut attr, + stack_size as libc::size_t) { 0 => {} n => { assert_eq!(n, libc::EINVAL); diff --git a/src/test/run-pass/format-no-std.rs b/src/test/run-pass/format-no-std.rs index 62d54da56b2ec..1b9b4ab32ca40 100644 --- a/src/test/run-pass/format-no-std.rs +++ b/src/test/run-pass/format-no-std.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten missing rust_begin_unwind + #![feature(lang_items, start, collections)] #![no_std] From 21b987ea089c08627016bca7074960a1ba77ae6d Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 27 Sep 2016 21:07:17 +0000 Subject: [PATCH 23/27] Unignore some working emscripten tests --- src/test/run-fail/run-unexported-tests.rs | 1 - src/test/run-pass/issue-16597.rs | 1 - src/test/run-pass/issue-20823.rs | 1 - src/test/run-pass/issue-29663.rs | 1 - src/test/run-pass/packed-struct-vec.rs | 1 - .../test-fn-signature-verification-for-explicit-return-type.rs | 1 - src/test/run-pass/test-should-fail-good-message.rs | 1 - 7 files changed, 7 deletions(-) diff --git a/src/test/run-fail/run-unexported-tests.rs b/src/test/run-fail/run-unexported-tests.rs index bc7b3540d1e99..8158333ade818 100644 --- a/src/test/run-fail/run-unexported-tests.rs +++ b/src/test/run-fail/run-unexported-tests.rs @@ -12,7 +12,6 @@ // compile-flags:--test // check-stdout // ignore-pretty: does not work well with `--test` -// ignore-emscripten Needs threads. mod m { pub fn exported() {} diff --git a/src/test/run-pass/issue-16597.rs b/src/test/run-pass/issue-16597.rs index 77c4554522158..7f0a341f14715 100644 --- a/src/test/run-pass/issue-16597.rs +++ b/src/test/run-pass/issue-16597.rs @@ -10,7 +10,6 @@ // compile-flags:--test // ignore-pretty turns out the pretty-printer doesn't handle gensym'd things... -// ignore-emscripten mod tests { use super::*; diff --git a/src/test/run-pass/issue-20823.rs b/src/test/run-pass/issue-20823.rs index aa5d0151446de..c297998b6493a 100644 --- a/src/test/run-pass/issue-20823.rs +++ b/src/test/run-pass/issue-20823.rs @@ -10,7 +10,6 @@ // compile-flags: --test // no-pretty-expanded -// ignore-emscripten #![deny(unstable)] diff --git a/src/test/run-pass/issue-29663.rs b/src/test/run-pass/issue-29663.rs index 88958744fe916..9a77be049feeb 100644 --- a/src/test/run-pass/issue-29663.rs +++ b/src/test/run-pass/issue-29663.rs @@ -9,7 +9,6 @@ // except according to those terms. // write_volatile causes an LLVM assert with composite types -// ignore-emscripten write_volatile doesn't work on arrays of structs? #![feature(volatile)] use std::ptr::{read_volatile, write_volatile}; diff --git a/src/test/run-pass/packed-struct-vec.rs b/src/test/run-pass/packed-struct-vec.rs index 9873f23137b4c..4b32b881be738 100644 --- a/src/test/run-pass/packed-struct-vec.rs +++ b/src/test/run-pass/packed-struct-vec.rs @@ -7,7 +7,6 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-emscripten Right side of comparison is screwed up. No idea how. use std::mem; diff --git a/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs b/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs index b5f303b8760fb..d58b5d3a00fec 100644 --- a/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs +++ b/src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs @@ -7,7 +7,6 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-emscripten needs threads? #![feature(test)] diff --git a/src/test/run-pass/test-should-fail-good-message.rs b/src/test/run-pass/test-should-fail-good-message.rs index 95378df41c680..28698499303a9 100644 --- a/src/test/run-pass/test-should-fail-good-message.rs +++ b/src/test/run-pass/test-should-fail-good-message.rs @@ -10,7 +10,6 @@ // compile-flags: --test // ignore-pretty: does not work well with `--test` -// ignore-emscripten needs threads? #[test] #[should_panic(expected = "foo")] From badfd6200ba199f7535a4e59e7802317951ec9cc Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 27 Sep 2016 19:56:50 +0000 Subject: [PATCH 24/27] Cleanup bootstrap --- src/bootstrap/check.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 95c909aef773c..b8417218a2231 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -391,18 +391,18 @@ fn krate_emscripten(build: &Build, let test_file_name = test.to_string_lossy().into_owned(); println!("running {}", test_file_name); let nodejs = build.config.nodejs.as_ref().expect("nodejs not configured"); - let output = Command::new(nodejs) + let status = Command::new(nodejs) .arg(&test_file_name) .stderr(::std::process::Stdio::inherit()) - .output(); - let output = match output { - Ok(status) => status, + .status(); + match status { + Ok(status) => { + if !status.success() { + panic!("some tests failed"); + } + } Err(e) => panic!(format!("failed to execute command: {}", e)), }; - println!("{}", String::from_utf8(output.stdout).unwrap()); - if !output.status.success() { - panic!("some tests failed"); - } } } From 3c038c0505a5f937aba9a4c3208fe8e0aebdd370 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 27 Sep 2016 21:25:52 +0000 Subject: [PATCH 25/27] Document emscripten's unwind impl and remove unused function --- src/libpanic_unwind/emcc.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libpanic_unwind/emcc.rs b/src/libpanic_unwind/emcc.rs index 598f99ba27bf1..b3ab1117674ca 100644 --- a/src/libpanic_unwind/emcc.rs +++ b/src/libpanic_unwind/emcc.rs @@ -8,6 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +//! Unwinding for emscripten +//! +//! Whereas Rust's usual unwinding implementation for Unix platforms +//! calls into the libunwind APIs directly, on emscripten we instead +//! call into the C++ unwinding APIs. This is just an expedience since +//! emscripten's runtime always implements those APIs and does not +//! implement libunwind. + #![allow(private_no_mangle_fns)] use core::any::Any; @@ -55,12 +63,6 @@ unsafe extern "C" fn rust_eh_personality(version: c_int, context) } -#[lang = "eh_unwind_resume"] -#[unwind] -unsafe extern "C" fn rust_eh_unwind_resume(panic_ctx: *mut u8) -> ! { - uw::_Unwind_Resume(panic_ctx as *mut uw::_Unwind_Exception); -} - extern { fn __cxa_allocate_exception(thrown_size: libc::size_t) -> *mut libc::c_void; fn __cxa_free_exception(thrown_exception: *mut libc::c_void); From 4f5e73be1bf439a9881600ad4cdfd5865391eaef Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 27 Sep 2016 21:27:22 +0000 Subject: [PATCH 26/27] Build a dummy alloc_jemalloc crate on platforms that don't support it This is a hack to support building targets that don't support jemalloc alongside hosts that do. The jemalloc build is controlled by a feature of the std crate, and if that feature changes between targets, it invalidates the fingerprint of std's build script (this is a cargo bug); so we must ensure that the feature set used by std is the same across all targets, which means we have to build the alloc_jemalloc crate for targets like emscripten, even if we don't use it. --- src/bootstrap/sanity.rs | 17 +-- src/liballoc_jemalloc/build.rs | 18 +++ src/liballoc_jemalloc/lib.rs | 262 +++++++++++++++++++-------------- 3 files changed, 180 insertions(+), 117 deletions(-) diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index 962d0666f69f1..9429af565258b 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -104,6 +104,14 @@ pub fn check(build: &mut Build) { need_cmd(build.cxx(host).as_ref()); } + // The msvc hosts don't use jemalloc, turn it off globally to + // avoid packaging the dummy liballoc_jemalloc on that platform. + for host in build.config.host.iter() { + if host.contains("msvc") { + build.config.use_jemalloc = false; + } + } + // Externally configured LLVM requires FileCheck to exist let filecheck = build.llvm_filecheck(&build.config.build); if !filecheck.starts_with(&build.out) && !filecheck.exists() && build.config.codegen_tests { @@ -111,15 +119,6 @@ pub fn check(build: &mut Build) { } for target in build.config.target.iter() { - // Either can't build or don't want to run jemalloc on these targets - if target.contains("rumprun") || - target.contains("bitrig") || - target.contains("openbsd") || - target.contains("msvc") || - target.contains("emscripten") { - build.config.use_jemalloc = false; - } - // Can't compile for iOS unless we're on OSX if target.contains("apple-ios") && !build.config.build.contains("apple-darwin") { diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs index 8b31c5a557747..028d742cc832e 100644 --- a/src/liballoc_jemalloc/build.rs +++ b/src/liballoc_jemalloc/build.rs @@ -27,6 +27,24 @@ fn main() { let build_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); let src_dir = env::current_dir().unwrap(); + // FIXME: This is a hack to support building targets that don't + // support jemalloc alongside hosts that do. The jemalloc build is + // controlled by a feature of the std crate, and if that feature + // changes between targets, it invalidates the fingerprint of + // std's build script (this is a cargo bug); so we must ensure + // that the feature set used by std is the same across all + // targets, which means we have to build the alloc_jemalloc crate + // for targets like emscripten, even if we don't use it. + if target.contains("rumprun") || + target.contains("bitrig") || + target.contains("openbsd") || + target.contains("msvc") || + target.contains("emscripten") + { + println!("cargo:rustc-cfg=dummy_jemalloc"); + return; + } + if let Some(jemalloc) = env::var_os("JEMALLOC_OVERRIDE") { let jemalloc = PathBuf::from(jemalloc); println!("cargo:rustc-link-search=native={}", diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index 5bbf1c35e0dd4..21e45f9c4b20c 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -23,124 +23,170 @@ extern crate libc; -use libc::{c_int, c_void, size_t}; +pub use imp::*; -// Linkage directives to pull in jemalloc and its dependencies. -// -// On some platforms we need to be sure to link in `pthread` which jemalloc -// depends on, and specifically on android we need to also link to libgcc. -// Currently jemalloc is compiled with gcc which will generate calls to -// intrinsics that are libgcc specific (e.g. those intrinsics aren't present in -// libcompiler-rt), so link that in to get that support. -#[link(name = "jemalloc", kind = "static")] -#[cfg_attr(target_os = "android", link(name = "gcc"))] -#[cfg_attr(all(not(windows), - not(target_os = "android"), - not(target_env = "musl")), - link(name = "pthread"))] -#[cfg(not(cargobuild))] -extern "C" {} - -// Note that the symbols here are prefixed by default on OSX and Windows (we -// don't explicitly request it), and on Android and DragonFly we explicitly -// request it as unprefixing cause segfaults (mismatches in allocators). -extern "C" { - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", - target_os = "dragonfly", target_os = "windows"), - link_name = "je_mallocx")] - fn mallocx(size: size_t, flags: c_int) -> *mut c_void; - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", - target_os = "dragonfly", target_os = "windows"), - link_name = "je_rallocx")] - fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void; - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", - target_os = "dragonfly", target_os = "windows"), - link_name = "je_xallocx")] - fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t; - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", - target_os = "dragonfly", target_os = "windows"), - link_name = "je_sdallocx")] - fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int); - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", - target_os = "dragonfly", target_os = "windows"), - link_name = "je_nallocx")] - fn nallocx(size: size_t, flags: c_int) -> size_t; -} +// See comments in build.rs for why we sometimes build a crate that does nothing +#[cfg(not(dummy_jemalloc))] +mod imp { + use libc::{c_int, c_void, size_t}; -// The minimum alignment guaranteed by the architecture. This value is used to -// add fast paths for low alignment values. In practice, the alignment is a -// constant at the call site and the branch will be optimized out. -#[cfg(all(any(target_arch = "arm", - target_arch = "mips", - target_arch = "powerpc")))] -const MIN_ALIGN: usize = 8; -#[cfg(all(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "s390x")))] -const MIN_ALIGN: usize = 16; - -// MALLOCX_ALIGN(a) macro -fn mallocx_align(a: usize) -> c_int { - a.trailing_zeros() as c_int -} + // Linkage directives to pull in jemalloc and its dependencies. + // + // On some platforms we need to be sure to link in `pthread` which jemalloc + // depends on, and specifically on android we need to also link to libgcc. + // Currently jemalloc is compiled with gcc which will generate calls to + // intrinsics that are libgcc specific (e.g. those intrinsics aren't present in + // libcompiler-rt), so link that in to get that support. + #[link(name = "jemalloc", kind = "static")] + #[cfg_attr(target_os = "android", link(name = "gcc"))] + #[cfg_attr(all(not(windows), + not(target_os = "android"), + not(target_env = "musl")), + link(name = "pthread"))] + #[cfg(not(cargobuild))] + extern "C" {} + + // Note that the symbols here are prefixed by default on OSX and Windows (we + // don't explicitly request it), and on Android and DragonFly we explicitly + // request it as unprefixing cause segfaults (mismatches in allocators). + extern "C" { + #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", + target_os = "dragonfly", target_os = "windows"), + link_name = "je_mallocx")] + fn mallocx(size: size_t, flags: c_int) -> *mut c_void; + #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", + target_os = "dragonfly", target_os = "windows"), + link_name = "je_rallocx")] + fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void; + #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", + target_os = "dragonfly", target_os = "windows"), + link_name = "je_xallocx")] + fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t; + #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", + target_os = "dragonfly", target_os = "windows"), + link_name = "je_sdallocx")] + fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int); + #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", + target_os = "dragonfly", target_os = "windows"), + link_name = "je_nallocx")] + fn nallocx(size: size_t, flags: c_int) -> size_t; + } + + // The minimum alignment guaranteed by the architecture. This value is used to + // add fast paths for low alignment values. In practice, the alignment is a + // constant at the call site and the branch will be optimized out. + #[cfg(all(any(target_arch = "arm", + target_arch = "mips", + target_arch = "powerpc")))] + const MIN_ALIGN: usize = 8; + #[cfg(all(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x")))] + const MIN_ALIGN: usize = 16; + + // MALLOCX_ALIGN(a) macro + fn mallocx_align(a: usize) -> c_int { + a.trailing_zeros() as c_int + } + + fn align_to_flags(align: usize) -> c_int { + if align <= MIN_ALIGN { + 0 + } else { + mallocx_align(align) + } + } + + #[no_mangle] + pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 { + let flags = align_to_flags(align); + unsafe { mallocx(size as size_t, flags) as *mut u8 } + } + + #[no_mangle] + pub extern "C" fn __rust_reallocate(ptr: *mut u8, + _old_size: usize, + size: usize, + align: usize) + -> *mut u8 { + let flags = align_to_flags(align); + unsafe { rallocx(ptr as *mut c_void, size as size_t, flags) as *mut u8 } + } + + #[no_mangle] + pub extern "C" fn __rust_reallocate_inplace(ptr: *mut u8, + _old_size: usize, + size: usize, + align: usize) + -> usize { + let flags = align_to_flags(align); + unsafe { xallocx(ptr as *mut c_void, size as size_t, 0, flags) as usize } + } -fn align_to_flags(align: usize) -> c_int { - if align <= MIN_ALIGN { + #[no_mangle] + pub extern "C" fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) { + let flags = align_to_flags(align); + unsafe { sdallocx(ptr as *mut c_void, old_size as size_t, flags) } + } + + #[no_mangle] + pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize { + let flags = align_to_flags(align); + unsafe { nallocx(size as size_t, flags) as usize } + } + + // These symbols are used by jemalloc on android but the really old android + // we're building on doesn't have them defined, so just make sure the symbols + // are available. + #[no_mangle] + #[cfg(target_os = "android")] + pub extern "C" fn pthread_atfork(_prefork: *mut u8, + _postfork_parent: *mut u8, + _postfork_child: *mut u8) + -> i32 { 0 - } else { - mallocx_align(align) } } -#[no_mangle] -pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 { - let flags = align_to_flags(align); - unsafe { mallocx(size as size_t, flags) as *mut u8 } -} +#[cfg(dummy_jemalloc)] +mod imp { + fn bogus() -> ! { + panic!("jemalloc is not implemented for this platform"); + } -#[no_mangle] -pub extern "C" fn __rust_reallocate(ptr: *mut u8, - _old_size: usize, - size: usize, - align: usize) - -> *mut u8 { - let flags = align_to_flags(align); - unsafe { rallocx(ptr as *mut c_void, size as size_t, flags) as *mut u8 } -} + #[no_mangle] + pub extern "C" fn __rust_allocate(_size: usize, _align: usize) -> *mut u8 { + bogus() + } -#[no_mangle] -pub extern "C" fn __rust_reallocate_inplace(ptr: *mut u8, - _old_size: usize, - size: usize, - align: usize) - -> usize { - let flags = align_to_flags(align); - unsafe { xallocx(ptr as *mut c_void, size as size_t, 0, flags) as usize } -} + #[no_mangle] + pub extern "C" fn __rust_reallocate(_ptr: *mut u8, + _old_size: usize, + _size: usize, + _align: usize) + -> *mut u8 { + bogus() + } -#[no_mangle] -pub extern "C" fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) { - let flags = align_to_flags(align); - unsafe { sdallocx(ptr as *mut c_void, old_size as size_t, flags) } -} + #[no_mangle] + pub extern "C" fn __rust_reallocate_inplace(_ptr: *mut u8, + _old_size: usize, + _size: usize, + _align: usize) + -> usize { + bogus() + } -#[no_mangle] -pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize { - let flags = align_to_flags(align); - unsafe { nallocx(size as size_t, flags) as usize } -} + #[no_mangle] + pub extern "C" fn __rust_deallocate(_ptr: *mut u8, _old_size: usize, _align: usize) { + bogus() + } -// These symbols are used by jemalloc on android but the really old android -// we're building on doesn't have them defined, so just make sure the symbols -// are available. -#[no_mangle] -#[cfg(target_os = "android")] -pub extern "C" fn pthread_atfork(_prefork: *mut u8, - _postfork_parent: *mut u8, - _postfork_child: *mut u8) - -> i32 { - 0 + #[no_mangle] + pub extern "C" fn __rust_usable_size(_size: usize, _align: usize) -> usize { + bogus() + } } From afa72b5dd6b75ed4577a4e73c1525dcd58d93b51 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 28 Sep 2016 16:08:59 +0000 Subject: [PATCH 27/27] Don't build any native compiler-builtin components for emscripten --- src/bootstrap/sanity.rs | 7 +++++++ src/libcompiler_builtins/build.rs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index 9429af565258b..c4e6399c2c36d 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -95,6 +95,13 @@ pub fn check(build: &mut Build) { // We're gonna build some custom C code here and there, host triples // also build some C++ shims for LLVM so we need a C++ compiler. for target in build.config.target.iter() { + // On emscripten we don't actually need the C compiler to just + // build the target artifacts, only for testing. For the sake + // of easier bot configuration, just skip detection. + if target.contains("emscripten") { + continue; + } + need_cmd(build.cc(target).as_ref()); if let Some(ar) = build.ar(target) { need_cmd(ar.as_ref()); diff --git a/src/libcompiler_builtins/build.rs b/src/libcompiler_builtins/build.rs index 66c683333b985..acbd39bb1630c 100644 --- a/src/libcompiler_builtins/build.rs +++ b/src/libcompiler_builtins/build.rs @@ -73,6 +73,12 @@ impl Sources { fn main() { let target = env::var("TARGET").expect("TARGET was not set"); + + // Emscripten's runtime includes all the builtins + if target.contains("emscripten") { + return; + } + let cfg = &mut gcc::Config::new(); if target.contains("msvc") {