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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 5 additions & 2 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 8 additions & 2 deletions
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

Lines changed: 7 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 5 additions & 2 deletions
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;
Lines changed: 28 additions & 10 deletions
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
}

0 commit comments

Comments
 (0)