Skip to content

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

Closed
@adiba

Description

@adiba

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);
    }
}

Activity

shepmaster

shepmaster commented on Jan 26, 2018

@shepmaster
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

shepmaster commented on Apr 20, 2018

@shepmaster
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @shepmaster@adiba

        Issue actions

          WASM/WebAssembly fail in debug, success in release · Issue #251 · rust-lang/rust-playground