Description
Hi,
I'm trying to compile with IPO/LTO and I'm getting:
wasm-ld: warning: function signature mismatch: _ZN12wre_frontend12ModelFactory11createModelERKNSt3__212basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE
defined as () -> void in ModelFactory.cpp.o
defined as (i32, i32, i32) -> void in lto.tmp
Without IPO/LTO there isn't any wasm-ld warning.
This maybe happen because the function implementation is defined in a different compilation unit from the EMSCRIPTEN_BINDINGS usage. This function isn't used except in the bindings:
emscripten::class_<wre_frontend::ModelFactory>(“ModelFactory”)
.constructor<>()
.function(“createModel”, &wre_frontend::ModelFactory::createModel);
Adding attribute((used)) to the function doesn't solve the issue.
I tried both with SDK 1.39.7 and 1.39.11.
The workaround: replace the function binding with a wrapper that exists in same compilation unit of the binding (implemented in the header file of the class). The wrapper calls the original function.
Related issue:
I would like to have linker warnings treated as errors.
Neither -Werror nor -Xlinker --fatal-warnings error out the function signature mismatch.
According to https://lld.llvm.org/WebAssembly.html - The --fatal-warnings flag can be used to disable generating stub functions and error out if mismatched are found.