Skip to content

-sWASM_ESM_INTEGRATION incompatibility with metadce #27217

Description

@guybedford

When building with -sWASM_ESM_INTEGRATION and say -O3, there's a JS optimizer assertion failure.

Example:

emcc test/hello_world.c -sWASM_ESM_INTEGRATION -sEXPORT_ES6 -O3 -o out.mjs

Result:

AssertionError [ERR_ASSERTION]: could not find the assignment to "wasmImports".
perhaps --pre-js or --post-js code moved it out of the global scope? ...
    at Object.<anonymous> (.../tools/acorn-optimizer.mjs:...)   // emitDCEGraph
emcc: error: '... acorn-optimizer.mjs <tmp>.js emitDCEGraph --no-print --export-es6' failed (returned 1)

The issue is that wasmImports is gated out under WASM_ESM_INTEGRATION in src/preamble.js:718.

The metadce needs to either be disabled or somehow be taught the ESM integration graph I believe here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions