Skip to content

Commit

Permalink
Make wasm32 buildbot test LLVM backend
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tlively committed Jun 23, 2017
1 parent bd62230 commit 447297c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
6 changes: 3 additions & 3 deletions src/ci/docker/disabled/wasm32/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
5 changes: 4 additions & 1 deletion src/ci/docker/scripts/emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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)> ,
Expand Down

0 comments on commit 447297c

Please sign in to comment.