From 447297ce597d2762db40afaa2349fc927c90f897 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Tue, 20 Jun 2017 13:37:58 -0700 Subject: [PATCH] Make wasm32 buildbot test LLVM backend This adds the experimental targets option to configure so it can be used by the builders and changes the wasm32 Dockerfile accordingly. Instead of using LLVM from the emsdk, the builder's emscripten tools now uses the Rust in-tree LLVM, since this is the one built with wasm support. --- configure | 1 + src/bootstrap/config.rs | 3 +++ src/ci/docker/disabled/wasm32/Dockerfile | 6 +++--- src/ci/docker/scripts/emscripten.sh | 5 ++++- src/tools/compiletest/src/runtest.rs | 11 ++++++++--- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 2b493ee91b50..e08bcc028272 100755 --- a/configure +++ b/configure @@ -490,6 +490,7 @@ valopt musl-root-armhf "" "arm-unknown-linux-musleabihf install directory" valopt musl-root-armv7 "" "armv7-unknown-linux-musleabihf install directory" valopt extra-filename "" "Additional data that is hashed and passed to the -C extra-filename flag" valopt qemu-armhf-rootfs "" "rootfs in qemu testing, you probably don't want to use this" +valopt experimental-targets "" "experimental LLVM targets to build" if [ -e ${CFG_SRC_DIR}.git ] then diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 902cd0997a8e..3ada846e3823 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -497,6 +497,9 @@ impl Config { "CFG_TARGET" if value.len() > 0 => { self.target.extend(value.split(" ").map(|s| s.to_string())); } + "CFG_EXPERIMENTAL_TARGETS" if value.len() > 0 => { + self.llvm_experimental_targets = Some(value.to_string()); + } "CFG_MUSL_ROOT" if value.len() > 0 => { self.musl_root = Some(parse_configure_path(value)); } diff --git a/src/ci/docker/disabled/wasm32/Dockerfile b/src/ci/docker/disabled/wasm32/Dockerfile index daf398ac0962..f3dd48ae411d 100644 --- a/src/ci/docker/disabled/wasm32/Dockerfile +++ b/src/ci/docker/disabled/wasm32/Dockerfile @@ -20,7 +20,7 @@ RUN sh /scripts/dumb-init.sh # emscripten COPY scripts/emscripten.sh /scripts/ RUN bash /scripts/emscripten.sh -COPY wasm32/node.sh /usr/local/bin/node +COPY disabled/wasm32/node.sh /usr/local/bin/node # env ENV PATH=$PATH:/emsdk-portable @@ -30,9 +30,9 @@ ENV EMSCRIPTEN=/emsdk-portable/emscripten/1.37.13/ ENV BINARYEN_ROOT=/emsdk-portable/clang/e1.37.13_64bit/binaryen/ ENV EM_CONFIG=/emsdk-portable/.emscripten -ENV TARGETS=wasm32-unknown-emscripten +ENV TARGETS=wasm32-unknown-emscripten,wasm32-experimental-emscripten -ENV RUST_CONFIGURE_ARGS --target=$TARGETS +ENV RUST_CONFIGURE_ARGS --target=$TARGETS --experimental-targets=WebAssembly ENV SCRIPT python2.7 ../x.py test --target $TARGETS diff --git a/src/ci/docker/scripts/emscripten.sh b/src/ci/docker/scripts/emscripten.sh index 8aa5a98d7fc5..516ef0ae0d27 100644 --- a/src/ci/docker/scripts/emscripten.sh +++ b/src/ci/docker/scripts/emscripten.sh @@ -40,9 +40,12 @@ hide_output ./emsdk install sdk-1.37.13-64bit source ./emsdk_env.sh echo "main(){}" > a.c HOME=/emsdk-portable/ emcc a.c -HOME=/emsdk-portable/ emcc -s BINARYEN=1 a.c +HOME=/emsdk-portable/ emcc -s WASM=1 a.c rm -f a.* +# Make emscripten use Rust's LLVM +echo "LLVM_ROOT='/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/bin'" >> /root/.emscripten + # Make emsdk usable by any user cp /root/.emscripten /emsdk-portable chmod a+rxw -R /emsdk-portable diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 01419c425707..3b3a94c6c582 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1280,6 +1280,12 @@ actual:\n\ let extra_link_args = vec!["-L".to_owned(), aux_dir.to_str().unwrap().to_owned()]; + let mut env = self.props.rustc_env.clone(); + // Tell emscripten to link using libc produced with LLVM backend + if self.config.target.contains("wasm32") && self.config.target.contains("experimental") { + env.push(("EMCC_WASM_BACKEND".to_string(), "1".to_string())); + } + for rel_ab in &self.props.aux_builds { let aux_testpaths = self.compute_aux_test_paths(rel_ab); let aux_props = self.props.from_aux_file(&aux_testpaths.file, @@ -1319,7 +1325,7 @@ actual:\n\ }; let aux_args = aux_cx.make_compile_args(crate_type, &aux_testpaths.file, aux_output); let auxres = aux_cx.compose_and_run(aux_args, - Vec::new(), + env.clone(), aux_cx.config.compile_lib_path.to_str().unwrap(), Some(aux_dir.to_str().unwrap()), None); @@ -1332,13 +1338,12 @@ actual:\n\ } self.compose_and_run(args, - self.props.rustc_env.clone(), + env, self.config.compile_lib_path.to_str().unwrap(), Some(aux_dir.to_str().unwrap()), input) } - fn compose_and_run(&self, ProcArgs{ args, prog }: ProcArgs, procenv: Vec<(String, String)> ,