Skip to content

Commit 71340ca

Browse files
committed
Auto merge of #46291 - alexcrichton:wasm-tests, r=kennytm
ci: Start running wasm32 tests on Travis This commit allocates a builder to running wasm32 tests on Travis. Not all test suites pass right now so this is starting out with just the run-pass and the libcore test suites. This'll hopefully give us a pretty broad set of coverage for integration in rustc itself as well as a somewhat broad coverage of the llvm backend itself through integration/unit tests.
2 parents 5a59704 + 73970bf commit 71340ca

23 files changed

+84
-34
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ matrix:
161161
if: branch = auto
162162
- env: IMAGE=i686-gnu-nopt
163163
if: branch = auto
164-
# - env: IMAGE=wasm32 issue 42646
165-
# if: branch = auto
164+
- env: IMAGE=wasm32-unknown
165+
if: branch = auto
166166
- env: IMAGE=x86_64-gnu
167167
if: branch = auto
168168
- env: IMAGE=x86_64-gnu-full-bootstrap

src/bootstrap/check.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,17 @@ impl Step for Crate {
12451245
if target.contains("emscripten") {
12461246
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
12471247
build.config.nodejs.as_ref().expect("nodejs not configured"));
1248+
} else if target.starts_with("wasm32") {
1249+
// On the wasm32-unknown-unknown target we're using LTO which is
1250+
// incompatible with `-C prefer-dynamic`, so disable that here
1251+
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
1252+
1253+
let node = build.config.nodejs.as_ref()
1254+
.expect("nodejs not configured");
1255+
let runner = format!("{} {}/src/etc/wasm32-shim.js",
1256+
node.display(),
1257+
build.src.display());
1258+
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner);
12481259
} else if build.remote_tested(target) {
12491260
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)),
12501261
format!("{} run",
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ubuntu:16.04
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
g++ \
5+
make \
6+
file \
7+
curl \
8+
ca-certificates \
9+
python \
10+
git \
11+
cmake \
12+
sudo \
13+
gdb \
14+
xz-utils
15+
16+
RUN curl -sL https://nodejs.org/dist/v9.2.0/node-v9.2.0-linux-x64.tar.xz | \
17+
tar -xJ
18+
19+
COPY scripts/sccache.sh /scripts/
20+
RUN sh /scripts/sccache.sh
21+
22+
ENV TARGETS=wasm32-unknown-unknown
23+
24+
ENV RUST_CONFIGURE_ARGS \
25+
--target=$TARGETS \
26+
--set build.nodejs=/node-v9.2.0-linux-x64/bin/node
27+
28+
ENV SCRIPT python2.7 /checkout/x.py test --target $TARGETS \
29+
src/test/ui \
30+
src/test/run-pass \
31+
src/test/compile-fail \
32+
src/test/parse-fail \
33+
src/test/mir-opt \
34+
src/test/codegen-units \
35+
src/libcore \
36+
src/libstd_unicode/ \

src/etc/wasm32-shim.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ imports.env = {
4545
exp2f: function(x) { return Math.pow(2, x); },
4646
ldexp: function(x, y) { return x * Math.pow(2, y); },
4747
ldexpf: function(x, y) { return x * Math.pow(2, y); },
48-
log10: function(x) { return Math.log10(x); },
49-
log10f: function(x) { return Math.log10(x); },
48+
log10: Math.log10,
49+
log10f: Math.log10,
5050

5151
// These are called in src/libstd/sys/wasm/stdio.rs and are used when
5252
// debugging is enabled.
@@ -71,14 +71,12 @@ imports.env = {
7171
return process.argv.length - 2;
7272
},
7373
rust_wasm_args_arg_size: function(i) {
74-
return process.argv[i + 2].length;
74+
return Buffer.byteLength(process.argv[i + 2]);
7575
},
7676
rust_wasm_args_arg_fill: function(idx, ptr) {
7777
let arg = process.argv[idx + 2];
7878
let view = new Uint8Array(memory.buffer);
79-
for (var i = 0; i < arg.length; i++) {
80-
view[ptr + i] = arg.charCodeAt(i);
81-
}
79+
Buffer.from(arg).copy(view, ptr);
8280
},
8381

8482
// These are called in src/libstd/sys/wasm/os.rs and are used when
@@ -91,15 +89,13 @@ imports.env = {
9189
if (!(key in process.env)) {
9290
return -1;
9391
}
94-
return process.env[key].length;
92+
return Buffer.byteLength(process.env[key]);
9593
},
9694
rust_wasm_getenv_data: function(a, b, ptr) {
9795
let key = copystr(a, b);
9896
let value = process.env[key];
9997
let view = new Uint8Array(memory.buffer);
100-
for (var i = 0; i < value.length; i++) {
101-
view[ptr + i] = value.charCodeAt(i);
102-
}
98+
Buffer.from(value).copy(view, ptr);
10399
},
104100
};
105101

src/test/compile-fail/auxiliary/issue_5844_aux.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(libc)]
12-
13-
extern crate libc;
14-
1511
extern "C" {
16-
pub fn rand() -> libc::c_int;
12+
pub fn rand() -> u32;
1713
}

src/test/compile-fail/issue-10755.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// compile-flags: -C linker=llllll
11+
// compile-flags: -C linker=llllll -Z linker-flavor=ld
1212
// error-pattern: the linker `llllll`
1313

1414
fn main() {

src/test/compile-fail/lint-ctypes.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ extern {
5252
pub fn fn_type2(p: fn()); //~ ERROR found function pointer with Rust
5353
pub fn fn_contained(p: RustBadRet); //~ ERROR: found struct without
5454

55-
pub fn good1(size: *const libc::c_int);
56-
pub fn good2(size: *const libc::c_uint);
5755
pub fn good3(fptr: Option<extern fn()>);
5856
pub fn good4(aptr: &[u8; 4 as usize]);
5957
pub fn good5(s: StructWithProjection);
@@ -66,5 +64,11 @@ extern {
6664
pub fn good12(size: usize);
6765
}
6866

67+
#[cfg(not(target_arch = "wasm32"))]
68+
extern {
69+
pub fn good1(size: *const libc::c_int);
70+
pub fn good2(size: *const libc::c_uint);
71+
}
72+
6973
fn main() {
7074
}

src/test/compile-fail/lint-dead-code-3.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
#![allow(unused_variables)]
1212
#![allow(non_camel_case_types)]
1313
#![deny(dead_code)]
14-
#![feature(libc)]
1514

1615
#![crate_type="lib"]
1716

18-
extern crate libc;
1917

2018
pub use extern_foo as x;
2119
extern {
@@ -54,14 +52,13 @@ pub fn pub_fn() {
5452
}
5553

5654
mod blah {
57-
use libc::size_t;
5855
// not warned because it's used in the parameter of `free` and return of
5956
// `malloc` below, which are also used.
6057
enum c_void {}
6158

6259
extern {
6360
fn free(p: *const c_void);
64-
fn malloc(size: size_t) -> *const c_void;
61+
fn malloc(size: usize) -> *const c_void;
6562
}
6663

6764
pub fn baz() {

src/test/compile-fail/nolink-with-link-args.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// error-pattern:aFdEfSeVEE
12+
// compile-flags: -Z linker-flavor=ld
1213

1314
/* We're testing that link_args are indeed passed when nolink is specified.
1415
So we try to compile with junk link_args and make sure they are visible in

src/test/compile-fail/non-copyable-void.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-wasm32-bare no libc to test ffi with
12+
1113
#![feature(libc)]
1214

1315
extern crate libc;

src/test/compile-fail/panic-runtime/libtest-unwinds.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// error-pattern:is not compiled with this crate's panic strategy `abort`
1212
// compile-flags:-C panic=abort
13+
// ignore-wasm32-bare compiled with panic=abort by default
1314

1415
#![feature(test)]
1516

src/test/compile-fail/panic-runtime/transitive-link-a-bunch.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// aux-build:wants-panic-runtime-abort.rs
1515
// aux-build:panic-runtime-lang-items.rs
1616
// error-pattern: is not compiled with this crate's panic strategy `unwind`
17+
// ignore-wasm32-bare compiled with panic=abort by default
1718

1819
#![no_std]
1920

src/test/compile-fail/panic-runtime/want-unwind-got-abort.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// error-pattern:is incompatible with this crate's strategy of `unwind`
1212
// aux-build:panic-runtime-abort.rs
1313
// aux-build:panic-runtime-lang-items.rs
14+
// ignore-wasm32-bare compiled with panic=abort by default
1415

1516
#![no_std]
1617

src/test/compile-fail/panic-runtime/want-unwind-got-abort2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// aux-build:panic-runtime-abort.rs
1313
// aux-build:wants-panic-runtime-abort.rs
1414
// aux-build:panic-runtime-lang-items.rs
15+
// ignore-wasm32-bare compiled with panic=abort by default
1516

1617
#![no_std]
1718

src/test/compile-fail/static-mut-foreign-requires-unsafe.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(libc)]
12-
13-
extern crate libc;
14-
1511
extern {
16-
static mut a: libc::c_int;
12+
static mut a: i32;
1713
}
1814

1915
fn main() {

src/test/compile-fail/unsupported-cast.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111
// error-pattern:casting
1212

13-
#![feature(libc)]
14-
15-
extern crate libc;
13+
struct A;
1614

1715
fn main() {
18-
println!("{:?}", 1.0 as *const libc::FILE); // Can't cast float to foreign.
16+
println!("{:?}", 1.0 as *const A); // Can't cast float to foreign.
1917
}

src/test/compile-fail/weak-lang-item.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// aux-build:weak-lang-items.rs
1212
// error-pattern: language item required, but not found: `panic_fmt`
1313
// error-pattern: language item required, but not found: `eh_personality`
14+
// ignore-wasm32-bare compiled with panic=abort, personality not required
1415

1516
#![no_std]
1617

src/test/mir-opt/box_expr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-wasm32-bare compiled with panic=abort by default
12+
1113
#![feature(box_syntax)]
1214

1315
fn main() {

src/test/mir-opt/issue-41110.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-wasm32-bare compiled with panic=abort by default
12+
1113
// check that we don't emit multiple drop flags when they are not needed.
1214

1315
fn main() {

src/test/mir-opt/packed-struct-drop-aligned.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-wasm32-bare compiled with panic=abort by default
12+
1113
fn main() {
1214
let mut x = Packed(Aligned(Droppy(0)));
1315
x.0 = Aligned(Droppy(0));

src/test/run-pass/next-power-of-two-overflow-debug.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// compile-flags: -C debug_assertions=yes
12+
// ignore-wasm32-bare compiled with panic=abort by default
1213

1314
#![feature(i128_type)]
1415

src/test/run-pass/saturating-float-casts.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// Tests saturating float->int casts. See u128-as-f32.rs for the opposite direction.
1212
// compile-flags: -Z saturating-float-casts
13+
// ignore-wasm32-bare FIXME(#46298) needs upstream llvm fixes
1314

1415
#![feature(test, i128, i128_type, stmt_expr_attributes)]
1516
#![deny(overflowing_literals)]

0 commit comments

Comments
 (0)