Skip to content

Commit d0b68c0

Browse files
committed
Rollup merge of rust-lang#55845 - nikic:emscripten-clamp-mode, r=alexcrichton
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. ;
2 parents 75e920f + 48aa602 commit d0b68c0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/librustc_target/spec/wasm32_unknown_emscripten.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@
1111
use super::{LinkArgs, LinkerFlavor, Target, TargetOptions};
1212

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

2127
let opts = TargetOptions {
2228
dynamic_linking: false,

0 commit comments

Comments
 (0)