When building with the --enable-experimental-jit option, the _Py_jit_entry symbol is duplicated in Python/ceval.o and Modules/_testinternalcapi/interpreter.o preventing them from being linked into the same DSO.
The later symbol was added in #143944. This symbol should likely be marked as extern.
I found this issue when building 3.15.0a6 for python-build-standalone, astral-sh/python-build-standalone#981. The build is configured so that the _testinternalcapi module is statically linked into the interpreter.
cpython-3.15> ld64.lld: error: duplicate symbol: _Py_jit_entry
cpython-3.15> >>> defined in Python/ceval.o
cpython-3.15> >>> defined in Modules/_testinternalcapi/interpreter.o
cpython-3.15> clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is a bit tricky. When statically linking _testinternalcapi the symbol must not be duplicated and the second definition can be marked extern. In the more common case where _testinternalcapi is dynamic the symbol needs to be defined in the module because it is not a global.
The declaration of _Py_jit_entry in Modules/_testinternalcapi/interpreter.c is unusual as it is NULL. I does not seem to be used for anything functionally but is needed to allow the extension to be properly linked. Should this be made more clear in the file?
Activity
jjhelmus commented on Feb 11, 2026
This is a bit tricky. When statically linking _testinternalcapi the symbol must not be duplicated and the second definition can be marked extern. In the more common case where _testinternalcapi is dynamic the symbol needs to be defined in the module because it is not a global.
jjhelmus commented on Feb 11, 2026
The declaration of _Py_jit_entry in Modules/_testinternalcapi/interpreter.c is unusual as it is NULL. I does not seem to be used for anything functionally but is needed to allow the extension to be properly linked. Should this be made more clear in the file?
dlin09119-design commented on Feb 19, 2026
Merge branch 'main' into pythongh-144712
Merge branch 'main' into pythongh-144712
pythongh-144712: Fix _Py_jit_entry initializer after merge
pythongh-144712: Export _Py_jit_entry symbol via PyAPI_DATA
Merge branch 'main' into pythongh-144712
Merge branch 'main' into pythongh-144712
Merge branch 'main' into pythongh-144712
gh-144712: Export _Py_jit_entry symbol via PyAPI_DATA (#145840)