Fix $ORIGIN rpath on shared builds - #645
Open
abgoyal wants to merge 1 commit into
Open
Conversation
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 free
to 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.
Fixes #560.
scripts.d/99-rpath.shhas emitted$ORIGINrpath flags for linux shared builds since a0384b8 (2021), but the escaped literal stopped surviving the pipeline in 2024, and every linux shared release since has shipped a mangled rpath:Confirmed against released tarballs.
autobuild-2026-02-28(N-123074),autobuild-2026-06-30(N-125365) andautobuild-2026-08-03(N-125953) all carry[-Wl:../lib].Root cause
281ab29 (2024-03-14) added the
xargsnormalisation atgenerate.sh:230, which unescapes one level. That is the level99-rpath.sh's literal depended on:What reaches the linker with the current escaping:
configure'sappend()runseval "$var=\"\$$var $*\"". Inside those quotes\$becomes$, and the unset$ORIGINexpands to nothing, soconfig.makgets-Wl,-rpath=$ -Wl,-rpath=$/../lib.maketreats$and$/as single-character variable references, both empty, merging the two flags into one token:-Wl,-rpath=-Wl,-rpath=../lib.ldreceives-rpath=-Wland-rpath=../lib, givingRPATH [-Wl:../lib].Step 2 explains both the merge and the missing leading slash.
Fix
Not by adding more backslashes. That is what caused the bug, and it cannot be made reliable: the chain has five unescaping layers, and one of them is
to_df()'sprintf "$@"(seperate issue in itself), which uses caller data as a format string.Instead the value never enters the generate/Dockerfile pipeline at all:
99-rpath.shno longer emits the rpath flags (it keeps-pie), so there is nothing forxargs,printforENVparsing to mangle.build.shappends them inside the container, one shell layer fromconfigure, where the required value is knowable and can be commented. The heredoc delimiter is quoted so the host expands nothing, and the fragment is single-quoted and concatenated so the container's shell substitutes nothing either:Not
${FF_LDEXEFLAGS//@PLACEHOLDER@/$var}. Bash's pattern substitution consumes a backslash from the replacement on some bash versions but not others, which silently costs one escaping level.build.shalso gains a post-build check for linux shared variants. A broken$ORIGINrpath still builds, and still runs anywhereld.so.cacheknows the libraries, which is why this went unnoticed for two years. It now fails the build instead:Both additions are gated on
linux* + *shared*, so win and static targets generate the same build script as before.Verification
Traced end to end through the real chain:
generate.shoutput, DockerENVparsing,configure'sappend()/eval,config.mak,make,sh,gcc.confirmed on real
linux64 gpl-sharedbuilds, twice: once against the prebuilt variant image, and once rebuilding the variant image frombase-linux64the way CI does.Unpacked elsewhere and run from an unrelated working directory:
so the binary is self-locating, which is what #560 asked for.