Skip to content

Function signature mismatch when targetting wasm32-unknown-emscripten #954

@curiousdannii

Description

@curiousdannii

I have an exported Rust function:

#[no_mangle]
pub extern "C" fn gidispatch_get_objrock_fileref(ptr: FileRefPtr) -> DispatchRockPtr {
    ...
}

Which is called from a support C function:

extern gidispatch_rock_t gidispatch_get_objrock_fileref(void *obj);

gidispatch_rock_t gidispatch_get_objrock(void *obj, glui32 objclass) {
    switch (objclass) {
        case gidisp_Class_Fileref:
            return gidispatch_get_objrock_fileref(obj);
    }
}

Everything works fine with on x86_64-unknown-linux-gnu, but now that I'm trying to target wasm32-unknown-emscripten I'm suddenly getting an error:

wasm-ld: error: function signature mismatch: gidispatch_get_objrock_fileref
>>> defined as (i32, i32) -> void in /src/remglk/target/wasm32-unknown-emscripten/debug/libremglk_capi.a(support.o)
>>> defined as (i32) -> i32 in /src/remglk/target/wasm32-unknown-emscripten/debug/libremglk_capi.a(remglk_capi-e60aef9700ee309a.590b7ctqlq0880bk.rcgu.o)

It's like it's turned the return into a second argument. #715 looks similar, but I'm not targeting wasm32-unknown-unknown.

Any ideas how to get this working?

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

    Issue actions