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

The hello world example doesn't build #197

Closed
P-E-Meunier opened this issue May 14, 2018 · 16 comments
Closed

The hello world example doesn't build #197

P-E-Meunier opened this issue May 14, 2018 · 16 comments

Comments

@P-E-Meunier
Copy link

I get the following error on a clone of this repository, when running build.rs in examples/hello_world:

ERROR in ./hello_world_bg.wasm
Module not found: Error: Can't resolve 'env' in '/home/pe/Recherche/origami/designer-rs/wasm-bindgen/examples/hello_world'
 @ ./hello_world_bg.wasm
 @ ./hello_world.js
 @ ./index.js
 @ multi (webpack)-dev-server/client?http://localhost:8082 ./index.js
ℹ 「wdm」: Failed to compile.

I'm using the latest Rust nightly.

@xtuc
Copy link
Member

xtuc commented May 14, 2018

Yes this is likely due to Webpack new wasm pipeline.

I'll try when I'm desktop.

@alexcrichton
Copy link
Contributor

@P-E-Meunier hm I just exected this locally and it seems to have worked. Can you gist the full error you were seeing as well as the package-lock.json perhaps?

@P-E-Meunier P-E-Meunier changed the title The hello world doesn't build The hello world example doesn't build May 15, 2018
@P-E-Meunier
Copy link
Author

Wait, the add examples builds fine, with the same configuration.

@xtuc
Copy link
Member

xtuc commented May 16, 2018

I'm not able to reproduce it. It's probably something on your side @P-E-Meunier.

@P-E-Meunier
Copy link
Author

I'm a little surprised that cargo + npm/yarn are not able to make this reproducible. I'll try in a clean virtual machine with a more standard system and report back here to see where the differences are.

@xtuc
Copy link
Member

xtuc commented May 16, 2018

Could you please share your hello_world_bg.wasm?

@P-E-Meunier
Copy link
Author

P-E-Meunier commented May 16, 2018

It looks like:

(module
  (type (;0;) (func (param i32)))
  (type (;1;) (func))
  (type (;2;) (func (param i32 i32 i32)))
  (type (;3;) (func (result i32)))
  (type (;4;) (func (param i32 i32 i32 i32)))
  (type (;5;) (func (param i32 i32) (result i32)))
  (type (;6;) (func (param i32 i32 i32 i32 i32 i32 i32)))
  (type (;7;) (func (param i32 i32)))
  (type (;8;) (func (param i32 i32 i32 i32 i32)))
  (type (;9;) (func (param i32) (result i32)))
  (type (;10;) (func (param i32 i32 i32) (result i32)))
  (type (;11;) (func (param i32 i32 i32 i32) (result i32)))
  (type (;12;) (func (param i32 i32 i32 i32 i32) (result i32)))
  (import "env" "_ZN5alloc3fmt6format17h6b4a2c4b2b4848bbE" (func $alloc::fmt::format::h6b4a2c4b2b4848bb (
type 7)))
  (import "env" "_ZN42_$LT$str$u20$as$u20$core..fmt..Display$GT$3fmt17h400a3e2a654fb434E" (func $<str_as_
core::fmt::Display>::fmt::h400a3e2a654fb434 (type 10)))
  (import "env" "_ZN87_$LT$alloc..string..String$u20$as$u20$core..convert..From$LT$$RF$$u27$a$u20$str$GT$
$GT$4from17he22ed9faae460b39E" (func $<alloc::string::String_as_core::convert::From<&'a_str>>::from::he22
ed9faae460b39 (type 2)))
  (import "env" "__rdl_alloc" (func $__rdl_alloc (type 5)))
  (import "env" "__rdl_dealloc" (func $__rdl_dealloc (type 2)))
  (import "env" "__rdl_realloc" (func $__rdl_realloc (type 11)))
  (import "env" "_ZN4core9panicking5panic17h67bd905640162afcE" (func $core::panicking::panic::h67bd905640
162afc (type 0)))
  (import "env" "_ZN5alloc5alloc3oom17h879a831cffc2bb90E" (func $alloc::alloc::oom::h879a831cffc2bb90 (ty
pe 1)))
  (import "env" "_ZN4core9panicking18panic_bounds_check17h7ac5dc694968f21bE" (func $core::panicking::pani
c_bounds_check::h7ac5dc694968f21b (type 2)))
  (import "./hello_world" "__wbindgen_throw" (func $__wbindgen_throw (type 7)))
  (func $core::ptr::drop_in_place::h2311fbbd9a4ae244 (type 0) (param i32)
    (local i32 i32 i32)
    get_global 0
    set_local 1
    i32.const 16
    set_local 2
    get_local 1
    get_local 2
    i32.sub
    set_local 3
    get_local 3
    get_local 0
    i32.store offset=12
    return)
  (func $hello_world::generate_greeting::h333ef058df030260 (type 0) (param i32)
    (local i32 i32 i32)
    i32.const 1744
    set_local 1
    get_local 1
    set_local 2
    i32.const 13
    set_local 3
    get_local 0
    get_local 2
    get_local 3
    call $<str_as_alloc::string::ToString>::to_string::h4368959bf9342e2c
    return)
  (func $generate_greeting (type 0) (param i32)
    (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i64 i32 i32 i32 i32 i32 i32 i32 i32 i32 i3
2 i32 i32 i32 i32 i32 i32 i32)
    get_global 0
    set_local 1
    i32.const 48
    set_local 2
    get_local 1
    get_local 2



[…]




    i32.add
    set_local 18
    get_local 18
    set_global 0
    get_local 16
    return)
  (table (;0;) 5 5 anyfunc)
  (memory (;0;) 17)
  (global (;0;) (mut i32) (i32.const 1051200))
  (export "memory" (memory 0))
  (export "generate_greeting" (func $generate_greeting))
  (export "generate_custom_greeting" (func $generate_custom_greeting))
  (export "__wbindgen_malloc" (func $__wbindgen_malloc))
  (export "__wbindgen_free" (func $__wbindgen_free))
  (export "__wbindgen_global_argument_ptr" (func $__wbindgen_global_argument_ptr))
  (elem (i32.const 1) $<&'a_T_as_core::fmt::Display>::fmt::h1be0fdfbbafff573 $core::ptr::drop_in_place::h2311fbbd9a4ae244 $<wasm_bindgen::convert::GlobalStack_as_wasm_bindgen::convert::Stack>::push::hc047f85f64a912e4 $<wasm_bindgen::convert::GlobalStack_as_wasm_bindgen::convert::Stack>::pop::h9160b53383762229)
  (data (i32.const 1024) "\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00\01gdb_load_rust_pretty_printers.py\00")
  (data (i32.const 1744) "Hello, world!Hello, !\00\00\00\01\00\00\00\00\00\00\00 \00\00\00\00\00\00\00\03\00\00\00\00\00\00\00\03\00\00\00\00\00\00\00\03\00\00\00Tried to shrink to a larger capacityliballoc/raw_vec.rs\00\00\00\00\00\00\00\00\00\00\00\00\00/checkout/src/liballoc/raw_vec.rsnull pointer passed to rustrecursive use of an object detected which would lead to unsafe aliasing in rustinvalid malloc requestassertion failed: self.next < GLOBAL_STACK_CAP/home/pe/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/wasm-bindgen-0.2.9/src/convert.rs\00\00\00\00\00\00\00/home/pe/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/wasm-bindgen-0.2.9/src/convert.rs\00\00\00\00\00\00attempt to add with overflowclosure invoked recursively or destroyed already")
  (data (i32.const 2348) "\02\00\00\00\04\00\00\00\04\00\00\00\03\00\00\00\04\00\00\00\dd\06\00\00\07\00\00\00\e4\06\00\00\01\00\00\00\0c\07\00\00$\00\00\000\07\00\00\13\00\00\00\81\02\00\00\09\00\00\00P\07\00\00!\00\00\00D\00\00\00\12\00\00\00\f1\07\00\00.\00\00\00\1f\08\00\00Z\00\00\00p\01\00\00\0d\00\00\00\80\08\00\00Z\00\00\00q\01\00\00\0d\00\00\00\e0\08\00\00\1c\00\00\00\80\08\00\00Z\00\00\00r\01\00\00\0d\00\00\00\f1\07\00\00.\00\00\00\1f\08\00\00Z\00\00\00x\01\00\00\0d\00\00\00\80\08\00\00Z\00\00\00y\01\00\00\17\00\00\00\e0\08\00\00\1c\00\00\00\80\08\00\00Z\00\00\00z\01\00\00\0d\00\00\00")
  (data (i32.const 2552) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"))

Or a full version: https://gist.github.com/P-E-Meunier/76b6073c1b8ae59c3750476033d448fe

@xtuc
Copy link
Member

xtuc commented May 16, 2018

Did you modify the example? The issue is that you have an env module in the imports.

I have:

  (import "./hello_world" "__wbg_f_alert_alert_n" (func $__wbg_f_alert_alert_n (param i32) (param i32)))
  (import "./hello_world" "__wbindgen_throw" (func $__wbindgen_throw (param i32) (param i32)))

Do you have an idea @alexcrichton?

@alexcrichton
Copy link
Contributor

Old historical toolchains may have had that bug, but @P-E-Meunier you have a fully updated toolchain, right? And you're using the official binaries shipped by rust-lang/rust?

@P-E-Meunier
Copy link
Author

Yes, according to rustc --version, I do have the latest nightly.
However, I'm using a nonstandard setup: I get my binaries from the rustup server, but not using rustup (using NixOS instead).

It seems there's something wrong with the installer. What part of the toolchain can cause this? Where should I look if I wanted to fix this?

@alexcrichton
Copy link
Contributor

The Rust compile rewrites imports after LLD has executed to fix the module that items are imported from, so if you're using the official binaries I'm not sure how this error would come up :(

It does sound like a local toolchain isssue, though, I'm just not sure how!

@alexcrichton
Copy link
Contributor

I'm gonna close this for now as it seemed like this was a local toolchain issue, but if it turns out to be a wasm-bindgen issue please let me know!

@David-OConnor
Copy link
Member

David-OConnor commented Jul 16, 2018

Same issue. I'll post details if I can narrow it down.

edit: Narrowed down. Using the Yew frontend library triggers it. Including it in Cargo.toml doesn't, but using extern crate yew; does.

@alexcrichton
Copy link
Contributor

@David-OConnor oh dear sounds bad! If you've got a reproduction feel free to file a new issue at any time!

@sciyoshi
Copy link

sciyoshi commented Aug 1, 2018

Looks like the info here could be relevant: rust-random/rand#478 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants