mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-44133: Link Python executable with object files (GH-30556)
When Python is built without --enable-shared, the "python" program is now linked to object files, rather than being linked to the Python library (libpython.a), to make sure that all symbols are exported. Previously, the linker omitted some symbols like the Py_FrozenMain() function. When Python is configured with --without-static-libpython, the Python static library (libpython.a) is no longer built. * Check --without-static-libpython earlier in configure.ac * Add LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variables to Makefile. * test_capi now ensures that the "Py_FrozenMain" symbol is exported.
This commit is contained in:
parent
0885999a8e
commit
6be848922b
6 changed files with 131 additions and 85 deletions
|
@ -643,6 +643,24 @@ class CAPITest(unittest.TestCase):
|
|||
expected = compile(code, "<string>", "exec")
|
||||
self.assertEqual(result.co_consts, expected.co_consts)
|
||||
|
||||
def test_export_symbols(self):
|
||||
# bpo-44133: Ensure that the "Py_FrozenMain" and
|
||||
# "PyThread_get_thread_native_id" symbols are exported by the Python
|
||||
# (directly by the binary, or via by the Python dynamic library).
|
||||
ctypes = import_helper.import_module('ctypes')
|
||||
names = ['PyThread_get_thread_native_id']
|
||||
|
||||
# Python/frozenmain.c fails to build on Windows when the symbols are
|
||||
# missing:
|
||||
# - PyWinFreeze_ExeInit
|
||||
# - PyWinFreeze_ExeTerm
|
||||
# - PyInitFrozenExtensions
|
||||
if os.name != 'nt':
|
||||
names.append('Py_FrozenMain')
|
||||
for name in names:
|
||||
with self.subTest(name=name):
|
||||
self.assertTrue(hasattr(ctypes.pythonapi, name))
|
||||
|
||||
|
||||
class TestPendingCalls(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue