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

Diff for: src/bootstrap/compile.rs

+1-1
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);

Diff for: src/ci/docker/asmjs/Dockerfile

+5-5
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

Diff for: src/ci/docker/disabled/wasm32/Dockerfile

+5-5
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

Diff for: src/ci/docker/scripts/emscripten.sh

+2-7
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

Diff for: src/librustc_codegen_llvm/llvm_util.rs

+2-1
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
}

Diff for: src/librustc_codegen_utils/symbol_export.rs

+10
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

Diff for: src/llvm-emscripten

Submodule llvm-emscripten updated 14718 files

Diff for: src/rustllvm/PassWrapper.cpp

+1-1
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;

Diff for: src/test/run-fail/mir_drop_panics.rs

+1-1
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
}

Diff for: src/test/run-fail/panic-set-handler.rs

+1-1
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
}

Diff for: src/test/run-pass/consts/const-endianess.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323
assert_eq!(BE_U32, b(55u32).to_be());
2424
assert_eq!(LE_U32, b(55u32).to_le());
2525

26-
#[cfg(not(target_arch = "asmjs"))]
26+
#[cfg(not(target_os = "emscripten"))]
2727
{
2828
const BE_U128: u128 = 999999u128.to_be();
2929
const LE_I128: i128 = (-999999i128).to_le();

Diff for: src/test/ui/inline-asm-bad-constraint.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// Test that the compiler will catch invalid inline assembly constraints.
1212

13+
// ignore-emscripten
14+
1315
#![feature(asm)]
1416

1517
extern "C" {

Diff for: src/test/ui/inline-asm-bad-constraint.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0668]: malformed inline assembly
2-
--> $DIR/inline-asm-bad-constraint.rs:29:9
2+
--> $DIR/inline-asm-bad-constraint.rs:31:9
33
|
44
LL | asm!("" :"={rax"(rax)) //~ ERROR E0668
55
| ^^^^^^^^^^^^^^^^^^^^^^
66

77
error[E0668]: malformed inline assembly
8-
--> $DIR/inline-asm-bad-constraint.rs:37:9
8+
--> $DIR/inline-asm-bad-constraint.rs:39:9
99
|
1010
LL | asm!("callq $0" : : "0"(foo)) //~ ERROR E0668
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error[E0668]: malformed inline assembly
14-
--> $DIR/inline-asm-bad-constraint.rs:44:9
14+
--> $DIR/inline-asm-bad-constraint.rs:46:9
1515
|
1616
LL | asm!("addb $1, $0" : "={rax}"((0i32, rax))); //~ ERROR E0668
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Diff for: src/test/ui/inline-asm-bad-operand.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// Test that the compiler will catch passing invalid values to inline assembly
1212
// operands.
1313

14+
// ignore-emscripten
15+
1416
#![feature(asm)]
1517

1618
#[repr(C)]

Diff for: src/test/ui/inline-asm-bad-operand.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
error[E0669]: invalid value for constraint in inline assembly
2-
--> $DIR/inline-asm-bad-operand.rs:29:24
2+
--> $DIR/inline-asm-bad-operand.rs:31:24
33
|
44
LL | asm!("" :: "r"("")); //~ ERROR E0669
55
| ^^
66

77
error[E0669]: invalid value for constraint in inline assembly
8-
--> $DIR/inline-asm-bad-operand.rs:34:32
8+
--> $DIR/inline-asm-bad-operand.rs:36:32
99
|
1010
LL | asm!("ret" : : "{rdi}"(target)); //~ ERROR E0669
1111
| ^^^^^^
1212

1313
error[E0669]: invalid value for constraint in inline assembly
14-
--> $DIR/inline-asm-bad-operand.rs:41:29
14+
--> $DIR/inline-asm-bad-operand.rs:43:29
1515
|
1616
LL | unsafe { asm!("" :: "i"(hello)) }; //~ ERROR E0669
1717
| ^^^^^
1818

1919
error[E0669]: invalid value for constraint in inline assembly
20-
--> $DIR/inline-asm-bad-operand.rs:49:38
20+
--> $DIR/inline-asm-bad-operand.rs:51:38
2121
|
2222
LL | asm!("movups $1, %xmm0"::"m"(arr)); //~ ERROR E0669
2323
| ^^^
2424

2525
error[E0669]: invalid value for constraint in inline assembly
26-
--> $DIR/inline-asm-bad-operand.rs:56:32
26+
--> $DIR/inline-asm-bad-operand.rs:58:32
2727
|
2828
LL | asm!("mov sp, $0"::"r"(addr)); //~ ERROR E0669
2929
| ^^^^
3030

3131
error[E0669]: invalid value for constraint in inline assembly
32-
--> $DIR/inline-asm-bad-operand.rs:63:32
32+
--> $DIR/inline-asm-bad-operand.rs:65:32
3333
|
3434
LL | asm!("mov sp, $0"::"r"(addr), //~ ERROR E0669
3535
| ^^^^
3636

3737
error[E0669]: invalid value for constraint in inline assembly
38-
--> $DIR/inline-asm-bad-operand.rs:64:32
38+
--> $DIR/inline-asm-bad-operand.rs:66:32
3939
|
4040
LL | "r"("hello e0669")); //~ ERROR E0669
4141
| ^^^^^^^^^^^^^

Diff for: src/test/ui/issues/issue-49579.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
1211
// compile-pass
12+
// ignore-emscripten no i128 support
1313

1414
#![feature(nll)]
1515

Diff for: src/test/ui/range/issue-54505-no-std.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use core::ops::RangeBounds;
1313

14-
#[cfg(not(target_arch = "wasm32"))]
14+
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
1515
#[lang = "eh_personality"]
1616
extern fn eh_personality() {}
1717

Diff for: src/tools/compiletest/src/runtest.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1870,11 +1870,9 @@ impl<'test> TestCx<'test> {
18701870
} else {
18711871
self.fatal("no NodeJS binary found (--nodejs)");
18721872
}
1873-
}
1874-
1875-
// If this is otherwise wasm , then run tests under nodejs with our
1873+
// If this is otherwise wasm, then run tests under nodejs with our
18761874
// shim
1877-
if self.config.target.contains("wasm32") {
1875+
} else if self.config.target.contains("wasm32") {
18781876
if let Some(ref p) = self.config.nodejs {
18791877
args.push(p.clone());
18801878
} else {

0 commit comments

Comments
 (0)