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

wasm-validator errors when trying to compile rust-brotli to wasm32 #42518

Closed
lilianmoraru opened this issue Jun 7, 2017 · 4 comments
Closed
Labels
C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/

Comments

@lilianmoraru
Copy link

rustc stable: rustc 1.17.0 (56124ba 2017-04-24)
rustc nightly: rustc 1.19.0-nightly (76242ae 2017-06-06)
emcc:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.37.13
clang version 4.0.0 (https://github.com/kripken/emscripten-fastcomp-clang/ a1ed3cfe03ddc6c3a581adc412276e7841df8e5f) (https://github.com/kripken/emscripten-fastcomp/ cd8feb18426289a8ed7a7ac9e5dac2ea663d09bf) (emscripten 1.37.13 : 1.37.13)

I tried to compile Dropbox's rust-brotli to Wasm32 and the results look like this, on both Rust stable and nightly:

  • [Pass] --target=asmjs-unknown-emscripten
  • [Pass] --target=asmjs-unknown-emscripten --features "no-stdlib"
  • [Fail] --target=wasm32-unknown-emscripten
  • [Fail] --target=wasm32-unknown-emscripten --features "no-stdlib"

Note that the base library that it uses for decompression, compiled alright in all combinations.
I also tested on a "Hello World" binary and all compiles ok.


Here are the logs(sorry, these are to big for gist and also Git doesn't want to accept the archive in this issue) for cargo +nightly build --target=wasm32-unknown-emscripten --verbose:

@malbarbo
Copy link
Contributor

malbarbo commented Jun 9, 2017

Some libc definitions are wrong for emscripten target, see rust-lang/libc#610.

Here is a small example that fails to compile:

use std::fs::File;
use std::io::{Seek, SeekFrom};

fn main() {
    let mut f = File::open("x.txt").unwrap();
    f.set_len(5).unwrap();
    f.seek(SeekFrom::Start(2)).unwrap();
}

It works for asmjs (I think because there is no validation), but fails for wasm32. The error is:

[wasm-validator error in function $__ZN3std2fs4File7set_len17h668c1fb11d26e7feE] 2 != 1: call param types must match, on
[i32] (call $_ftruncate
 [i32] (get_local $3)
 [i64] (get_local $2)
)
[wasm-validator error in function $__ZN47__LT_std__fs__File_u20_as_u20_std__io__Seek_GT_4seek17h53361e7da9834951E] 2 != 1: call param types must match, on
[i32] (call $_lseek
 [i32] (get_local $5
 [i64] (get_local $22)
 [i32] (get_local $24)
)

The problem is that off_t should be i32 but was i64. Although the libc patch are tested against asmjs, I think that it will work for wasm32.

After the libc PR get merged, it is necessary to update libc in rust. Well, I hope this assertions are correct, after all, the tests are green.

@sanxiyn sanxiyn added the O-wasm Target: WASM (WebAssembly), http://webassembly.org/ label Jun 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@lilianmoraru
Copy link
Author

Still doesn't compile on nightly :(
Even with --features no-stdlib

@Enselic
Copy link
Member

Enselic commented Sep 21, 2023

Triage: Is this still a problem 6 years later? (If it would be easy to check I would check myself, but doesn't seem easy to check.)

@Enselic
Copy link
Member

Enselic commented Apr 18, 2024

Triage: Assuming not a problem any longer. Closing.

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Apr 18, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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