Skip to content

ERROR_ON_UNDEFINED_SYMBOLS=1 always passed for emcc effectively prevents any dynamic linking #41750

Closed
@NikVolf

Description

@NikVolf

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:

"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-asmjsTarget: asm.js - http://asmjs.org/O-emscriptenTarget: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL!O-wasmTarget: WASM (WebAssembly), http://webassembly.org/

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions