Skip to content

Emscripten build fails with Python 3.14 #137025

Description

@treyhunner

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

Activity

  1. StanFromIreland commented on Jul 22, 2025

    @StanFromIreland
    Member
  2. hoodmane commented on Jul 22, 2025

    @hoodmane
    Contributor

    The new way to build Emscripten is with:

    python Tools/wasm/emscripten build
    

    I don't think anyone uses wasm_build.py anymore so we should probably remove it (cc @brettcannon )

  3. hoodmane commented on Jul 22, 2025

    @hoodmane
    Contributor

    Maybe it would be good to add a news entry about this change.

  4. emmatyping commented on Jul 22, 2025

    @emmatyping
    Member

    I agree a news entry is a good idea. I would also update Tools/wasm/README.md to no longer recommend wasm_build.py:

    Users and developers are encouraged to use the script
    `Tools/wasm/wasm_build.py`. The tool automates the build process and provides
    assistance with installation of SDKs, running tests, etc.

  5. added
    docsDocumentation in the Doc dir
    and removed
    type-bugAn unexpected behavior, bug, or error
    on Jul 22, 2025
  6. hoodmane commented on Jul 22, 2025

    @hoodmane
    Contributor

    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.

  7. hoodmane commented on Jul 22, 2025

    @hoodmane
    Contributor

    Further down in the readme it does say to use python Tools/wasm/emscripten:

    ```shell
    python Tools/wasm/emscripten build
    ```
    or you can break it out into four separate steps:
    ```shell
    python Tools/wasm/emscripten configure-build-python
    python Tools/wasm/emscripten make-build-python
    python Tools/wasm/emscripten make-libffi
    python Tools/wasm/emscripten configure-host
    python Tools/wasm/emscripten make-host
    ```

  8. treyhunner commented on Jul 22, 2025

    @treyhunner
    MemberAuthor

    The new way to build Emscripten is with:

    python Tools/wasm/emscripten build
    

    I don't think anyone uses wasm_build.py anymore so we should probably remove it (cc @brettcannon )

    I should have read further down in the README. Thanks!

    Using python Tools/wasm/emscripten build seemed to work, but the demo didn't seem to work.

    I had to manually copy Tools/wasm/emscripten/web_example/python.worker.mjs to cross-build/wasm32-emscripten/build/python/web_example. Then running python server.py from cross-build/wasm32-emscripten/build/python/web_example worked as expected.

    Separately, I'm not sure how to get the JSPI demo working. I noticed there was not a server.py file in the new web_example_pyrepl_jspi/ directory and tried python ../web_example/server.py but 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.

  9. hoodmane commented on Jul 22, 2025

    @hoodmane
    Contributor

    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?

  10. hoodmane commented on Jul 22, 2025

    @hoodmane
    Contributor

    I had to manually copy Tools/wasm/emscripten/web_example/python.worker.mjs to cross-build/wasm32-emscripten/build/python/web_example.

    Oops, I messed that up, sorry. I'll make a PR to fix it tomorrow.

  11. treyhunner commented on Jul 23, 2025

    @treyhunner
    MemberAuthor

    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?

    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.

  12. added a commit that references this issue on Jul 31, 2025
  13. added a commit that references this issue on Jul 31, 2025
  14. added a commit that references this issue on Aug 19, 2025
  15. added a commit that references this issue on Oct 7, 2025
  16. added a commit that references this issue on Oct 9, 2025
  17. freakboy3742 commented on Oct 9, 2025

    @freakboy3742
    Contributor

    I'm fairly certain this is resolved now; closing. If anyone is still having problems, let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixesOS-emscriptendocsDocumentation in the Doc dir

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions