Closed
Description
the following rust code is failing to compile using wasm32-unknown-emscripten target
extern {
#[link(name="env")]
fn log_event(id: *const u8);
}
fn main() {
unsafe { log_event(::std::ptr::null()); }
}
with
error: unresolved symbol: log_event
correct me if I'm wrong, I might be terrible wrong with this, but #[link]
without kind=static
implies dynamic linking, and the above code should not fail to compile?
As for emscripten itself, it has no problem compiling C code like this:
extern void log_event(void* ptr);
int main() {
log_event(0);
}
with emcc <source above.c> -O3 -s WASM=1 -s SIDE_MODULE=1 -o result.wasm
producing nice import entry in the result.wasm
(import "env" "_log_event" (func (;0;) (type 0)))
So, the question is, is there is any option to have dynamic symbols in the resulting wasm? Or at least override this linker ERROR_ON_UNDEFINED_SYMBOLS
argument at some point?
source link would be: