Skip to content

Fails to compile with "no function table found in module" #1967

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

Closed
hexpunk opened this issue Jan 21, 2020 · 2 comments · Fixed by #1970
Closed

Fails to compile with "no function table found in module" #1967

hexpunk opened this issue Jan 21, 2020 · 2 comments · Fixed by #1970
Labels

Comments

@hexpunk
Copy link

hexpunk commented Jan 21, 2020

Describe the Bug

Could not compile due to error:

error: failed to generate bindings for import of `__wbindgen_placeholder__::__wbindgen_closure_wrapper28`

Caused by:
    no function table found in module
Error: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit code: 1

Steps to Reproduce

Use the following code in lib.rs, which the compiler says is correct:

use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::console::{log_1, profile_0, profile_end_0};
use web_sys::window;

#[wasm_bindgen(start)]
pub fn run() {
    let win = window().expect("no global `window` exists");

    profile_0();

    log_1(&"Hello from Rust!".into());

    let cb = Closure::wrap(Box::new(profile_end_0) as Box<dyn Fn()>);

    win.set_timeout_with_callback_and_timeout_and_arguments_0(cb.as_ref().unchecked_ref(), 5)
        .expect("could not set timeout");

    cb.forget();
}

Try to compile by running wasm-pack build with any combination of options.

Expected Behavior

Compile and run without issue.

Actual Behavior

Receive the error message:

error: failed to generate bindings for import of `__wbindgen_placeholder__::__wbindgen_closure_wrapper28`

Caused by:
    no function table found in module
Error: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit code: 1

Additional Context

I'm using wasm-bindgen 0.2.58 and web-sys 0.3.35.

@hexpunk hexpunk added the bug label Jan 21, 2020
@hexpunk
Copy link
Author

hexpunk commented Jan 21, 2020

This appears to be a regression as this occurs in versions 0.2.58, 0.2.57, and 0.2.56, but not in 0.2.55. That version appears to work just fine.

alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Jan 21, 2020
The main gc pass of unused items in wasm-bindgen was accidentally
removing the function table because we weren't properly rooting it in
the auxiliary section which has a few ways that imports can reference
the function table via intrinsics and closures.

Closes rustwasm#1967
@alexcrichton
Copy link
Contributor

Thanks for the report! Looks like this was an internal mistake and should be fixed in #1970

alexcrichton added a commit that referenced this issue Jan 21, 2020
The main gc pass of unused items in wasm-bindgen was accidentally
removing the function table because we weren't properly rooting it in
the auxiliary section which has a few ways that imports can reference
the function table via intrinsics and closures.

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

Successfully merging a pull request may close this issue.

2 participants