Uh oh!
There was an error while loading. Please reload this page.
bpo-44133: Link Python executable with object files - #30556
Conversation
vstinner
commented
Jan 12, 2022
With this change, The "python" file only exports the symbol when it's not linked to libpython.so. When libpython.so exists, il always exports the symbol. Case 1 (no option): Case 2, --without-static-libpython --enable-shared: Case 3, --without-static-libpython: Case 4, --enable-shared: |
vstinner
commented
Jan 12, 2022
I don't know how to test this change on macOS to build Python with the "framework". |
vstinner
commented
Jan 12, 2022
@tiran@erlend-aasland: Would you mind to review this change? cc @encukou |
vstinner
commented
Jan 12, 2022
On my Fedora 35, if I compare |
Uh oh!
There was an error while loading. Please reload this page.
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.
vstinner
commented
Jan 12, 2022
PR rebased to fix merge conflicts. |
vstinner
commented
Jan 12, 2022
I may be a good idea to test this build change on buildbots before merging the PR :-) Fedora and RHEL buildbots use |
shihai1991
commented
Jan 13, 2022
The gate failed. the test of this PR should be skipped in wins? |
bedevere-bot
commented
Jan 13, 2022
🤖 New build scheduled with the buildbot fleet by @shihai1991 for commit c5c7102 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
vstinner
commented
Jan 13, 2022
@shihai1991: "The gate failed. the test of this PR should be skipped in wins?" No, the symbol must be present on all platforms. I pushed a fix. |
vstinner
commented
Jan 13, 2022
Ah, adding frozenmain.c to the pythoncore project makes the Windows build to fail: |
Ok, I give up for this PR (I skip the test on Windows): I have no idea how to add Py_FrozenMain() on Windows if it requires 3 symbols when Python is linked. Maybe Py_FrozenMain() should be modified to load these symbols at runtime on Windows? |
When Python is built without --enable-shared, the "python" program is
now linked to object files, rather than be linked the Python static
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.
earlier.
https://bugs.python.org/issue44133