Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f32::rem fails on wasm32-unknown-emscripten #42629

Closed
malbarbo opened this issue Jun 13, 2017 · 4 comments
Closed

f32::rem fails on wasm32-unknown-emscripten #42629

malbarbo opened this issue Jun 13, 2017 · 4 comments
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/

Comments

@malbarbo
Copy link
Contributor

This example (test for issue #27859):

#[inline(never)]
fn foo(a: f32, b: f32) -> f32 {
    a % b
}

#[inline(never)]
fn bar(a: f32, b: f32) -> f32 {
    ((a as f64) % (b as f64)) as f32
}

fn main() {
    let unknown_float = std::env::args().len();
    println!("{}", foo(4.0, unknown_float as f32));
    println!("{}", foo(5.0, (unknown_float as f32) + 1.0));
    println!("{}", bar(6.0, (unknown_float as f32) + 2.0));
    println!("{}", bar(7.0, (unknown_float as f32) + 3.0));
}

fails to compile for wasm32-unknown-emscripten with the error:

[wasm-validator error in function $__ZN1x3foo17h4d65114cf314b7c3E] 3 != 4: call param types must match, on
[f64] (call $f64-rem
 [f32] (get_local $4)
 [f32] (get_local $5)
)
malbarbo added a commit to malbarbo/rust that referenced this issue Jun 13, 2017
bors added a commit that referenced this issue Jun 16, 2017
Add a travis builder for wasm32-unknown-emscripten

This commits add an entry to travis matrix that will execute wasm32-unknown-emscripten tests suites.

- Emscripten for asmjs was updated to sdk-1.37.13-64bit
- The tests are run with node 8.0.0 (it can execute wasm)
- A wrapper script is used to run each test from the directory where it is (workaround for emscripten-core/emscripten#4542)
- Some tests are ignore, see #42629 and #42630
@Mark-Simulacrum Mark-Simulacrum added A-testsuite Area: The testsuite used to check the correctness of rustc O-wasm Target: WASM (WebAssembly), http://webassembly.org/ labels Jun 23, 2017
@CryZe
Copy link
Contributor

CryZe commented Jul 20, 2017

Looks like my code has also hit this bug: https://travis-ci.org/CryZe/livesplit-core/jobs/255487184#L401

Do we know where this bug is? If so, I probably want to try to fix it.

It seems like in my case I don't even have f64 at all, and yet it still uses f64-rem.

@pepyakin
Copy link
Contributor

pepyakin commented Jul 20, 2017

Minimized example:

define float @foo(float, float) unnamed_addr #2 {
start:
  %2 = frem float %0, %1
  ret float %2
}
emcc -s BINARYEN=1 -s "EXPORTED_FUNCTIONS=['_foo']" example.ll

Gives following output (stripped):

[wasm-validator error in function $_foo] 3 != 4: call param types must match[wasm-validator error in function $_foo] 3 != 4: call param types must match, on
[f64] (call $f64-rem
 [f32] (get_local $0)
 [f32] (get_local $1)
), on
[f64] (call $f64-rem
 [f32] (get_local $0)
 [f32] (get_local $1)
)
(on argument
(on argument 0)
0)
[wasm-validator error in function $_foo] [wasm-validator error in function $_foo] 3 != 4: 3 != 4: call param types must match, on
[f64call param types must match, on
[f64] (call $] (call $f64-rem
 [f64-rem
 [f32] (get_local f32] (get_local $0)
$0)
 [f32]  [f32] (get_local $1(get_local $1)
)
)
)
(on argument 1)

It seems like problem lies in Emscripten side of things.

@pepyakin
Copy link
Contributor

pepyakin commented Jul 20, 2017

Should be fixed by WebAssembly/binaryen#1106

@alexcrichton
Copy link
Member

Looks like upstream fix (WebAssembly/binaryen#1106) is merged so closing, yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/
Projects
None yet
Development

No branches or pull requests

5 participants