Upgrade Emscripten targets to use upstream LLVM backend

- Refactors the Emscripten target spec to share code with other wasm
   targets.
 - Replaces the incorrect wasm32 C call ABI with the old asmjs
   version, which is correct for both wasm32 and JS.
 - Updates the varargs ABI used by Emscripten and deletes the old one.
 - Removes the obsolete wasm32-experimental-emscripten target.
 - Temporarily makes Emscripten targets use panic=abort by default
   because supporting unwinding will require an LLVM patch.
This commit is contained in:
Thomas Lively 2019-08-16 22:08:01 -07:00
parent 31d75c4e9c
commit 9a55103b98
100 changed files with 166 additions and 424 deletions

View file

@ -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

View file

@ -1046,11 +1046,9 @@ impl Step for Compiletest {
// Also provide `rust_test_helpers` for the host.
builder.ensure(native::TestHelpers { target: compiler.host });
// As well as the target
builder.ensure(native::TestHelpers { target });
// wasm32 can't build the test helpers
if !target.contains("wasm32") {
builder.ensure(native::TestHelpers { target });
}
builder.ensure(RemoteCopyLibs { compiler, target });
let mut cmd = builder.tool_cmd(Tool::Compiletest);

View file

@ -11,7 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
xz-utils
xz-utils \
bzip2
COPY scripts/emscripten.sh /scripts/
RUN bash /scripts/emscripten.sh
@ -20,28 +21,17 @@ COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
ENV PATH=$PATH:/emsdk-portable
ENV PATH=$PATH:/emsdk-portable/clang/e1.38.15_64bit/
ENV PATH=$PATH:/emsdk-portable/emscripten/1.38.15/
ENV PATH=$PATH:/emsdk-portable/node/8.9.1_64bit/bin/
ENV EMSCRIPTEN=/emsdk-portable/emscripten/1.38.15/
ENV BINARYEN_ROOT=/emsdk-portable/clang/e1.38.15_64bit/binaryen/
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 EM_CONFIG=/emsdk-portable/.emscripten
ENV TARGETS=asmjs-unknown-emscripten
ENV RUST_CONFIGURE_ARGS --enable-emscripten --disable-optimize-tests
# TODO: Run run-fail, libcore, libstd, etc. once exceptions are enabled
ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/ui
ENV SCRIPT python2.7 ../x.py test --target $TARGETS \
src/test/ui \
src/test/run-fail \
src/libstd \
src/liballoc \
src/libcore
# Debug assertions in rustc are largely covered by other builders, and LLVM
# assertions cause this builder to slow down by quite a large amount and don't
# buy us a huge amount over other builders (not sure if we've ever seen an
# asmjs-specific backend assertion trip), so disable assertions for these
# tests.
ENV NO_LLVM_ASSERTIONS=1
# 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

View file

@ -1,35 +0,0 @@
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 \
jq \
bzip2
# emscripten
COPY scripts/emscripten-wasm.sh /scripts/
COPY wasm32-exp/node.sh /usr/local/bin/node
RUN bash /scripts/emscripten-wasm.sh
# cache
COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
# env
ENV PATH=/wasm-install/emscripten:/wasm-install/bin:$PATH
ENV EM_CONFIG=/root/.emscripten
ENV TARGETS=wasm32-experimental-emscripten
ENV RUST_CONFIGURE_ARGS --experimental-targets=WebAssembly
ENV SCRIPT python2.7 ../x.py test --target $TARGETS

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
path="$(dirname $1)"
file="$(basename $1)"
shift
cd "$path"
exec /node-v8.0.0-linux-x64/bin/node "$file" "$@"

View file

@ -11,9 +11,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
xz-utils
xz-utils \
bzip2
# emscripten
COPY scripts/emscripten.sh /scripts/
RUN bash /scripts/emscripten.sh
@ -21,12 +21,12 @@ COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
ENV PATH=$PATH:/emsdk-portable
ENV PATH=$PATH:/emsdk-portable/clang/e1.38.15_64bit/
ENV PATH=$PATH:/emsdk-portable/emscripten/1.38.15/
ENV PATH=$PATH:/emsdk-portable/node/8.9.1_64bit/bin/
ENV EMSCRIPTEN=/emsdk-portable/emscripten/1.38.15/
ENV BINARYEN_ROOT=/emsdk-portable/clang/e1.38.15_64bit/binaryen/
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 EM_CONFIG=/emsdk-portable/.emscripten
ENV TARGETS=wasm32-unknown-emscripten
ENV SCRIPT python2.7 ../x.py test --target $TARGETS
# TODO: Run run-fail, libcore, libstd, etc. once exceptions are enabled
ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/ui

View file

@ -1,37 +0,0 @@
set -ex
hide_output() {
set +x
on_err="
echo ERROR: An error was encountered with the build.
cat /tmp/build.log
exit 1
"
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
rm -f /tmp/build.log
set -x
}
# Download last known good emscripten from WebAssembly waterfall
BUILD=$(curl -fL https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | \
jq '.build | tonumber')
curl -sL https://storage.googleapis.com/wasm-llvm/builds/linux/$BUILD/wasm-binaries.tbz2 | \
hide_output tar xvkj
# node 8 is required to run wasm
cd /
curl -sL https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \
tar -xJ
# Make emscripten use wasm-ready node and LLVM tools
echo "EMSCRIPTEN_ROOT = '/wasm-install/emscripten'" >> /root/.emscripten
echo "NODE_JS='/usr/local/bin/node'" >> /root/.emscripten
echo "LLVM_ROOT='/wasm-install/bin'" >> /root/.emscripten
echo "BINARYEN_ROOT = '/wasm-install'" >> /root/.emscripten
echo "COMPILER_ENGINE = NODE_JS" >> /root/.emscripten
echo "JS_ENGINES = [NODE_JS]" >> /root/.emscripten

View file

@ -17,20 +17,15 @@ 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
hide_output ./emsdk install 1.38.46-upstream
./emsdk activate 1.38.46-upstream
# 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

View file

@ -49,8 +49,10 @@ impl fmt::Debug for c_void {
/// Basic implementation of a `va_list`.
// The name is WIP, using `VaListImpl` for now.
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
not(target_arch = "x86_64"), not(target_arch = "asmjs")),
not(target_arch = "x86_64")),
all(target_arch = "aarch64", target_os = "ios"),
target_arch = "wasm32",
target_arch = "asmjs",
windows))]
#[repr(transparent)]
#[unstable(feature = "c_variadic",
@ -67,8 +69,10 @@ pub struct VaListImpl<'f> {
}
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
not(target_arch = "x86_64"), not(target_arch = "asmjs")),
not(target_arch = "x86_64")),
all(target_arch = "aarch64", target_os = "ios"),
target_arch = "wasm32",
target_arch = "asmjs",
windows))]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
@ -137,38 +141,6 @@ pub struct VaListImpl<'f> {
_marker: PhantomData<&'f mut &'f c_void>,
}
/// asm.js ABI implementation of a `va_list`.
// asm.js uses the PNaCl ABI, which specifies that a `va_list` is
// an array of 4 32-bit integers, according to the old PNaCl docs at
// https://web.archive.org/web/20130518054430/https://www.chromium.org/nativeclient/pnacl/bitcode-abi#TOC-Derived-Types
// and clang does the same in `CreatePNaClABIBuiltinVaListDecl` from `lib/AST/ASTContext.cpp`
#[cfg(all(target_arch = "asmjs", not(windows)))]
#[repr(C)]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "44930")]
#[lang = "va_list"]
pub struct VaListImpl<'f> {
inner: [crate::mem::MaybeUninit<i32>; 4],
_marker: PhantomData<&'f mut &'f c_void>,
}
#[cfg(all(target_arch = "asmjs", not(windows)))]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "44930")]
impl<'f> fmt::Debug for VaListImpl<'f> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
unsafe {
write!(f, "va_list* [{:#x}, {:#x}, {:#x}, {:#x}]",
self.inner[0].read(), self.inner[1].read(),
self.inner[2].read(), self.inner[3].read())
}
}
}
/// A wrapper for a `va_list`
#[repr(transparent)]
#[derive(Debug)]
@ -178,14 +150,18 @@ impl<'f> fmt::Debug for VaListImpl<'f> {
issue = "44930")]
pub struct VaList<'a, 'f: 'a> {
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
not(target_arch = "x86_64"), not(target_arch = "asmjs")),
not(target_arch = "x86_64")),
all(target_arch = "aarch64", target_os = "ios"),
target_arch = "wasm32",
target_arch = "asmjs",
windows))]
inner: VaListImpl<'f>,
#[cfg(all(any(target_arch = "aarch64", target_arch = "powerpc",
target_arch = "x86_64", target_arch = "asmjs"),
target_arch = "x86_64"),
any(not(target_arch = "aarch64"), not(target_os = "ios")),
not(target_arch = "wasm32"),
not(target_arch = "asmjs"),
not(windows)))]
inner: &'a mut VaListImpl<'f>,
@ -193,8 +169,10 @@ pub struct VaList<'a, 'f: 'a> {
}
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
not(target_arch = "x86_64"), not(target_arch = "asmjs")),
not(target_arch = "x86_64")),
all(target_arch = "aarch64", target_os = "ios"),
target_arch = "wasm32",
target_arch = "asmjs",
windows))]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
@ -212,8 +190,10 @@ impl<'f> VaListImpl<'f> {
}
#[cfg(all(any(target_arch = "aarch64", target_arch = "powerpc",
target_arch = "x86_64", target_arch = "asmjs"),
target_arch = "x86_64"),
any(not(target_arch = "aarch64"), not(target_os = "ios")),
not(target_arch = "wasm32"),
not(target_arch = "asmjs"),
not(windows)))]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \

View file

@ -114,24 +114,8 @@ pub fn black_box<T>(dummy: T) -> T {
// this. LLVM's intepretation of inline assembly is that it's, well, a black
// box. This isn't the greatest implementation since it probably deoptimizes
// more than we want, but it's so far good enough.
#[cfg(not(any(
target_arch = "asmjs",
all(
target_arch = "wasm32",
target_os = "emscripten"
)
)))]
unsafe {
asm!("" : : "r"(&dummy));
return dummy;
}
// Not all platforms support inline assembly so try to do something without
// inline assembly which in theory still hinders at least some optimizations
// on those targets. This is the "best effort" scenario.
unsafe {
let ret = crate::ptr::read_volatile(&dummy);
crate::mem::forget(dummy);
ret
}
}

View file

@ -257,8 +257,7 @@ pub fn target_feature_whitelist(sess: &Session)
"hexagon" => HEXAGON_WHITELIST,
"mips" | "mips64" => MIPS_WHITELIST,
"powerpc" | "powerpc64" => POWERPC_WHITELIST,
// wasm32 on emscripten does not support these target features
"wasm32" if !sess.target.target.options.is_like_emscripten => WASM_WHITELIST,
"wasm32" => WASM_WHITELIST,
_ => &[],
}
}

View file

@ -142,15 +142,12 @@ impl ModuleConfig {
// Copy what clang does by turning on loop vectorization at O2 and
// slp vectorization at O3. Otherwise configure other optimization aspects
// of this pass manager builder.
// Turn off vectorization for emscripten, as it's not very well supported.
self.vectorize_loop = !sess.opts.cg.no_vectorize_loops &&
(sess.opts.optimize == config::OptLevel::Default ||
sess.opts.optimize == config::OptLevel::Aggressive) &&
!sess.target.target.options.is_like_emscripten;
sess.opts.optimize == config::OptLevel::Aggressive);
self.vectorize_slp = !sess.opts.cg.no_vectorize_slp &&
sess.opts.optimize == config::OptLevel::Aggressive &&
!sess.target.target.options.is_like_emscripten;
sess.opts.optimize == config::OptLevel::Aggressive;
// Some targets (namely, NVPTX) interact badly with the MergeFunctions
// pass. This is because MergeFunctions can generate new function calls

View file

@ -1,47 +0,0 @@
use crate::abi::call::{FnType, ArgType, Uniform};
use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
// Data layout: e-p:32:32-i64:64-v128:32:128-n32-S128
// See the https://github.com/kripken/emscripten-fastcomp-clang repository.
// The class `EmscriptenABIInfo` in `/lib/CodeGen/TargetInfo.cpp` contains the ABI definitions.
fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'a, Ty>)
where Ty: TyLayoutMethods<'a, C> + Copy,
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
{
if ret.layout.is_aggregate() {
if let Some(unit) = ret.layout.homogeneous_aggregate(cx).unit() {
let size = ret.layout.size;
if unit.size == size {
ret.cast_to(Uniform {
unit,
total: size
});
return;
}
}
ret.make_indirect();
}
}
fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>) {
if arg.layout.is_aggregate() {
arg.make_indirect_byval();
}
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
where Ty: TyLayoutMethods<'a, C> + Copy,
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
{
if !fty.ret.is_ignore() {
classify_ret_ty(cx, &mut fty.ret);
}
for arg in &mut fty.args {
if arg.is_ignore() { continue; }
classify_arg_ty(arg);
}
}

View file

@ -5,7 +5,6 @@ use crate::spec::{self, HasTargetSpec};
mod aarch64;
mod amdgpu;
mod arm;
mod asmjs;
mod hexagon;
mod mips;
mod mips64;
@ -557,14 +556,6 @@ impl<'a, Ty> FnType<'a, Ty> {
"powerpc" => powerpc::compute_abi_info(cx, self),
"powerpc64" => powerpc64::compute_abi_info(cx, self),
"s390x" => s390x::compute_abi_info(cx, self),
"asmjs" => asmjs::compute_abi_info(cx, self),
"wasm32" => {
if cx.target_spec().llvm_target.contains("emscripten") {
asmjs::compute_abi_info(cx, self)
} else {
wasm32::compute_abi_info(self)
}
}
"msp430" => msp430::compute_abi_info(self),
"sparc" => sparc::compute_abi_info(cx, self),
"sparc64" => sparc64::compute_abi_info(cx, self),
@ -573,6 +564,7 @@ impl<'a, Ty> FnType<'a, Ty> {
"hexagon" => hexagon::compute_abi_info(self),
"riscv32" => riscv::compute_abi_info(self, 32),
"riscv64" => riscv::compute_abi_info(self, 64),
"wasm32" | "asmjs" => wasm32::compute_abi_info(cx, self),
a => return Err(format!("unrecognized arch \"{}\" in target specification", a))
}

View file

@ -1,16 +1,38 @@
use crate::abi::call::{FnType, ArgType};
use crate::abi::call::{FnType, ArgType, Uniform};
use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
fn classify_ret_ty<Ty>(ret: &mut ArgType<'_, Ty>) {
ret.extend_integer_width_to(32);
fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'a, Ty>)
where Ty: TyLayoutMethods<'a, C> + Copy,
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
{
if ret.layout.is_aggregate() {
if let Some(unit) = ret.layout.homogeneous_aggregate(cx).unit() {
let size = ret.layout.size;
if unit.size == size {
ret.cast_to(Uniform {
unit,
total: size
});
return;
}
}
ret.make_indirect();
}
}
fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>) {
arg.extend_integer_width_to(32);
if arg.layout.is_aggregate() {
arg.make_indirect_byval();
}
}
pub fn compute_abi_info<Ty>(fty: &mut FnType<'_, Ty>) {
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
where Ty: TyLayoutMethods<'a, C> + Copy,
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
{
if !fty.ret.is_ignore() {
classify_ret_ty(&mut fty.ret);
classify_ret_ty(cx, &mut fty.ret);
}
for arg in &mut fty.args {

View file

@ -1,40 +1,10 @@
use super::{LinkArgs, LinkerFlavor, Target, TargetOptions};
use super::{LinkerFlavor, Target, wasm32_unknown_emscripten};
pub fn target() -> Result<Target, String> {
let mut args = LinkArgs::new();
args.insert(LinkerFlavor::Em,
vec!["-s".to_string(),
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string(),
"-s".to_string(),
"ABORTING_MALLOC=0".to_string(),
"-s".to_string(),
"WASM=0".to_string()]);
let opts = TargetOptions {
dynamic_linking: false,
executables: true,
exe_suffix: ".js".to_string(),
linker_is_gnu: true,
allow_asm: false,
obj_is_bitcode: true,
is_like_emscripten: true,
max_atomic_width: Some(32),
post_link_args: args,
target_family: Some("unix".to_string()),
codegen_backend: "emscripten".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_c_int_width: "32".to_string(),
target_os: "emscripten".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
data_layout: "e-p:32:32-i64:64-v128:32:128-n32-S128".to_string(),
arch: "asmjs".to_string(),
linker_flavor: LinkerFlavor::Em,
options: opts,
})
let mut target = wasm32_unknown_emscripten::target()?;
target.options.post_link_args
.entry(LinkerFlavor::Em)
.or_default()
.extend(vec!["-s".to_string(), "WASM=0".to_string()]);
Ok(target)
}

View file

@ -462,7 +462,6 @@ supported_targets! {
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
("wasm32-unknown-unknown", wasm32_unknown_unknown),
("wasm32-wasi", wasm32_wasi),
("wasm32-experimental-emscripten", wasm32_experimental_emscripten),
("thumbv6m-none-eabi", thumbv6m_none_eabi),
("thumbv7m-none-eabi", thumbv7m_none_eabi),

View file

@ -1,44 +0,0 @@
use super::{LinkArgs, LinkerFlavor, Target, TargetOptions};
pub fn target() -> Result<Target, String> {
let mut post_link_args = LinkArgs::new();
post_link_args.insert(LinkerFlavor::Em,
vec!["-s".to_string(),
"WASM=1".to_string(),
"-s".to_string(),
"ASSERTIONS=1".to_string(),
"-s".to_string(),
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string(),
"-g3".to_string()]);
let opts = TargetOptions {
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,
link_env: vec![("EMCC_WASM_BACKEND".to_string(), "1".to_string())],
allow_asm: false,
obj_is_bitcode: true,
is_like_emscripten: true,
max_atomic_width: Some(32),
post_link_args,
limit_rdylib_exports: false,
target_family: Some("unix".to_string()),
.. Default::default()
};
Ok(Target {
llvm_target: "wasm32-unknown-unknown".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "emscripten".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
data_layout: "e-m:e-p:32:32-i64:64-n32:64-S128".to_string(),
arch: "wasm32".to_string(),
linker_flavor: LinkerFlavor::Em,
options: opts,
})
}

View file

@ -1,45 +1,44 @@
use super::{LinkArgs, LinkerFlavor, Target, TargetOptions};
use super::wasm32_base;
use super::{LinkArgs, LinkerFlavor, Target, TargetOptions, PanicStrategy};
pub fn target() -> Result<Target, String> {
// FIXME(nikic) BINARYEN_TRAP_MODE=clamp is needed to avoid trapping in our
// -Zsaturating-float-casts implementation. This can be dropped if/when
// we have native fpto[su]i.sat intrinsics, or the implementation otherwise
// stops relying on non-trapping fpto[su]i.
let mut post_link_args = LinkArgs::new();
post_link_args.insert(LinkerFlavor::Em,
vec!["-s".to_string(),
"BINARYEN=1".to_string(),
"-s".to_string(),
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string(),
"-s".to_string(),
"BINARYEN_TRAP_MODE='clamp'".to_string()]);
"ASSERTIONS=1".to_string(),
"-s".to_string(),
"DISABLE_EXCEPTION_CATCHING=1".to_string(),
// FIXME(tlively): Enable this linker option once libc type errors
// are resolved. See https://github.com/rust-lang/libc/pull/1478.
// "-Wl,--fatal-warnings".to_string(),
]);
let opts = TargetOptions {
dynamic_linking: false,
executables: true,
// Today emcc emits two files - a .js file to bootstrap and
// possibly interpret the wasm, and a .wasm file
// emcc emits two files - a .js file to instantiate the wasm and supply platform
// functionality, and a .wasm file.
exe_suffix: ".js".to_string(),
linker: None,
linker_is_gnu: true,
allow_asm: false,
obj_is_bitcode: true,
is_like_emscripten: true,
max_atomic_width: Some(32),
// FIXME(tlively): Emscripten supports unwinding, but we would have to pass
// -enable-emscripten-cxx-exceptions to LLVM at codegen time and merge
// https://reviews.llvm.org/rG5c3cdef84b82464756bb571c13c31cf7773860c3to use it.
panic_strategy: PanicStrategy::Abort,
post_link_args,
limit_rdylib_exports: false,
target_family: Some("unix".to_string()),
codegen_backend: "emscripten".to_string(),
.. Default::default()
.. wasm32_base::options()
};
Ok(Target {
llvm_target: "asmjs-unknown-emscripten".to_string(),
llvm_target: "wasm32-unknown-emscripten".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "emscripten".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
data_layout: "e-p:32:32-i64:64-v128:32:128-n32-S128".to_string(),
data_layout: "e-m:e-p:32:32-i64:64-n32:64-S128".to_string(),
arch: "wasm32".to_string(),
linker_flavor: LinkerFlavor::Em,
options: opts,

View file

@ -360,7 +360,7 @@ impl<'a> fmt::Display for Html<'a> {
("target_arch", Some(arch)) => match &*arch.as_str() {
"aarch64" => "AArch64",
"arm" => "ARM",
"asmjs" => "asm.js",
"asmjs" => "JavaScript",
"mips" => "MIPS",
"mips64" => "MIPS-64",
"msp430" => "MSP430",

View file

@ -10,7 +10,8 @@
// fallback implementation to use as well.
//
// Due to rust-lang/rust#18804, make sure this is not generic!
#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "hermit", target_os = "redox"))]
#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "hermit", target_os = "redox",
target_os = "emscripten"))]
pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
use crate::mem;
use crate::sys_common::thread_local::register_dtor_fallback;

View file

@ -1,7 +1,5 @@
// compile-flags: -O
// ignore-asmjs
#![feature(asm)]
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,4 +1,3 @@
// ignore-emscripten
// min-llvm-version 7.0
// compile-flags: -C no-prepopulate-passes

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,5 +1,3 @@
// ignore-emscripten
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]

View file

@ -1,4 +1,3 @@
// ignore-emscripten
// ignore-tidy-linelength
// compile-flags: -C no-prepopulate-passes

View file

@ -1,4 +1,3 @@
// ignore-emscripten
// ignore-tidy-linelength
// compile-flags: -C no-prepopulate-passes

View file

@ -5,6 +5,10 @@
// ignore-wasm32-bare no libc to test ffi with
// FIXME: This will work on emscripten once libc is updated to include
// rust-lang/libc/#1478
// ignore-emscripten libc type mismatch
#![feature(rustc_private)]
extern crate libc;

View file

@ -7,7 +7,7 @@
//
// See issue #59123 for a full explanation.
// ignore-wasm32-bare (sizes don't match)
// ignore-emscripten (sizes don't match)
// run-pass
// edition:2018

View file

@ -3,6 +3,7 @@
// compile-flags: -Copt-level=z -Cdebuginfo=2 --edition=2018
// run-pass
// ignore-asmjs wasm2js does not support source maps yet
use std::future::Future;
use std::task::Poll;

View file

@ -2,7 +2,7 @@
// Check that partially moved from function parameters are dropped after the
// named bindings that move from them.
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
use std::{panic, cell::RefCell};

View file

@ -1,6 +1,7 @@
// run-pass
#![allow(dead_code)]
// compile-flags: -g
// ignore-asmjs wasm2js does not support source maps yet
#[derive(PartialEq, Eq)]
struct NewBool(bool);

View file

@ -2,7 +2,7 @@
#![allow(unused_variables)]
#![allow(unused_imports)]
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
// Test that builtin implementations of `Clone` cleanup everything
// in case of unwinding.

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
fn worker() -> ! {
panic!()

View file

@ -1,5 +1,4 @@
// run-pass
// ignore-emscripten no i128 support
#![feature(const_saturating_int_methods)]
const INT_U32_NO: u32 = (42 as u32).saturating_add(2);

View file

@ -7,6 +7,7 @@
// aux-build:debuginfo-lto-aux.rs
// compile-flags: -C lto -g
// no-prefer-dynamic
// ignore-asmjs wasm2js does not support source maps yet
extern crate debuginfo_lto_aux;

View file

@ -5,7 +5,7 @@
// run-pass
// edition:2018
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![feature(slice_patterns)]
#![allow(unused)]

View file

@ -2,7 +2,7 @@
#![allow(unused_assignments)]
#![allow(unused_variables)]
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![feature(generators, generator_trait, untagged_unions)]
#![feature(slice_patterns)]

View file

@ -5,7 +5,8 @@
// compile. To sidestep this by using one that *is* defined.
// run-rustfix
// ignore-wasm32 no external library to link to.
// ignore-wasm32-bare no external library to link to.
// ignore-asmjs wasm2js does not support source maps yet
// compile-flags: -g
#![feature(rustc_private)]
extern crate libc;

View file

@ -5,7 +5,8 @@
// compile. To sidestep this by using one that *is* defined.
// run-rustfix
// ignore-wasm32 no external library to link to.
// ignore-wasm32-bare no external library to link to.
// ignore-asmjs wasm2js does not support source maps yet
// compile-flags: -g
#![feature(rustc_private)]
extern crate libc;

View file

@ -1,5 +1,5 @@
error: extern items cannot be `const`
--> $DIR/extern-const.rs:15:5
--> $DIR/extern-const.rs:16:5
|
LL | const rust_dbg_static_mut: libc::c_int;
| ^^^^^ help: try using a static value: `static`

View file

@ -1,5 +1,6 @@
// run-pass
// compile-flags: -g
// ignore-asmjs wasm2js does not support source maps yet
#![feature(generators, generator_trait)]

View file

@ -1,6 +1,6 @@
// run-pass
// ignore-wasm32-bare compiled as panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![feature(generators, generator_trait)]

View file

@ -1,6 +1,6 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![feature(generators, generator_trait)]

View file

@ -1,6 +1,6 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![feature(generators, generator_trait)]

View file

@ -11,6 +11,7 @@
// edition:2018
// ignore-wasm32 issue #62807
// ignore-asmjs issue #62807
#![feature(generators, generator_trait)]

View file

@ -1,5 +1,4 @@
// run-pass
// ignore-emscripten no i128 support
#![feature(intrinsics)]

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare always compiled as panic=abort right now
// ignore-emscripten compiled with panic=abort by default
// Check that values are not leaked when a dtor panics (#14875)

View file

@ -1,6 +1,7 @@
// run-pass
// aux-build:issue-24687-lib.rs
// compile-flags:-g
// ignore-asmjs wasm2js does not support source maps yet
extern crate issue_24687_lib as d;

View file

@ -3,6 +3,7 @@
// as options to the compiler.
// compile-flags:-g -g -O -O
// ignore-asmjs wasm2js does not support source maps yet
fn main() {
assert_eq!(1, 1);

View file

@ -1,5 +1,6 @@
// run-pass
// compile-flags:-g
// ignore-asmjs wasm2js does not support source maps yet
fn helper<F: FnOnce(usize) -> bool>(_f: F) {
print!("");

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
use std::panic;

View file

@ -1,5 +1,6 @@
// run-pass
// compile-flags: -g
// ignore-asmjs wasm2js does not support source maps yet
use std::ops::Deref;

View file

@ -1,7 +1,7 @@
// run-pass
// ignore-windows
// ignore-macos
// ignore-wasm32-bare common linkage not implemented right now
// ignore-emscripten common linkage not implemented right now
#![feature(linkage)]

View file

@ -1,5 +1,6 @@
// run-pass
// compile-flags:-g
// ignore-asmjs wasm2js does not support source maps yet
// In this test we just want to make sure that the code below does not lead to
// a debuginfo verification assertion during compilation. This was caused by the

View file

@ -2,6 +2,7 @@
// Regression test for #36856.
// compile-flags:-g
// ignore-asmjs wasm2js does not support source maps yet
fn g() -> bool {
false

View file

@ -2,6 +2,7 @@
// Regression test for #42210.
// compile-flags: -g
// ignore-asmjs wasm2js does not support source maps yet
trait Foo {
fn foo() { }

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
use std::panic;

View file

@ -1,6 +1,7 @@
// run-pass
#![allow(unused_variables)]
// compile-flags:--test -g
// ignore-asmjs wasm2js does not support source maps yet
#[cfg(target_os = "macos")]
#[test]

View file

@ -1,6 +1,8 @@
// run-pass
// compile-flags:--test -O
// ignore-emscripten compiled with panic=abort by default
#[test]
#[should_panic(expected = "creating inhabited type")]
fn test() {

View file

@ -8,6 +8,7 @@
// compile-flags:-g
// ignore-pretty issue #37195
// ignore-asmjs wasm2js does not support source maps yet
#![feature(non_ascii_idents)]

View file

@ -1,5 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// ignore-emscripten no i128 support
fn fibs(n: u32) -> impl Iterator<Item=u128> {
(0 .. n)

View file

@ -1,5 +1,7 @@
// run-pass
// compile-flags:-C debuginfo=2
// ignore-asmjs wasm2js does not support source maps yet
fn foo() -> impl Copy {
foo
}

View file

@ -1,6 +1,6 @@
// run-pass
// only-32bit too impatient for 2⁶⁴ items
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
// compile-flags: -C debug_assertions=yes -C opt-level=3
use std::panic;

View file

@ -1,6 +1,6 @@
// run-pass
// only-32bit too impatient for 2⁶⁴ items
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
// compile-flags: -C debug_assertions=yes -C opt-level=3
use std::panic;

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
// compile-flags: -C debug_assertions=yes
use std::panic;

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
// compile-flags: -C debug_assertions=yes
use std::panic;

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
// compile-flags: -C overflow-checks
use std::panic;

View file

@ -13,6 +13,8 @@
// compile-flags: --test -C debug_assertions=yes
// revisions: std core
// ignore-emscripten compiled with panic=abort by default
#![cfg_attr(core, no_std)]
#[cfg(std)] use std::fmt;

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![feature(fn_traits)]
#![feature(never_type)]

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
use std::cell::RefCell;
use std::panic;

View file

@ -1,5 +1,4 @@
// run-pass
// ignore-emscripten no i128 support
#![deny(const_err)]

View file

@ -1,9 +1,6 @@
// run-pass
#![allow(overflowing_literals)]
// ignore-emscripten i128 doesn't work
#![feature(test)]
extern crate test;

View file

@ -1,6 +1,6 @@
// run-pass
// compile-flags: -C debug_assertions=yes
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
// ignore-emscripten dies with an LLVM error
use std::panic;

View file

@ -1,5 +1,4 @@
// run-pass
// ignore-emscripten u128 not supported
#![feature(test)]
#![deny(overflowing_literals)]

View file

@ -1,6 +1,4 @@
// run-pass
// ignore-emscripten u128 not supported
#![feature(test)]

View file

@ -4,7 +4,7 @@
// aux-build:wants-panic-runtime-abort.rs
// aux-build:panic-runtime-lang-items.rs
// error-pattern: is not compiled with this crate's panic strategy `unwind`
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![no_std]
#![no_main]

View file

@ -1,7 +1,7 @@
// error-pattern:is incompatible with this crate's strategy of `unwind`
// aux-build:panic-runtime-abort.rs
// aux-build:panic-runtime-lang-items.rs
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![no_std]
#![no_main]

View file

@ -2,7 +2,7 @@
// aux-build:panic-runtime-abort.rs
// aux-build:wants-panic-runtime-abort.rs
// aux-build:panic-runtime-lang-items.rs
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![no_std]
#![no_main]

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare always compiled as panic=abort right now and this requires unwinding
// ignore-emscripten compiled with panic=abort by default
// This test checks that instantiating an uninhabited type via `mem::{uninitialized,zeroed}` results
// in a runtime panic.

View file

@ -1,7 +1,7 @@
// run-pass
// aux-build:expand-with-a-macro.rs
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![deny(warnings)]

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
// aux-build:reachable-unnameable-items.rs
extern crate reachable_unnameable_items;

View file

@ -1,6 +1,8 @@
// compile-flags: --test
// run-pass
// ignore-emscripten compiled with panic=abort by default
#![feature(test)]
extern crate test;

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
#![allow(dead_code, unreachable_code)]

View file

@ -4,6 +4,7 @@
// aux-build:sepcomp_lib.rs
// compile-flags: -C lto -g
// ignore-asmjs wasm2js does not support source maps yet
// no-prefer-dynamic
extern crate sepcomp_lib;

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
// compile-flags: --test
#![feature(allow_fail)]

View file

@ -1,5 +1,5 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten compiled with panic=abort by default
// compile-flags: --test
#[test]
#[should_panic(expected = "foo")]

View file

@ -10,6 +10,7 @@
// This is a regression test for issue #17021.
//
// compile-flags: -g
// ignore-asmjs wasm2js does not support source maps yet
use std::ptr;