Repository navigation
Emscripten build fails with Python 3.14 #137025
Copy link
Copy link
Closed
Labels
3.14bugs and security fixesbugs and security fixesOS-emscriptendocsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Bug report
Bug description:
I tried to use emsdk 4.10.0 and ran ./Tools/wasm/wasm_build.py emscripten-browser build repl against the v3.14.0rc1 branch, but the build failed:
configure: error: You must get working getaddrinfo() function or pass the "--disable-ipv6" option to configure.
emconfigure: error: '../../configure -C --host=wasm32-unknown-emscripten --build=x86_64-unknown-linux-gnu --with-emscripten-target=browser --enable-wasm-dynamic-linking --with-build-python=/tmp/wasm/cpython/builddir/build/python CONFIG_SITE=/tmp/wasm/cpython/Tools/wasm/config.site-wasm32-emscripten' failed (returned 1)
Traceback (most recent call last):
File "/tmp/wasm/cpython/./Tools/wasm/wasm_build.py", line 932, in <module>
main()
~~~~^^
File "/tmp/wasm/cpython/./Tools/wasm/wasm_build.py", line 902, in main
builder.run_build(*cm_args)
~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/tmp/wasm/cpython/./Tools/wasm/wasm_build.py", line 571, in run_build
self.run_configure(*args)
~~~~~~~~~~~~~~~~~~^^^^^^^
File "/tmp/wasm/cpython/./Tools/wasm/wasm_build.py", line 577, in run_configure
return self._run_cmd(self.configure_cmd, args)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/wasm/cpython/./Tools/wasm/wasm_build.py", line 557, in _run_cmd
return subprocess.check_call(
~~~~~~~~~~~~~~~~~~~~~^
cmd,
^^^^
cwd=os.fspath(cwd),
^^^^^^^^^^^^^^^^^^^
env=self.getenv(),
^^^^^^^^^^^^^^^^^^
)
^
File "/home/trey/.local/share/uv/python/cpython-3.13.1-linux-x86_64-gnu/lib/python3.13/subprocess.py", line 419, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/emsdk/upstream/emscripten/emconfigure', '../../configure', '-C', '--host=wasm32-unknown-emscripten', '--build=x86_64-unknown-linux-gnu', '--with-emscripten-target=browser', '--enable-wasm-dynamic-linking', '--with-build-python=/tmp/wasm/cpython/builddir/build/python', 'CONFIG_SITE=/tmp/wasm/cpython/Tools/wasm/config.site-wasm32-emscripten']' returned non-zero exit status 1.
It seems like the config_site settings are pointing to the wrong subdirectories.
I fixed that for Emscripten like this (in this branch):
EMSCRIPTEN = Platform(
"emscripten",
pythonexe="python.js",
- config_site=WASMTOOLS / "config.site-wasm32-emscripten",
+ config_site=WASMTOOLS / "emscripten"/ "config.site-wasm32-emscripten",
The build still fails after this:
emcc: warning: EXPORTED_FUNCTIONS is not valid with LINKABLE set (normally due to SIDE_MODULE=1/MAIN_MODULE=1) since all functions are exported this mode. To export only a subset use SIDE_MODULE=2/MAIN_MODULE=2 [-Wunused-command-line-argument]
emcc: error: undefined exported symbol: "__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET" [-Wundefined] [-Werror]
make: *** [Makefile:1115: python.mjs] Error 1
emmake: error: 'make all' failed (returned 2)
Traceback (most recent call last):
File "/tmp/wasm/cpython/./Tools/wasm/wasm_build.py", line 932, in <module>
main()
~~~~^^
File "/tmp/wasm/cpython/./Tools/wasm/wasm_build.py", line 902, in main
builder.run_build(*cm_args)
~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/tmp/wasm/cpython/./Tools/wasm/wasm_build.py", line 572, in run_build
self.run_make("all", *args)
~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "/tmp/wasm/cpython/./Tools/wasm/wasm_build.py", line 581, in run_make
return self._run_cmd(self.make_cmd, args)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "/tmp/wasm/cpython/./Tools/wasm/wasm_build.py", line 557, in _run_cmd
return subprocess.check_call(
~~~~~~~~~~~~~~~~~~~~~^
cmd,
^^^^
cwd=os.fspath(cwd),
^^^^^^^^^^^^^^^^^^^
env=self.getenv(),
^^^^^^^^^^^^^^^^^^
)
^
File "/home/trey/.local/share/uv/python/cpython-3.13.1-linux-x86_64-gnu/lib/python3.13/subprocess.py", line 419, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/emsdk/upstream/emscripten/emmake', 'make', 'all']' returned non-zero exit status 1.
Using emsdk 4.10.0 and running ./Tools/wasm/wasm_build.py emscripten-browser build repl against the v3.13.5 branch works.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixesOS-emscriptendocsDocumentation in the Doc dirDocumentation in the Doc dir
Projects
- StatusShow more project fieldsTodo
Activity
StanFromIreland commentedon Jul 22, 2025
cc @hoodmane
hoodmane commentedon Jul 22, 2025
The new way to build Emscripten is with:
I don't think anyone uses
wasm_build.pyanymore so we should probably remove it (cc @brettcannon )hoodmane commentedon Jul 22, 2025
Maybe it would be good to add a news entry about this change.
emmatyping commentedon Jul 22, 2025
I agree a news entry is a good idea. I would also update
Tools/wasm/README.mdto no longer recommendwasm_build.py:cpython/Tools/wasm/README.md
Lines 12 to 14 in aafb143
hoodmane commentedon Jul 22, 2025
Right, the new instructions are in the dev guide here:
https://devguide.python.org/contrib/workflows/compile/#emscripten
I can update the readme to link there.
hoodmane commentedon Jul 22, 2025
Further down in the readme it does say to use
python Tools/wasm/emscripten:cpython/Tools/wasm/README.md
Lines 58 to 68 in aafb143
treyhunner commentedon Jul 22, 2025
I should have read further down in the README. Thanks!
Using
python Tools/wasm/emscripten buildseemed to work, but the demo didn't seem to work.I had to manually copy
Tools/wasm/emscripten/web_example/python.worker.mjstocross-build/wasm32-emscripten/build/python/web_example. Then runningpython server.pyfromcross-build/wasm32-emscripten/build/python/web_exampleworked as expected.Separately, I'm not sure how to get the JSPI demo working. I noticed there was not a
server.pyfile in the newweb_example_pyrepl_jspi/directory and triedpython ../web_example/server.pybut that didn't seem to result in a working demo. The demo at http://127.0.0.1:8000 showed a dark background (the xterm.js terminal background color I assume) and didn't load anything nor show any errors in the console or network inspector tabs. The browser tab also froze. This same same black window and freezing happened in 2 versions of Chrome and in Firefox.hoodmane commentedon Jul 22, 2025
The JSPI demo can be served with
http.server. It should work with Chrome version >= 137. (Firefox requires an experimental flag.)Which versions of Chrome did you try? Could you try opening the dev console before visiting the page with Ctrl+Shift+J and then navigate to the page and see if you see anything in the console?
hoodmane commentedon Jul 22, 2025
Oops, I messed that up, sorry. I'll make a PR to fix it tomorrow.
treyhunner commentedon Jul 23, 2025
Ah I was apparently still on Chrome 136. I just upgraded and it works now!
I'm very excited to ship an in-browser pyrepl in the future. Thanks to all who made this possible.
gh-137025: Include ``python.worker.mjs`` in the Emscripten Web Example (
pythongh-137025: Include ``python.worker.mjs`` in the Emscripten Web …
pythongh-137025: Include ``python.worker.mjs`` in the Emscripten Web …
[3.14] gh-137025: Include ``python.worker.mjs`` in the Emscripten Web…
gh-137025: Update Emscripten Build Docs (#137312)
freakboy3742 commentedon Oct 9, 2025
I'm fairly certain this is resolved now; closing. If anyone is still having problems, let us know.