[release-1.8] Consistently use RUNPATH
in our libraries
#46465
Merged
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.
When loading dependencies on Linux, we can either use
RPATH
orRUNPATH
as a list of relative paths to search for libraries. Thedifference, for our purposes, mainly lies within how this interacts with
LD_LIBRARY_PATH
:RPATH
is searched first, thenLD_LIBRARY_PATH
,then
RUNPATH
. So by usingRUNPATH
here, we are explicitly allowingourselves to be overridden by
LD_LIBRARY_PATH
. This is fine, as longas we are consistent across our entire library line, however in the
v1.8.0
release, there was an inconsistency, reported in [0].The inconsistency occured because of the following confluence of factors:
ld
builds (such as the one used in our build environment)do not default to using
RUNPATH
, but instead useRPATH
.patchelf
, when it rewrites the RPATH, will default to usingRUNPATH
instead.patchelf
onlibjulia-internal
, not onlibjulia-codegen
, which was newly added inv1.8
.These three factors together caused us to ship a binary with
RUNPATH
in
libjulia-internal
, butRPATH
inlibjulia-codegen
, which causedloading to fail in [0] due to first
libjulia-internal
being loaded,(which brought in the external
libstdc++
), thenlibjulia-codegen
failed to load (because it found an incompatible
libstdc++
), causingthe mysterious compiler error.
This PR fixes this twofold; first, when building the libraries in the
first place, we pass
--enable-new-dtags
to the linker to encourage itto use
runpath
when possible. This removes the possibility for amissing
patchelf
invocation to break things in this way. Second, weapply
patchelf
properly tolibjulia-codegen
as well.[0] #46409