]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-133312: configure: add --enable-static-libpython-for-interpreter (#133313)
authorGeoffrey Thomas <geofft@ldpreload.com>
Tue, 14 Apr 2026 15:26:19 +0000 (11:26 -0400)
committerGitHub <noreply@github.com>
Tue, 14 Apr 2026 15:26:19 +0000 (16:26 +0100)
commitc88c27b0c1c09c125fe6a5ad78a4d42cf9c3fcd2
treee90026a6addbbe3e1a7d29fc6eefa1e47bea3525
parente0b56f006c7ee1e5e6f353f030d0e5a672bfc190
gh-133312: configure: add --enable-static-libpython-for-interpreter (#133313)

This option changes the behavior of --enable-shared to continue to build
the libpython3.x.so shared library, but not use it for linking the
python3 interpreter executable. Instead, the executable is linked
directly against the libpython .o files as it would be with
--disable-shared.

There are two benefits of this change. First, libpython uses
thread-local storage, which is noticeably slower when used in a loaded
module instead of in the main program, because the main program can take
advantage of constant offsets from the thread state pointer but loaded
modules have to dynamically call a function __tls_get_addr() to
potentially allocate their thread-local storage area. (There is another
thread-local storage model for dynamic libraries which mitigates most of
this performance hit, but it comes at the cost of preventing
dlopen("libpython3.x.so"), which is a use case we want to preserve.)

Second, this improves the user experience around relocatable Python a
little bit, in that we don't need to use an $ORIGIN-relative path to
locate libpython3.x.so, which has some mild benefits around musl (which
does not support $ORIGIN-relative DT_NEEDED, only $ORIGIN-relative
DT_RPATH/DT_RUNPATH), users who want to make the interpreter setuid or
setcap (which prevents processing $ORIGIN), etc.
Doc/using/configure.rst
Misc/NEWS.d/next/Build/2025-05-02-17-06-10.gh-issue-133312.YkO6BI.rst [new file with mode: 0644]
configure
configure.ac