-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-44133: Link Python executable with object files #30556
Conversation
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:
|
I don't know how to test this change on macOS to build Python with the "framework". |
@tiran @erlend-aasland: Would you mind to review this change? cc @encukou |
On my Fedora 35, if I compare |
Misc/NEWS.d/next/Build/2022-01-12-13-34-52.bpo-44133.HYCNXb.rst
Outdated
Show resolved
Hide resolved
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.
PR rebased to fix merge conflicts. |
I may be a good idea to test this build change on buildbots before merging the PR :-) Fedora and RHEL buildbots use |
The gate failed. the test of this PR should be skipped in wins? |
🤖 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. |
@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. |
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