Skip to content

WASM/WebAssembly fail in debug, success in release #251

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
adiba opened this issue Jan 26, 2018 · 2 comments
Closed

WASM/WebAssembly fail in debug, success in release #251

adiba opened this issue Jan 26, 2018 · 2 comments

Comments

@adiba
Copy link

adiba commented Jan 26, 2018

The playground on nightly in debug mode fails to compile the below code to WASM with following error:

error: expected function name count (598) <= function count (441)
00257ca: error: OnFunctionNamesCount callback failed

It compiles fine in release mode.

I should also mention that there is a bug in the resulting wasm code when opt-level=0, see rust-lang/rust#47776.

fn main() {}
extern {
    fn log_i32(val: i32);
}

#[no_mangle]
pub fn run() {
    let s = "Tre".as_bytes();
    let len = s.len();
    unsafe {
        log_i32(len as i32);
    }
}
@shepmaster
Copy link
Member

That error is pretty ugly which makes me think it's not coming from Rust.

You can see the steps we perform after compilation:

https://github.com/integer32llc/rust-playground/blob/964fff159d7925c8121244b4db3fa29d2f5bcdad/compiler/base/cargo-wasm#L38-L51

Perhaps you could try those with your code and see if either tool fails? It might help pinpoint details with your correctness issue as well.

@shepmaster
Copy link
Member

This works now, so assuming it was an upstream issue.

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

2 participants