getdeps: keep $LDFLAGS on the shared library links under --shared-lib - #499
Open
michel-slm wants to merge 1 commit into
Open
michel-slm wants to merge 1 commit into
michel-slm wants to merge 1 commit into
Conversation
--shared-lib defines CMAKE_SHARED_LINKER_FLAGS and CMAKE_MODULE_LINKER_FLAGS on the cmake command line to append -Wl,--exclude-libs=ALL. A variable given on the command line is never seeded from $LDFLAGS, so the caller's linker flags vanished from every shared library link while the executables, whose CMAKE_EXE_LINKER_FLAGS we do not touch, kept them. For a distro build that silently dropped the hardening flags (RELRO, BIND_NOW, --error-rwx-segments) from the produced .so files. Seed both variables from $LDFLAGS, as CMake would, before appending. An explicit caller value still wins. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Michel Lind <salimma@fedoraproject.org>
michel-slm
marked this pull request as draft
September 18, 2026 14:19
michel-slm
marked this pull request as ready for review
September 18, 2026 17:00
Contributor
Author
|
Verified with a full Fedora Rawhide aarch64 rebuild of CacheLib using Every |
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.
Summary
--shared-lib(#491) appends-Wl,--exclude-libs=ALLby definingCMAKE_SHARED_LINKER_FLAGSandCMAKE_MODULE_LINKER_FLAGSon the cmake command line. A cache variable given on the command line is never seeded from$LDFLAGS, so the caller's linker flags silently vanished from every shared library link, while the executables (whoseCMAKE_EXE_LINKER_FLAGSwe leave alone) kept them.Seed both variables from
$LDFLAGS, as CMake itself would, before appending. An explicit caller-supplied value still wins.How it showed up
Fedora package build of cachelib with
--shared-lib,LDFLAGSset by rpm's%set_build_flags. From the generatedbuild.ninja:The libraries lost RELRO, BIND_NOW and, on Fedora Rawhide,
--error-rwx-segments. That last one would have turned a real problem into a link error: fbthrift's generated_data.cppfiles put relocated data in a.rodata.*section, which-fPICmakes writable, so everylibcachelib_*.sowas linked with a single RWX LOAD segment (ld only warned) and glibc's aarch64 loader then crashed on them at startup. With this fix the hardening flags reach the.solinks and that class of problem fails loudly at link time.Test plan
Two new tests:
$LDFLAGSseeds both variables and--exclude-libs=ALLis appended; an explicitCMAKE_SHARED_LINKER_FLAGSfrom the caller overrides$LDFLAGSfor that variable only.black --checkclean.Fedora Rawhide aarch64 package rebuild with this patch applied is in progress; I will confirm the shared libraries'
LINK_FLAGShere once it completes.🤖 Generated with Claude Code