Skip to content

gh-119696: Set relative library paths for relocatable builds - #48

Draft
zaniebot wants to merge 1 commit into
zb/relocatable-flag-iifrom
zb/relocatable-flag-ii-linker
Draft

zaniebot wants to merge 1 commit into
zb/relocatable-flag-iifrom
zb/relocatable-flag-ii-linker

Conversation

@zaniebot

@zaniebot zaniebot commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

PBS rewrites installed binaries to give them relative library paths. Supply those paths during linking under --enable-relocatable, for installed interpreters, libpython, and standard-library extensions on Linux and non-framework macOS. This moves part of PBS's relocation handling into CPython's build system, as proposed in python#119696 and backported in the downstream draft astral-sh/python-build-standalone#861.

On glibc, an installed-layout DT_RPATH in the build-tree interpreter can select an unrelated sibling libpython before RUNSHARED's LD_LIBRARY_PATH. Link separate installation binaries from the same objects so build-tree programs use their build-time library lookup. Build-tree extensions keep their ordinary link flags. On Linux shared builds, RUNSHARED includes the build directory followed by any LD_LIBRARY_PATH supplied when running configure, allowing non-system dependency directories to be supplied independently of the installation prefix. Keep installed-layout flags out of LDSHARED, since third-party extensions can be installed elsewhere.

On glibc, DT_RPATH supplies paths for indirect dependencies and takes precedence over LD_LIBRARY_PATH when the requesting object has no DT_RUNPATH. This supports distributions that prefer their bundled libraries, at the cost of less flexible environment overrides and additional linking. It does not prevent preloading or reuse of libraries already loaded by an embedding application. macOS uses an @rpath install name with relative search paths.

The experimental mode requires default bin and lib directories under a common prefix and rejects framework builds until framework relocation is implemented. Combining it with --enable-bolt is an error. The standard library may use a different directory through --with-platlibdir, so extension paths traverse back to the prefix before entering lib. The added search paths point to lib; dependencies in subdirectories such as lib/tcltk may need additional search paths. Tcl/Tk script discovery is separate from shared-library lookup. Dependency bundling and rewriting shebangs or sysconfig paths remain separate concerns.

The base branch contains the flag proposed in python#160377 and the independent deleted-library fixture fix proposed in python#160396 for python#160388. Separate installation binaries also require BOLT optimization; #56 adds that support. Alternative: #49 uses DT_RUNPATH and shares build and installation binaries.

@zaniebot
zaniebot force-pushed the zb/relocatable-flag-ii-linker branch 2 times, most recently from 58e203b to 94be16f Compare October 22, 2026 19:30
@zaniebot
zaniebot force-pushed the zb/relocatable-flag-ii-linker branch from 94be16f to 72a4350 Compare October 22, 2026 22:19
@zaniebot
zaniebot changed the base branch from zb/relocatable-flag-ii to zb/relocatable-flag-ii-deleted-libpython October 22, 2026 22:20
@zaniebot
zaniebot force-pushed the zb/relocatable-flag-ii-linker branch from 72a4350 to b444cd7 Compare October 22, 2026 22:52
@zanieb
zanieb added this pull request to stack #57 October 22, 2026 22:53
@zaniebot
zaniebot removed this pull request from stack #57 October 22, 2026 22:59
@zaniebot
zaniebot changed the base branch from zb/relocatable-flag-ii-deleted-libpython to zb/relocatable-flag-ii October 22, 2026 22:59
@zaniebot
zaniebot added this pull request to stack #58 October 22, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant