Skip to content

gh-156780: Emscripten: add missing EM_JS_DEPS - #156798

Merged
freakboy3742 merged 1 commit into
python:mainfrom
clementperon:emscripten-em-js-deps
Sep 8, 2026
Merged

gh-156780: Emscripten: add missing EM_JS_DEPS#156798
freakboy3742 merged 1 commit into
python:mainfrom
clementperon:emscripten-em-js-deps

Conversation

@clementperon

@clementperon clementperon commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Split out of #156781, as suggested by @hoodmane.

EM_JS bodies are emitted verbatim, so Emscripten's dependency tracker cannot see the JS symbols they reference and silently omits them.

Declared here: $FS, $PATH, $FS_getMode, $resolveGlobalSymbol and emscripten_exit_with_live_runtime in emscripten_syscalls.c, and $wasmTable, $wasmMemory, $addFunction, $addOnPreRun in emscripten_trampoline.c.

No change for MAIN_MODULE builds. Without it, the link now fails with

error: undefined symbol: $resolveGlobalSymbol

instead of a ReferenceError during initRuntime.

@clementperon

Copy link
Copy Markdown
Contributor Author

@hoodmane first PR that add the EM_JS_DEPS() everywhere

Comment thread Misc/NEWS.d/next/Build/2026-09-01-23-32-01.gh-issue-156780.Kz8vQr.rst Outdated
@freakboy3742

Copy link
Copy Markdown
Contributor

Noting that CI is currently failing because of a duplicated symbol; that seems to suggest there's a need to collate these declarations into a single coherent location so that we can avoid duplication, rather than co-locating them with usage.

Also - can I ask that you please don't force push. We don't care about a "messy" commit history; CPython uses merge commits, so any messy history isn't preserved after merge. Force pushes also mean that we can lose the context for review comments, and it's really easy to force push a merge comment that pings the entire core team for comment.

@hoodmane

hoodmane commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Emscripten's normal style guide is to put these next to the symbol that uses them so I think that's alright. I think we have a conflict with #156335, need to merge a main that includes that commit and fix the duplicate symbol.

EM_JS bodies are emitted verbatim, so Emscripten cannot see the JS symbols
they reference. Declare them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@clementperon

clementperon commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@freakboy3742 "Noting that CI is currently failing because of a duplicated symbol" ?

The build fail no?
Something like

dup.c >>>
EM_JS_DEPS(tag_a, "$FS");

EM_JS_DEPS(tag_a, "$PATH");  

dup.c:3:1: error: redefinition of '__em_lib_deps_tag_a'
dup.c:1:1: note: previous definition is here

The issue here is that my fork was not up to date with main.

Also about the force push well noted, I had to do it here to properly rebase on latest master

@freakboy3742 freakboy3742 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - if Emscripten convention is to keep the declarations locally, then it makes sense for us to do the same.

@freakboy3742
freakboy3742 merged commit 0b3b154 into python:main Sep 8, 2026
96 of 98 checks passed
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot x86 Debian Non-Debug with X 3.x (tierless) has failed when building commit 0b3b154.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1245/builds/9398) and take a look at the build logs.
  4. Check if the failure is related to this commit (0b3b154) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1245/builds/9398

Summary of the results of the build (if available):

==

Click to see traceback logs
Note: switching to '0b3b154060936e1b120f5b9793ed3f8647df8480'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 0b3b15406093 gh-156780: Emscripten: add missing EM_JS_DEPS (#156798)
Switched to and reset branch 'main'

configure: WARNING: i686-pc-linux-gnu/gcc is not supported
configure: WARNING:

Platform "i686-pc-linux-gnu" with compiler "gcc" is not supported by the
CPython core team, see https://peps.python.org/pep-0011/ for more information.


Objects/moduleobject.c: In function ‘module_from_slots_and_spec’:
Objects/moduleobject.c:412:38: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  412 |     uint64_t multiple_interpreters = (uint64_t)Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED;
      |                                      ^
Objects/moduleobject.c:474:44: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  474 |                     requires_gil = (val != (uint64_t)Py_MOD_GIL_NOT_USED);
      |                                            ^
In file included from Objects/mimalloc/static.c:26,
                 from Objects/obmalloc.c:26:
Objects/mimalloc/arena.c:59:1: note: the alignment of ‘_Atomic long long int’ fields changed in GCC 11.1
   59 | } mi_arena_t;
      | ^
Python/ceval.c: In function ‘_Py_BuildMap_StackRefSteal’:
Python/ceval.c:943:11: warning: ‘args_o_temp’ may be used uninitialized [-Wmaybe-uninitialized]
  943 |     res = _PyDict_FromItems(
      |           ^~~~~~~~~~~~~~~~~~
  944 |         args_o, 2,
      |         ~~~~~~~~~~
  945 |         args_o+1, 2,
      |         ~~~~~~~~~~~~
  946 |         half_args
      |         ~~~~~~~~~
  947 |     );
      |     ~      
In file included from Python/ceval.h:11,
                 from Python/ceval.c:3:
./Include/internal/pycore_dict.h:333:23: note: by argument 3 of type ‘PyObject * const*’ {aka ‘struct _object * const*’} to ‘_PyDict_FromItems’ declared here
  333 | PyAPI_FUNC(PyObject *)_PyDict_FromItems(
      |                       ^~~~~~~~~~~~~~~~~
In file included from Python/ceval.c:702:
Python/ceval.c:938:52: note: ‘args_o_temp’ declared here
  938 |     STACKREFS_TO_PYOBJECTS(arguments, half_args*2, args_o);
      |                                                    ^~~~~~
Python/ceval_macros.h:522:15: note: in definition of macro ‘STACKREFS_TO_PYOBJECTS’
  522 |     PyObject *NAME##_temp[MAX_STACKREF_SCRATCH+1]; \
      |               ^~~~
./Modules/_remote_debugging/binary_io_reader.c: In function ‘binary_reader_replay’:
./Modules/_remote_debugging/binary_io_reader.c:1250:55: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
 1250 |             if (replayed % PROGRESS_CALLBACK_INTERVAL < count) {
      |                                                       ^
./Modules/_sqlite/connection.c: In function ‘deserialize_impl’:
./Modules/_sqlite/connection.c:2352:19: warning: comparison is always false due to limited range of data type [-Wtype-limits]
 2352 |     if (data->len > 9223372036854775807) {  // (1 << 63) - 1
      |                   ^
./Modules/_testlimitedcapi/heaptype_relative.c: In function ‘make_sized_heaptypes’:
./Modules/_testlimitedcapi/heaptype_relative.c:71:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   71 |                            (unsigned long long)data_ptr,
      |                            ^

make: *** [Makefile:2481: buildbottest] Error 3

maurycy added a commit to maurycy/cpython that referenced this pull request Sep 10, 2026
* main: (158 commits)
  pythongh-156924: Try reifying lazy imports in `ForwarRef.evaluate()` (python#156940)
  pythongh-156233: Fix typos and code snippet errors in the docs (python#156475)
  pythongh-156837: Refer to yield expressions in generator function definitions (pythonGH-156863)
  pythongh-155292: Skip updating unicodedata with mismatched interpreter (pythonGH-157066)
  pythongh-157170: Document the scope of global curses settings (pythonGH-157207)
  pythongh-155966: Correct handling of `math.tanpi` poles (python#155980)
  pythongh-157170: Restore use_env() after test_use_prescr_screen in test_curses (pythonGH-157171)
  pythongh-156910: fix deadlock in type_set_abstractmethods under free-threading (python#156948)
  pythongh-155648: Write the empty and placeholder IDLE tests (python#156260)
  pythongh-153569: centralize formatted-string state and source spans (python#156484)
  pythongh-157137: Mark the PEP 820 soft deprecations as 3.15, not `next` (python#157138)
  pythongh-152433: Use regular LoadLibrary in UWP for Windows system libs (pythonGH-156972)
  pythongh-121617: Fix Py_CLEAR() memcpy in C++: replace NULL with _Py_NULL (python#157188)
  pythongh-157135: Fix documentation errors in the `math.atan{2}pi` functions (python#157136)
  pythongh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (python#157067)
  pythongh-156774: Speed up pdb startup with asyncio guard (python#156775)
  pythongh-156109: Allow static, non-framework iOS builds (python#156110)
  pythongh-156780: Emscripten: add missing EM_JS_DEPS (python#156798)
  pythongh-152936: Make privileged functions available on Android (python#152977)
  pythongh-123018: Keep the libedit history file header when truncating (pythonGH-157165)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants