Uh oh!
There was an error while loading. Please reload this page.
gh-104612: Fix libpython3.so stable ABI on Linux using patchelf - #144136
Open
beeender wants to merge 2 commits into
Open
gh-104612: Fix libpython3.so stable ABI on Linux using patchelf#144136beeender wants to merge 2 commits into
beeender wants to merge 2 commits into
Conversation
The previous implementation of libpython3.so created an empty wrapper library that recorded libpython3.X.so in DT_NEEDED but did not properly re-export symbols. The program with proper Py_LIMITED_API defined cannot actually linked with libpython3.so (-lpython3), and it makes the stable API pointless. And libpython3.so cannot simply be a symbolic link to the libpython3.X.so, since due to the SONAME contains the minor version, error will still be reported during the runtime with a different pythons so version. This fix uses patchelf on Linux to copy the versioned library and set its SONAME to libpython3.so, ensuring binaries get the correct DT_NEEDED entry for stable ABI compatibility. - Add PATCHELF variable detection in configure.ac (Linux only) - Require patchelf on Linux, error if not found - Update libpython3.so target to use patchelf when available - Fall back to original behavior on non-Linux platforms A program linked with the newly patched libpython3.so and stable API, can run with the previous empty wrapper libpython3.so.
beeender
requested review from
AA-Turner, corona10, emmatyping and erlend-aasland
as code ownersJanuary 22, 2026 08:59
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
This PR is stale because it has been open for 30 days with no activity. |
beeender
commented
May 5, 2026
Author
shall i do anything ? |
This PR is stale because it has been open for 90 days with no activity. |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous implementation of libpython3.so created an empty wrapper
library that recorded libpython3.X.so in DT_NEEDED but did not properly
re-export symbols. The program with proper Py_LIMITED_API defined cannot
actually linked with libpython3.so (-lpython3), and it makes the stable
API pointless.
And libpython3.so cannot simply be a symbolic link to the
libpython3.X.so, since due to the SONAME contains the minor version,
error will still be reported during the runtime with a different pythons
so version.
This fix uses patchelf on Linux to copy the versioned library and set
its SONAME to libpython3.so, ensuring binaries get the correct
DT_NEEDED entry for stable ABI compatibility.
A program linked with the newly patched libpython3.so and stable API,
can run with the previous empty wrapper libpython3.so.