Skip to content

Commit 06118ea

Browse files
committed
Auto merge of #55626 - nikic:update-emscripten, r=alexcrichton
Update emscripten This updates emscripten to 1.38.15, which is based on LLVM 6.0.1 and would allow us to drop code for handling LLVM 4. The main issue I ran into is that exporting statics through `EXPORTED_FUNCTIONS` no longer works. As far as I understand exporting non-functions doesn't really make sense under emscripten anyway, so I've modified the symbol export code to not even try. Closes #52323.
2 parents 36a50c2 + 82574e9 commit 06118ea

File tree

18 files changed

+48
-40
lines changed

18 files changed

+48
-40
lines changed

src/bootstrap/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ pub fn build_codegen_backend(builder: &Builder,
736736

737737
// Pass down configuration from the LLVM build into the build of
738738
// librustc_llvm and librustc_codegen_llvm.
739-
if builder.is_rust_llvm(target) {
739+
if builder.is_rust_llvm(target) && backend != "emscripten" {
740740
cargo.env("LLVM_RUSTLLVM", "1");
741741
}
742742
cargo.env("LLVM_CONFIG", &llvm_config);

src/ci/docker/asmjs/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ COPY scripts/sccache.sh /scripts/
2020
RUN sh /scripts/sccache.sh
2121

2222
ENV PATH=$PATH:/emsdk-portable
23-
ENV PATH=$PATH:/emsdk-portable/clang/e1.37.13_64bit/
24-
ENV PATH=$PATH:/emsdk-portable/emscripten/1.37.13/
25-
ENV PATH=$PATH:/emsdk-portable/node/4.1.1_64bit/bin/
26-
ENV EMSCRIPTEN=/emsdk-portable/emscripten/1.37.13/
27-
ENV BINARYEN_ROOT=/emsdk-portable/clang/e1.37.13_64bit/binaryen/
23+
ENV PATH=$PATH:/emsdk-portable/clang/e1.38.15_64bit/
24+
ENV PATH=$PATH:/emsdk-portable/emscripten/1.38.15/
25+
ENV PATH=$PATH:/emsdk-portable/node/8.9.1_64bit/bin/
26+
ENV EMSCRIPTEN=/emsdk-portable/emscripten/1.38.15/
27+
ENV BINARYEN_ROOT=/emsdk-portable/clang/e1.38.15_64bit/binaryen/
2828
ENV EM_CONFIG=/emsdk-portable/.emscripten
2929

3030
ENV TARGETS=asmjs-unknown-emscripten

src/ci/docker/disabled/wasm32/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ COPY scripts/sccache.sh /scripts/
2121
RUN sh /scripts/sccache.sh
2222

2323
ENV PATH=$PATH:/emsdk-portable
24-
ENV PATH=$PATH:/emsdk-portable/clang/e1.37.13_64bit/
25-
ENV PATH=$PATH:/emsdk-portable/emscripten/1.37.13/
26-
ENV PATH=$PATH:/node-v8.0.0-linux-x64/bin/
27-
ENV EMSCRIPTEN=/emsdk-portable/emscripten/1.37.13/
28-
ENV BINARYEN_ROOT=/emsdk-portable/clang/e1.37.13_64bit/binaryen/
24+
ENV PATH=$PATH:/emsdk-portable/clang/e1.38.15_64bit/
25+
ENV PATH=$PATH:/emsdk-portable/emscripten/1.38.15/
26+
ENV PATH=$PATH:/emsdk-portable/node/8.9.1_64bit/bin/
27+
ENV EMSCRIPTEN=/emsdk-portable/emscripten/1.38.15/
28+
ENV BINARYEN_ROOT=/emsdk-portable/clang/e1.38.15_64bit/binaryen/
2929
ENV EM_CONFIG=/emsdk-portable/.emscripten
3030

3131
ENV TARGETS=wasm32-unknown-emscripten

src/ci/docker/scripts/emscripten.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ curl -fL https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portab
3333

3434
cd /emsdk-portable
3535
./emsdk update
36-
hide_output ./emsdk install sdk-1.37.13-64bit
37-
./emsdk activate sdk-1.37.13-64bit
36+
hide_output ./emsdk install sdk-1.38.15-64bit
37+
./emsdk activate sdk-1.38.15-64bit
3838

3939
# Compile and cache libc
4040
source ./emsdk_env.sh
@@ -46,8 +46,3 @@ rm -f a.*
4646
# Make emsdk usable by any user
4747
cp /root/.emscripten /emsdk-portable
4848
chmod a+rxw -R /emsdk-portable
49-
50-
# node 8 is required to run wasm
51-
cd /
52-
curl -sL https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \
53-
tar -xJ

src/librustc_codegen_llvm/llvm_util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ pub fn target_feature_whitelist(sess: &Session)
243243
"hexagon" => HEXAGON_WHITELIST,
244244
"mips" | "mips64" => MIPS_WHITELIST,
245245
"powerpc" | "powerpc64" => POWERPC_WHITELIST,
246-
"wasm32" => WASM_WHITELIST,
246+
// wasm32 on emscripten does not support these target features
247+
"wasm32" if !sess.target.target.options.is_like_emscripten => WASM_WHITELIST,
247248
_ => &[],
248249
}
249250
}

src/librustc_codegen_utils/symbol_export.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,16 @@ fn symbol_export_level(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportLevel {
388388
codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
389389

390390
if is_extern && !std_internal {
391+
// Emscripten cannot export statics, so reduce their export level here
392+
if tcx.sess.target.target.options.is_like_emscripten {
393+
if let Some(Node::Item(&hir::Item {
394+
node: hir::ItemKind::Static(..),
395+
..
396+
})) = tcx.hir.get_if_local(sym_def_id) {
397+
return SymbolExportLevel::Rust;
398+
}
399+
}
400+
391401
SymbolExportLevel::C
392402
} else {
393403
SymbolExportLevel::Rust

src/llvm-emscripten

Submodule llvm-emscripten updated 14718 files

src/rustllvm/PassWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ extern "C" void LLVMRustConfigurePassManagerBuilder(
429429
LLVMPassManagerBuilderRef PMBR, LLVMRustCodeGenOptLevel OptLevel,
430430
bool MergeFunctions, bool SLPVectorize, bool LoopVectorize, bool PrepareForThinLTO,
431431
const char* PGOGenPath, const char* PGOUsePath) {
432-
#if LLVM_RUSTLLVM
432+
#if LLVM_VERSION_GE(7, 0)
433433
unwrap(PMBR)->MergeFunctions = MergeFunctions;
434434
#endif
435435
unwrap(PMBR)->SLPVectorize = SLPVectorize;

src/test/run-fail/mir_drop_panics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl Drop for Droppable {
1717
if self.0 == 1 {
1818
panic!("panic 1");
1919
} else {
20-
eprint!("drop {}", self.0);
20+
eprintln!("drop {}", self.0);
2121
}
2222
}
2323
}

src/test/run-fail/panic-set-handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::panic;
1414

1515
fn main() {
1616
panic::set_hook(Box::new(|i| {
17-
eprint!("greetings from the panic handler");
17+
eprintln!("greetings from the panic handler");
1818
}));
1919
panic!("foobar");
2020
}

0 commit comments

Comments
 (0)