Commit 88a7e4f
committed
gh-104612: Fix libpython3.so stable ABI on Linux using patchelf
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.1 parent 6181b69 commit 88a7e4f
3 files changed
+73
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
| |||
1026 | 1029 | | |
1027 | 1030 | | |
1028 | 1031 | | |
1029 | | - | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
1030 | 1037 | | |
1031 | 1038 | | |
1032 | 1039 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1719 | 1719 | | |
1720 | 1720 | | |
1721 | 1721 | | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
1722 | 1733 | | |
1723 | 1734 | | |
1724 | 1735 | | |
| |||
0 commit comments