Skip to content

__embind_initialize_bindings is stripped from export table in Release + pthreads build #22968

@laminowany

Description

@laminowany

This is a regression in 3.1.70, on previously tested version 3.1.56 it worked correctly. My application gets undefined reference to __embind_initialize_bindings during runtime.

There is a code which adds __embind_initialize_bindings to exported symbols:

emscripten/tools/link.py

Lines 508 to 509 in 119a427

if settings.EMBIND:
settings.REQUIRED_EXPORTS.append('_embind_initialize_bindings')

but this seems to be stripped during call to binaryen:

out = run_binaryen_command('wasm-metadce',
wasm_file,
wasm_file,
args,
debug=debug_info,
stdout=PIPE)

The binaryen takes an DCEGraph as an input, and when I inspect the json of graph it has following entry:

{
    "name": "emcc$export$__embind_initialize_bindings",
    "export": "_embind_initialize_bindings",
    "reaches": []
 },

I can fix this issue by manually editing this intermediate file and changing this entry to:

   {
    "name": "emcc$export$__embind_initialize_bindings",
    "export": "_embind_initialize_bindings",
    "reaches": [],
    "root": true
  }

My guess: _embind_initialize_bindings should be marked with root: true but for some reason is not.

Another workaround is manually exporting this function via:
EXPORTED_FUNCTIONS=_main,__embind_initialize_bindings"
but I believe it should not be needed.

This issue is similiar to: #21844

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