Skip to content

fix: pass CFLAGS to the sdb binary link step - #324

Merged
trufae merged 1 commit into
radareorg:masterfrom
blshkv:fix-link-cflags
Aug 6, 2026
Merged

fix: pass CFLAGS to the sdb binary link step#324
trufae merged 1 commit into
radareorg:masterfrom
blshkv:fix-link-cflags

Conversation

@blshkv

@blshkv blshkv commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Problem

The sdb binary link rule uses only ${LDFLAGS}, omitting ${CFLAGS}.
When the caller passes -flto in 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:

  1. GCC's .GCC.command.line sections (written by -frecord-gcc-switches)
    are not present in the final binary, causing QA failures on
    distributions that verify this section (Gentoo, among others).

  2. LTO optimizations are silently skipped for the sdb binary.

Fix

Add ${CFLAGS} before ${LDFLAGS} in the link command — the standard
convention for flags like -flto, sanitizers, and coverage instrumentation
that must appear in both the compile and link steps.

Related

radareorg/radare2#26410 — fixes the same class of issue in radare2's
io_shm.so build, and provides context on why HOST_CFLAGS in
shlr/Makefile should not unconditionally default to $(CFLAGS).

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
@trufae
trufae merged commit 6886414 into radareorg:master Aug 6, 2026
14 of 15 checks passed
@blshkv
blshkv deleted the fix-link-cflags branch August 6, 2026 04:37
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.

2 participants