Skip to content

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

Closed as not planned

Description

@lilianmoraru

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:

Activity

  1. malbarbo commented on Jun 9, 2017

    @malbarbo
    Contributor

    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.

  2. added
    O-wasmTarget: WASM (WebAssembly), http://webassembly.org/
    on Jun 9, 2017
  3. lilianmoraru commented on Sep 6, 2017

    @lilianmoraru
    Author

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

  4. Enselic commented on Sep 21, 2023

    @Enselic
    Member

    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.)

  5. Enselic commented on Apr 18, 2024

    @Enselic
    Member

    Triage: Assuming not a problem any longer. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions