From 2bafbba655888c288e43ce107cc4bfdf6e758ca3 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 19 Jan 2017 22:31:57 +0300 Subject: [PATCH 1/3] tell emcc stip exception handling if panic rt used --- src/librustc_back/target/asmjs_unknown_emscripten.rs | 1 + src/librustc_back/target/mod.rs | 5 +++++ src/librustc_back/target/wasm32_unknown_emscripten.rs | 1 + src/librustc_trans/back/link.rs | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/src/librustc_back/target/asmjs_unknown_emscripten.rs b/src/librustc_back/target/asmjs_unknown_emscripten.rs index 2dbaeaf26e970..4d38b0d170596 100644 --- a/src/librustc_back/target/asmjs_unknown_emscripten.rs +++ b/src/librustc_back/target/asmjs_unknown_emscripten.rs @@ -22,6 +22,7 @@ pub fn target() -> Result { linker_is_gnu: true, allow_asm: false, obj_is_bitcode: true, + is_like_emscripten: true, max_atomic_width: Some(32), post_link_args: vec!["-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()], target_family: Some("unix".to_string()), diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 5afa85d155279..9c30057d4189c 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -330,6 +330,10 @@ pub struct TargetOptions { /// Whether the target toolchain is like Android's. Only useful for compiling against Android. /// Defaults to false. pub is_like_android: bool, + /// Whether the target toolchain is like Emscripten's. Only useful for compiling with + /// Emscripten toolchain. + /// Defaults to false. + pub is_like_emscripten: bool, /// Whether the linker support GNU-like arguments such as -O. Defaults to false. pub linker_is_gnu: bool, /// The MinGW toolchain has a known issue that prevents it from correctly @@ -428,6 +432,7 @@ impl Default for TargetOptions { is_like_solaris: false, is_like_windows: false, is_like_android: false, + is_like_emscripten: false, is_like_msvc: false, linker_is_gnu: false, allows_weak_linkage: true, diff --git a/src/librustc_back/target/wasm32_unknown_emscripten.rs b/src/librustc_back/target/wasm32_unknown_emscripten.rs index a06980767fd75..b1967fa8f37a7 100644 --- a/src/librustc_back/target/wasm32_unknown_emscripten.rs +++ b/src/librustc_back/target/wasm32_unknown_emscripten.rs @@ -24,6 +24,7 @@ pub fn target() -> Result { linker_is_gnu: true, allow_asm: false, obj_is_bitcode: true, + is_like_emscripten: true, max_atomic_width: Some(32), post_link_args: vec!["-s".to_string(), "BINARYEN=1".to_string(), "-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()], diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index defbb44448a9f..2da042da8aa50 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -29,6 +29,7 @@ use rustc::dep_graph::DepNode; use rustc::hir::def_id::CrateNum; use rustc::hir::svh::Svh; use rustc_back::tempdir::TempDir; +use rustc_back::PanicStrategy; use rustc_incremental::IncrementalHashesMap; use std::ascii; @@ -712,6 +713,11 @@ fn link_natively(sess: &Session, cmd.arg(root.join(obj)); } + if sess.target.target.options.is_like_emscripten && + sess.panic_strategy() == PanicStrategy::Abort { + cmd.arg("-s DISABLE_EXCEPTION_CATCHING=1"); + } + { let mut linker = trans.linker_info.to_linker(&mut cmd, &sess); link_args(&mut *linker, sess, crate_type, tmpdir, From 62c088c047f4a510bb2f65b550decb5bebff0f7c Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Fri, 20 Jan 2017 21:18:17 +0300 Subject: [PATCH 2/3] Separate emscripten args --- src/librustc_trans/back/link.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 2da042da8aa50..f34c19a8380f4 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -715,7 +715,7 @@ fn link_natively(sess: &Session, if sess.target.target.options.is_like_emscripten && sess.panic_strategy() == PanicStrategy::Abort { - cmd.arg("-s DISABLE_EXCEPTION_CATCHING=1"); + cmd.args(&["-s", "DISABLE_EXCEPTION_CATCHING=1"]); } { From 24cb5b7bae251b4d7d0f20e1a76728eb087d53d4 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Fri, 20 Jan 2017 21:18:51 +0300 Subject: [PATCH 3/3] Json encoding/decoding for is_like_emscripten --- src/librustc_back/target/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 9c30057d4189c..d2b76b1d55a98 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -608,6 +608,7 @@ impl Target { key!(is_like_solaris, bool); key!(is_like_windows, bool); key!(is_like_msvc, bool); + key!(is_like_emscripten, bool); key!(is_like_android, bool); key!(linker_is_gnu, bool); key!(allows_weak_linkage, bool); @@ -772,6 +773,7 @@ impl ToJson for Target { target_option_val!(is_like_solaris); target_option_val!(is_like_windows); target_option_val!(is_like_msvc); + target_option_val!(is_like_emscripten); target_option_val!(is_like_android); target_option_val!(linker_is_gnu); target_option_val!(allows_weak_linkage);