Skip to content

Commit 2bafbba

Browse files
committed
tell emcc stip exception handling if panic rt used
1 parent 47965f5 commit 2bafbba

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

src/librustc_back/target/asmjs_unknown_emscripten.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub fn target() -> Result<Target, String> {
2222
linker_is_gnu: true,
2323
allow_asm: false,
2424
obj_is_bitcode: true,
25+
is_like_emscripten: true,
2526
max_atomic_width: Some(32),
2627
post_link_args: vec!["-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()],
2728
target_family: Some("unix".to_string()),

src/librustc_back/target/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ pub struct TargetOptions {
330330
/// Whether the target toolchain is like Android's. Only useful for compiling against Android.
331331
/// Defaults to false.
332332
pub is_like_android: bool,
333+
/// Whether the target toolchain is like Emscripten's. Only useful for compiling with
334+
/// Emscripten toolchain.
335+
/// Defaults to false.
336+
pub is_like_emscripten: bool,
333337
/// Whether the linker support GNU-like arguments such as -O. Defaults to false.
334338
pub linker_is_gnu: bool,
335339
/// The MinGW toolchain has a known issue that prevents it from correctly
@@ -428,6 +432,7 @@ impl Default for TargetOptions {
428432
is_like_solaris: false,
429433
is_like_windows: false,
430434
is_like_android: false,
435+
is_like_emscripten: false,
431436
is_like_msvc: false,
432437
linker_is_gnu: false,
433438
allows_weak_linkage: true,

src/librustc_back/target/wasm32_unknown_emscripten.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub fn target() -> Result<Target, String> {
2424
linker_is_gnu: true,
2525
allow_asm: false,
2626
obj_is_bitcode: true,
27+
is_like_emscripten: true,
2728
max_atomic_width: Some(32),
2829
post_link_args: vec!["-s".to_string(), "BINARYEN=1".to_string(),
2930
"-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()],

src/librustc_trans/back/link.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use rustc::dep_graph::DepNode;
2929
use rustc::hir::def_id::CrateNum;
3030
use rustc::hir::svh::Svh;
3131
use rustc_back::tempdir::TempDir;
32+
use rustc_back::PanicStrategy;
3233
use rustc_incremental::IncrementalHashesMap;
3334

3435
use std::ascii;
@@ -712,6 +713,11 @@ fn link_natively(sess: &Session,
712713
cmd.arg(root.join(obj));
713714
}
714715

716+
if sess.target.target.options.is_like_emscripten &&
717+
sess.panic_strategy() == PanicStrategy::Abort {
718+
cmd.arg("-s DISABLE_EXCEPTION_CATCHING=1");
719+
}
720+
715721
{
716722
let mut linker = trans.linker_info.to_linker(&mut cmd, &sess);
717723
link_args(&mut *linker, sess, crate_type, tmpdir,

0 commit comments

Comments
 (0)