Skip to content

Question: dealing with "Imported global cannot be mutable in wasm-opt" #14460

@hoodmane

Description

@hoodmane

While working on upgrading Pyodide to Python3.9 I run into the following errors from wasm-opt when compiling packages (which are SIDE_MODULEs linked against Python stdlib):
[wasm-validator error in module] unexpected true: Imported global cannot be mutable
This occurs in a call like the following:

wasm-opt --strip-dwarf --post-emscripten --no-exit-runtime -O2 --low-memory-unused --fpcast-emu --pass-arg=max-func-params@61 --strip-debug --strip-producers build/lib.linux-x86_64-3.9/PIL/_imagingft.cpython-39-x86_64-linux-gnu.so -o build/lib.linux-x86_64-3.9/PIL/_imagingft.cpython-39-x86_64-linux-gnu.so --mvp-features

I found that if I remove --mvp-features and add --enable-mutable-globals then the build succeeds and the test suite passes.

I made the following patch to remove --mvp-features and add --enable-mutable-globals to the wasm-opt calls:
https://github.com/hoodmane/pyodide/blob/python-3.9/emsdk/patches/fix-wasm-validator-error.patch

My question is whether there is a better way to do this or a way to do it without patching emsdk.

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