Skip to content

Commit 5b56c66

Browse files
committed
Fix ABI, run and fix more tests, re-enable CI for PRs
1 parent 9a55103 commit 5b56c66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+202
-131
lines changed

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ impl<'a> Builder<'a> {
970970
Some("-Wl,-rpath,@loader_path/../lib")
971971
} else if !target.contains("windows") &&
972972
!target.contains("wasm32") &&
973+
!target.contains("emscripten") &&
973974
!target.contains("fuchsia") {
974975
Some("-Wl,-rpath,$ORIGIN/../lib")
975976
} else {

src/bootstrap/test.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1046,8 +1046,11 @@ impl Step for Compiletest {
10461046

10471047
// Also provide `rust_test_helpers` for the host.
10481048
builder.ensure(native::TestHelpers { target: compiler.host });
1049-
// As well as the target
1050-
builder.ensure(native::TestHelpers { target });
1049+
1050+
// As well as the target, except for plain wasm32, which can't build it
1051+
if !target.contains("wasm32") || target.contains("emscripten") {
1052+
builder.ensure(native::TestHelpers { target });
1053+
}
10511054

10521055
builder.ensure(RemoteCopyLibs { compiler, target });
10531056

src/ci/azure-pipelines/pr.yml

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
IMAGE: x86_64-gnu-llvm-6.0
2323
mingw-check:
2424
IMAGE: mingw-check
25+
asmjs:
26+
IMAGE: asmjs
27+
wasm32:
28+
IMAGE: wasm32
2529

2630
- job: LinuxTools
2731
timeoutInMinutes: 600

src/ci/docker/asmjs/Dockerfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ ENV EM_CONFIG=/emsdk-portable/.emscripten
2828

2929
ENV TARGETS=asmjs-unknown-emscripten
3030

31-
# TODO: Run run-fail, libcore, libstd, etc. once exceptions are enabled
32-
ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/ui
31+
ENV SCRIPT python2.7 ../x.py test --target $TARGETS
3332

3433
# This is almost identical to the wasm32-unknown-emscripten target, so
3534
# running with assertions again is not useful

src/ci/docker/disabled/wasm32/Dockerfile

+8-2
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@ ENV EM_CONFIG=/emsdk-portable/.emscripten
2828

2929
ENV TARGETS=wasm32-unknown-emscripten
3030

31-
# TODO: Run run-fail, libcore, libstd, etc. once exceptions are enabled
32-
ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/ui
31+
# FIXME: Re-enable these tests once Cargo stops trying to execute wasms
32+
ENV SCRIPT python2.7 ../x.py test --target $TARGETS \
33+
--exclude src/libcore \
34+
--exclude src/liballoc \
35+
--exclude src/libproc_macro \
36+
--exclude src/libstd \
37+
--exclude src/libterm \
38+
--exclude src/libtest

src/liballoc/tests/binary_heap.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
use std::cmp;
21
use std::collections::BinaryHeap;
32
use std::collections::binary_heap::{Drain, PeekMut};
4-
use std::panic::{self, AssertUnwindSafe};
5-
use std::sync::atomic::{AtomicUsize, Ordering};
6-
7-
use rand::{thread_rng, seq::SliceRandom};
83

94
#[test]
105
fn test_iterator() {
@@ -281,9 +276,15 @@ fn assert_covariance() {
281276
// even if the order may not be correct.
282277
//
283278
// Destructors must be called exactly once per element.
279+
// FIXME: re-enable emscripten once it can unwind again
284280
#[test]
285-
#[cfg(not(miri))] // Miri does not support catching panics
281+
#[cfg(not(any(miri, target_os = "emscripten")))] // Miri does not support catching panics
286282
fn panic_safe() {
283+
use std::cmp;
284+
use std::panic::{self, AssertUnwindSafe};
285+
use std::sync::atomic::{AtomicUsize, Ordering};
286+
use rand::{thread_rng, seq::SliceRandom};
287+
287288
static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
288289

289290
#[derive(Eq, PartialEq, Ord, Clone, Debug)]

src/liballoc/tests/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ mod slice_index {
483483
}
484484

485485
#[test]
486-
#[cfg(not(target_arch = "asmjs"))] // hits an OOM
486+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
487487
#[cfg(not(miri))] // Miri is too slow
488488
fn simple_big() {
489489
fn a_million_letter_x() -> String {

src/liballoc/tests/str.rs.rej

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
diff a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs (rejected hunks)
2+
@@ -483,7 +483,7 @@ mod slice_index {
3+
}
4+
5+
#[test]
6+
- #[cfg(not(target_arch = "asmjs"))] // hits an OOM
7+
+ #[cfg(not(target_arch = "js"))] // hits an OOM
8+
#[cfg(not(miri))] // Miri is too slow
9+
fn simple_big() {
10+
fn a_million_letter_x() -> String {

src/liballoc/tests/vec.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,10 @@ fn drain_filter_complex() {
944944
}
945945
}
946946

947+
// Miri does not support catching panics
948+
// FIXME: re-enable emscripten once it can unwind again
947949
#[test]
948-
#[cfg(not(miri))] // Miri does not support catching panics
950+
#[cfg(not(any(miri, target_os = "emscripten")))]
949951
fn drain_filter_consumed_panic() {
950952
use std::rc::Rc;
951953
use std::sync::Mutex;
@@ -995,8 +997,9 @@ fn drain_filter_consumed_panic() {
995997
}
996998
}
997999

1000+
// FIXME: Re-enable emscripten once it can catch panics
9981001
#[test]
999-
#[cfg(not(miri))] // Miri does not support catching panics
1002+
#[cfg(not(any(miri, target_os = "emscripten")))] // Miri does not support catching panics
10001003
fn drain_filter_unconsumed_panic() {
10011004
use std::rc::Rc;
10021005
use std::sync::Mutex;
+28-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,47 @@
11
use crate::abi::call::{FnType, ArgType, Uniform};
22
use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
33

4-
fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'a, Ty>)
4+
fn unwrap_trivial_aggregate<'a, Ty, C>(cx: &C, val: &mut ArgType<'a, Ty>) -> bool
55
where Ty: TyLayoutMethods<'a, C> + Copy,
66
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
77
{
8-
if ret.layout.is_aggregate() {
9-
if let Some(unit) = ret.layout.homogeneous_aggregate(cx).unit() {
10-
let size = ret.layout.size;
8+
if val.layout.is_aggregate() {
9+
if let Some(unit) = val.layout.homogeneous_aggregate(cx).unit() {
10+
let size = val.layout.size;
1111
if unit.size == size {
12-
ret.cast_to(Uniform {
12+
val.cast_to(Uniform {
1313
unit,
1414
total: size
1515
});
16-
return;
16+
return true;
1717
}
1818
}
19+
}
20+
false
21+
}
1922

20-
ret.make_indirect();
23+
24+
fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'a, Ty>)
25+
where Ty: TyLayoutMethods<'a, C> + Copy,
26+
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
27+
{
28+
ret.extend_integer_width_to(32);
29+
if ret.layout.is_aggregate() {
30+
if !unwrap_trivial_aggregate(cx, ret) {
31+
ret.make_indirect();
32+
}
2133
}
2234
}
2335

24-
fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>) {
36+
fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>)
37+
where Ty: TyLayoutMethods<'a, C> + Copy,
38+
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
39+
{
40+
arg.extend_integer_width_to(32);
2541
if arg.layout.is_aggregate() {
26-
arg.make_indirect_byval();
42+
if !unwrap_trivial_aggregate(cx, arg) {
43+
arg.make_indirect_byval();
44+
}
2745
}
2846
}
2947

@@ -37,6 +55,6 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
3755

3856
for arg in &mut fty.args {
3957
if arg.is_ignore() { continue; }
40-
classify_arg_ty(arg);
58+
classify_arg_ty(cx, arg);
4159
}
4260
}

src/librustc_target/spec/wasm32_unknown_emscripten.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub fn target() -> Result<Target, String> {
1010
"ASSERTIONS=1".to_string(),
1111
"-s".to_string(),
1212
"DISABLE_EXCEPTION_CATCHING=1".to_string(),
13+
"-s".to_string(),
14+
"ABORTING_MALLOC=0".to_string(),
1315
// FIXME(tlively): Enable this linker option once libc type errors
1416
// are resolved. See https://github.com/rust-lang/libc/pull/1478.
1517
// "-Wl,--fatal-warnings".to_string(),

src/libtest/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1478,9 +1478,9 @@ pub fn run_test(
14781478
) {
14791479
let TestDescAndFn { desc, testfn } = test;
14801480

1481-
let ignore_because_no_process_support = cfg!(target_arch = "wasm32")
1482-
&& !cfg!(target_os = "emscripten")
1483-
&& desc.should_panic != ShouldPanic::No;
1481+
// FIXME: Re-enable emscripten once it can catch panics again
1482+
let ignore_because_no_process_support = desc.should_panic != ShouldPanic::No
1483+
&& (cfg!(target_arch = "wasm32") || cfg!(target_os = "emscripten"));
14841484

14851485
if force_ignore || desc.ignore || ignore_because_no_process_support {
14861486
monitor_ch.send((desc, TrIgnored, None, Vec::new())).unwrap();

src/libtest/tests.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::*;
22

33
use crate::test::{
44
filter_tests, parse_opts, run_test, DynTestFn, DynTestName, MetricMap, RunIgnored, RunStrategy,
5-
ShouldPanic, StaticTestName, TestDesc, TestDescAndFn, TestOpts, TrFailedMsg,
5+
ShouldPanic, StaticTestName, TestDesc, TestDescAndFn, TestOpts,
66
TrIgnored, TrOk,
77
};
88
use std::sync::mpsc::channel;
@@ -90,7 +90,9 @@ pub fn ignored_tests_result_in_ignored() {
9090
assert!(res == TrIgnored);
9191
}
9292

93+
// FIXME: Re-enable emscripten once it can catch panics again
9394
#[test]
95+
#[cfg(not(target_os = "emscripten"))]
9496
fn test_should_panic() {
9597
fn f() {
9698
panic!();
@@ -110,7 +112,9 @@ fn test_should_panic() {
110112
assert!(res == TrOk);
111113
}
112114

115+
// FIXME: Re-enable emscripten once it can catch panics again
113116
#[test]
117+
#[cfg(not(target_os = "emscripten"))]
114118
fn test_should_panic_good_message() {
115119
fn f() {
116120
panic!("an error message");
@@ -130,8 +134,11 @@ fn test_should_panic_good_message() {
130134
assert!(res == TrOk);
131135
}
132136

137+
// FIXME: Re-enable emscripten once it can catch panics again
133138
#[test]
139+
#[cfg(not(target_os = "emscripten"))]
134140
fn test_should_panic_bad_message() {
141+
use crate::tests::TrFailedMsg;
135142
fn f() {
136143
panic!("an error message");
137144
}
@@ -152,7 +159,9 @@ fn test_should_panic_bad_message() {
152159
assert!(res == TrFailedMsg(format!("{} '{}'", failed_msg, expected)));
153160
}
154161

162+
// FIXME: Re-enable emscripten once it can catch panics again
155163
#[test]
164+
#[cfg(not(target_os = "emscripten"))]
156165
fn test_should_panic_but_succeeds() {
157166
fn f() {}
158167
let desc = TestDescAndFn {

src/test/codegen/c-variadic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// ignore-emscripten compiled with panic=abort by default
12
// compile-flags: -C no-prepopulate-passes
23
// ignore-tidy-linelength
34

src/test/codegen/drop.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// ignore-emscripten compiled with panic=abort by default
12
// compile-flags: -C no-prepopulate-passes
23

34
#![crate_type = "lib"]

src/test/codegen/extern-functions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// ignore-emscripten compiled with panic=abort by default
12
// compile-flags: -C no-prepopulate-passes
23

34
#![crate_type = "lib"]

src/test/codegen/external-no-mangle-statics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// ignore-emscripten default visibility is hidden
12
// compile-flags: -O
23
// `#[no_mangle]`d static variables always have external linkage, i.e., no `internal` in their
34
// definitions

src/test/codegen/link_section.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// ignore-emscripten default visibility is hidden
12
// compile-flags: -C no-prepopulate-passes
23

34
#![crate_type = "lib"]

src/test/codegen/personality_lifetimes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// ignore-msvc
2+
// ignore-emscripten compiled with panic=abort by default
23

34
// compile-flags: -O -C no-prepopulate-passes
45

src/test/codegen/repr-transparent-aggregates-2.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
// compile-flags: -C no-prepopulate-passes
22

33
// ignore-aarch64
4-
// ignore-asmjs
4+
// ignore-emscripten
55
// ignore-mips64
66
// ignore-powerpc
77
// ignore-powerpc64
88
// ignore-powerpc64le
99
// ignore-s390x
1010
// ignore-sparc
1111
// ignore-sparc64
12-
// ignore-wasm
1312
// ignore-x86
1413
// ignore-x86_64
1514
// See repr-transparent.rs

0 commit comments

Comments
 (0)