fix: pass CFLAGS to the sdb binary link step - #324
Merged
Conversation
The link rule uses only ${LDFLAGS}, omitting ${CFLAGS}. When the caller
uses -flto, the objects are compiled as fat LTO IR but linked without
-flto, so the LTO pass never runs. This has two consequences:
1. GCC's .GCC.command.line sections (from -frecord-gcc-switches) are not
emitted in the final binary, causing QA failures on distributions that
check for this section (Gentoo, among others).
2. LTO optimizations are silently skipped for the sdb binary.
Fix: add ${CFLAGS} before ${LDFLAGS} in the link command, matching the
standard convention where compilation flags that affect linking (LTO,
sanitizers, coverage) are passed to both compile and link steps.
Related: radareorg/radare2#26410
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.
Problem
The
sdbbinary link rule uses only${LDFLAGS}, omitting${CFLAGS}.When the caller passes
-fltoin CFLAGS (as many Linux distributions do),the object files are compiled as fat LTO IR but linked without
-flto,so the LTO pass never runs. This has two consequences:
GCC's
.GCC.command.linesections (written by-frecord-gcc-switches)are not present in the final binary, causing QA failures on
distributions that verify this section (Gentoo, among others).
LTO optimizations are silently skipped for the
sdbbinary.Fix
Add
${CFLAGS}before${LDFLAGS}in the link command — the standardconvention for flags like
-flto, sanitizers, and coverage instrumentationthat must appear in both the compile and link steps.
Related
radareorg/radare2#26410 — fixes the same class of issue in radare2's
io_shm.sobuild, and provides context on whyHOST_CFLAGSinshlr/Makefileshould not unconditionally default to$(CFLAGS).