Skip to content

embedding CPython in emscripten build requires stringToNewUTF8 symbol #156243

Description

@davidhewitt

Bug report

Bug description:

In the PyO3 CI I am testing out building emscripten CPython with 3.15rc1. I get a failure when executing the webassembly module:

warning: stringToNewUTF8 is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='$stringToNewUTF8')

TypeError: stringToNewUTF8 is not a function
    at _Py_emscripten_runtime (/home/david/dev/pyo3/target/wasm32-unknown-emscripten/debug/deps/pyo3-a56cdf8abaaca849.js:8007:500)

It looks like the symbol comes from

return BigInt(stringToNewUTF8(info));


I can hack around this with a compiler flag in the PyO3 build scripts. Local AI is telling me that CPython might want to consider adding an EM_JS_DEPS declaration near to the above to link the correct symbol without downstream users having to think about it. I guess either that's actually something worth doing, or this issue can be closed.

cc @hoodmane

CPython versions tested on:

3.15, 3.16, CPython main branch

Operating systems tested on:

Other

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions