Skip to content

Second Webassembly fn import of the same name but different module name is ignored #12880

Closed

Description

@Pyrolistical

Zig Version

0.10.0-dev.4060+61aaef0b0

Steps to Reproduce

  1. Create two files that both import a function of the same name, but with different module names
  2. Import two files into a 3rd one and call both functions.
  3. Make webassembly build
  4. Decompile webassembly
  5. Observe the declared import functions

a.zig

pub extern "a" fn hello() i32;

b.zig

pub extern "b" fn hello() i32;

double-hello.zig

const a = @import("a.zig");
const b = @import("b.zig");

extern "env" fn out(value: i32) void;
export fn doubleHello() void {
    out(a.hello());
    out(b.hello());
}

build command zig build-lib double-hello.zig -target wasm32-freestanding -dynamic

decompile double-hello.wasm using https://webassembly.github.io/wabt/demo/wasm2wat/

Expected Behavior

In decompiled wasm, expected two hello functions.

  (import "a" "hello" (func $a_hello ...
  (import "b" "hello" (func $b_hello ...

Actual Behavior

In decompiled wasm, only found a.hello

  (import "a" "hello" (func $hello ...

Activity

  1. added
    bug
    on Sep 17, 2022
  2. Pyrolistical commented on Sep 17, 2022

    @Pyrolistical
    ContributorAuthor

    What is really bad about this bug is all calls to b.hello go to a.hello and that is really hard to detect. I got random errors with "bitcast invalid" but that was a red herring.

  3. added
    frontend
    arch-wasm
    on Sep 18, 2022
  4. modified the milestones: 0.10.0, 0.11.0 on Sep 18, 2022
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

    arch-wasmbugfrontend

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions