Skip to content

Commit

Permalink
Auto merge of #65251 - tlively:emscripten-upstream-upgrade, r=tlively
Browse files Browse the repository at this point in the history
Upgrade Emscripten targets to use upstream LLVM backend

 - Compatible with Emscripten 1.38.46-upstream or later upstream.
 - Refactors the Emscripten target spec to share code with other wasm
   targets.
 - Replaces the old incorrect wasm32 C call ABI with the correct one,
   preserving the old one as wasm32_bindgen_compat for wasm-bindgen
   compatibility.
 - Updates the varargs ABI used by Emscripten and deletes the old one.
 - Removes the obsolete wasm32-experimental-emscripten target.
 - Uses EMCC_CFLAGS on CI to avoid the timeout problems with #63649.

r? @alexcrichton
  • Loading branch information
bors committed Oct 17, 2019
2 parents 7e49800 + c0aa7cb commit a16dca3
Show file tree
Hide file tree
Showing 148 changed files with 438 additions and 603 deletions.
1 change: 1 addition & 0 deletions config.toml.example
Expand Up @@ -377,6 +377,7 @@
# but you can also optionally enable the "emscripten" backend for asm.js or
# make this an empty array (but that probably won't get too far in the
# bootstrap)
# FIXME: remove the obsolete emscripten backend option.
#codegen-backends = ["llvm"]

# This is the name of the directory in which codegen backends will get installed
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Expand Up @@ -980,6 +980,7 @@ impl<'a> Builder<'a> {
Some("-Wl,-rpath,@loader_path/../lib")
} else if !target.contains("windows") &&
!target.contains("wasm32") &&
!target.contains("emscripten") &&
!target.contains("fuchsia") {
Some("-Wl,-rpath,$ORIGIN/../lib")
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/test.rs
Expand Up @@ -1047,10 +1047,11 @@ impl Step for Compiletest {
// Also provide `rust_test_helpers` for the host.
builder.ensure(native::TestHelpers { target: compiler.host });

// wasm32 can't build the test helpers
if !target.contains("wasm32") {
// As well as the target, except for plain wasm32, which can't build it
if !target.contains("wasm32") || target.contains("emscripten") {
builder.ensure(native::TestHelpers { target });
}

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

let mut cmd = builder.tool_cmd(Tool::Compiletest);
Expand Down
4 changes: 2 additions & 2 deletions src/ci/azure-pipelines/auto.yml
Expand Up @@ -124,14 +124,14 @@ jobs:
IMAGE: dist-x86_64-netbsd
DEPLOY: 1

asmjs:
IMAGE: asmjs
i686-gnu:
IMAGE: i686-gnu
i686-gnu-nopt:
IMAGE: i686-gnu-nopt
test-various:
IMAGE: test-various
wasm32:
IMAGE: wasm32
x86_64-gnu:
IMAGE: x86_64-gnu
x86_64-gnu-full-bootstrap:
Expand Down
47 changes: 0 additions & 47 deletions src/ci/docker/asmjs/Dockerfile

This file was deleted.

41 changes: 41 additions & 0 deletions src/ci/docker/disabled/asmjs/Dockerfile
@@ -0,0 +1,41 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
make \
file \
curl \
ca-certificates \
python \
git \
cmake \
sudo \
gdb \
xz-utils \
bzip2

COPY scripts/emscripten.sh /scripts/
RUN bash /scripts/emscripten.sh

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV PATH=$PATH:/emsdk-portable
ENV PATH=$PATH:/emsdk-portable/upstream/emscripten/
ENV PATH=$PATH:/emsdk-portable/node/12.9.1_64bit/bin/
ENV BINARYEN_ROOT=/emsdk-portable/upstream/

ENV TARGETS=asmjs-unknown-emscripten

# Use -O1 optimizations in the link step to reduce time spent optimizing JS.
ENV EMCC_CFLAGS=-O1

# Emscripten installation is user-specific
ENV NO_CHANGE_USER=1

ENV SCRIPT python2.7 ../x.py test --target $TARGETS

# This is almost identical to the wasm32-unknown-emscripten target, so
# running with assertions again is not useful
ENV NO_DEBUG_ASSERTIONS=1
ENV NO_LLVM_ASSERTIONS=1
35 changes: 0 additions & 35 deletions src/ci/docker/disabled/wasm32-exp/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions src/ci/docker/disabled/wasm32-exp/node.sh

This file was deleted.

32 changes: 0 additions & 32 deletions src/ci/docker/disabled/wasm32/Dockerfile

This file was deleted.

37 changes: 0 additions & 37 deletions src/ci/docker/scripts/emscripten-wasm.sh

This file was deleted.

21 changes: 3 additions & 18 deletions src/ci/docker/scripts/emscripten.sh
Expand Up @@ -17,22 +17,7 @@ exit 1
set -x
}

cd /
curl -fL https://mozilla-games.s3.amazonaws.com/emscripten/releases/emsdk-portable.tar.gz | \
tar -xz

git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
cd /emsdk-portable
./emsdk update
hide_output ./emsdk install sdk-1.38.15-64bit
./emsdk activate sdk-1.38.15-64bit

# Compile and cache libc
source ./emsdk_env.sh
echo "main(){}" > a.c
HOME=/emsdk-portable/ emcc a.c
HOME=/emsdk-portable/ emcc -s BINARYEN=1 a.c
rm -f a.*

# Make emsdk usable by any user
cp /root/.emscripten /emsdk-portable
chmod a+rxw -R /emsdk-portable
hide_output ./emsdk install 1.38.46-upstream
./emsdk activate 1.38.46-upstream
44 changes: 44 additions & 0 deletions src/ci/docker/wasm32/Dockerfile
@@ -0,0 +1,44 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
make \
file \
curl \
ca-certificates \
python \
git \
cmake \
sudo \
gdb \
xz-utils \
bzip2

COPY scripts/emscripten.sh /scripts/
RUN bash /scripts/emscripten.sh

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV PATH=$PATH:/emsdk-portable
ENV PATH=$PATH:/emsdk-portable/upstream/emscripten/
ENV PATH=$PATH:/emsdk-portable/node/12.9.1_64bit/bin/
ENV BINARYEN_ROOT=/emsdk-portable/upstream/

ENV TARGETS=wasm32-unknown-emscripten

# Use -O1 optimizations in the link step to reduce time spent optimizing.
ENV EMCC_CFLAGS=-O1

# Emscripten installation is user-specific
ENV NO_CHANGE_USER=1

# FIXME: Re-enable these tests once https://github.com/rust-lang/cargo/pull/7476
# is picked up by CI
ENV SCRIPT python2.7 ../x.py test --target $TARGETS \
--exclude src/libcore \
--exclude src/liballoc \
--exclude src/libproc_macro \
--exclude src/libstd \
--exclude src/libterm \
--exclude src/libtest
13 changes: 7 additions & 6 deletions src/liballoc/tests/binary_heap.rs
@@ -1,10 +1,5 @@
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::binary_heap::{Drain, PeekMut};
use std::panic::{self, AssertUnwindSafe};
use std::sync::atomic::{AtomicUsize, Ordering};

use rand::{thread_rng, seq::SliceRandom};

#[test]
fn test_iterator() {
Expand Down Expand Up @@ -281,9 +276,15 @@ fn assert_covariance() {
// even if the order may not be correct.
//
// Destructors must be called exactly once per element.
// FIXME: re-enable emscripten once it can unwind again
#[test]
#[cfg(not(miri))] // Miri does not support catching panics
#[cfg(not(any(miri, target_os = "emscripten")))] // Miri does not support catching panics
fn panic_safe() {
use std::cmp;
use std::panic::{self, AssertUnwindSafe};
use std::sync::atomic::{AtomicUsize, Ordering};
use rand::{thread_rng, seq::SliceRandom};

static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);

#[derive(Eq, PartialEq, Ord, Clone, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/str.rs
Expand Up @@ -483,7 +483,7 @@ mod slice_index {
}

#[test]
#[cfg(not(target_arch = "asmjs"))] // hits an OOM
#[cfg(not(target_os = "emscripten"))] // hits an OOM
#[cfg(not(miri))] // Miri is too slow
fn simple_big() {
fn a_million_letter_x() -> String {
Expand Down
7 changes: 5 additions & 2 deletions src/liballoc/tests/vec.rs
Expand Up @@ -944,8 +944,10 @@ fn drain_filter_complex() {
}
}

// Miri does not support catching panics
// FIXME: re-enable emscripten once it can unwind again
#[test]
#[cfg(not(miri))] // Miri does not support catching panics
#[cfg(not(any(miri, target_os = "emscripten")))]
fn drain_filter_consumed_panic() {
use std::rc::Rc;
use std::sync::Mutex;
Expand Down Expand Up @@ -995,8 +997,9 @@ fn drain_filter_consumed_panic() {
}
}

// FIXME: Re-enable emscripten once it can catch panics
#[test]
#[cfg(not(miri))] // Miri does not support catching panics
#[cfg(not(any(miri, target_os = "emscripten")))] // Miri does not support catching panics
fn drain_filter_unconsumed_panic() {
use std::rc::Rc;
use std::sync::Mutex;
Expand Down

0 comments on commit a16dca3

Please sign in to comment.