Skip to content

Commit

Permalink
Rollup merge of rust-lang#55845 - nikic:emscripten-clamp-mode, r=alex…
Browse files Browse the repository at this point in the history
…crichton

Set BINARYEN_TRAP_MODE=clamp

This fixes the wasm32-unknown-emscripten test failure mentioned in rust-lang#55626 (comment), by making binaryen operate in clamp rather than trap mode.

The issue is that the current `-Zsaturating-float-casts` implementation uses `fpto[us]i` unconditionally (and selects afterwards), which does not work with trapping implementations of fpto[su]i, which emscripten uses by default.

I've left a FIXME to drop this flag once we have a better solution for saturating casts on the LLVM side.
;
  • Loading branch information
kennytm committed Nov 11, 2018
2 parents 75e920f + 48aa602 commit d0b68c0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/librustc_target/spec/wasm32_unknown_emscripten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@
use super::{LinkArgs, LinkerFlavor, Target, TargetOptions};

pub fn target() -> Result<Target, String> {
// FIXME(nikic) BINARYEN_TRAP_MODE=clamp is needed to avoid trapping in our
// -Zsaturating-float-casts implementation. This can be dropped if/when
// we have native fpto[su]i.sat intrinsics, or the implementation otherwise
// stops relying on non-trapping fpto[su]i.
let mut post_link_args = LinkArgs::new();
post_link_args.insert(LinkerFlavor::Em,
vec!["-s".to_string(),
"BINARYEN=1".to_string(),
"-s".to_string(),
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()]);
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string(),
"-s".to_string(),
"BINARYEN_TRAP_MODE='clamp'".to_string()]);

let opts = TargetOptions {
dynamic_linking: false,
Expand Down

0 comments on commit d0b68c0

Please sign in to comment.