th0ma7 · GitHub

and others added 2 commits

July 19, 2026 13:33
A target without native 64-bit atomics (ARMv5, PowerPC e500) needs -latomic, and
a glibc older than 2.17 needs -lrt for clock_gettime -- knowledge that today is
scattered across packages as arch lists (cups enumerates ARMv5/old-PPC for -lrt,
flac adds it everywhere). Move it beside TC_EXTRA_CFLAGS, where the target is
known: the toolchain states the flag once.
tc-flags.mk drops -latomic when the toolchain's gcc does not ship libatomic (a gcc
that old predates the __atomic_* builtins and emits __sync_* instead, so it never
needs the library), asked of the compiler rather than tabulated. tc_vars.mk bakes
the value like the other flags. Declared on the ARMv5, PowerPC and glibc<2.17
toolchains; no change on the modern ones.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEH1b4ASNYSrZFQnEeroj8
… them
zstd, cups, flac, lz4, gnupg, htop, mosquitto, fdupes, imlib2 and misc-util-linux
each added -lrt by hand; python* and stockfish added -latomic for qoriq. The
glibc < 2.17 toolchains now carry -lrt and the ARMv5/PowerPC toolchains carry
-latomic via TC_EXTRA_LDFLAGS, so the per-package copies are redundant -- on newer
glibc -lrt was a no-op (clock_gettime is in libc), and -latomic is dropped anyway
where the gcc does not ship libatomic. python314 keeps its qoriq configure fix.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEH1b4ASNYSrZFQnEeroj8

@th0ma7

…de it
The arch/ABI flags a toolchain sets (-march, -mcpu, -mfpu, -mfloat-abi, ...) were
carried in TC_EXTRA_CFLAGS and then pasted into CPPFLAGS/CXXFLAGS/LDFLAGS too,
which read like a copy/paste bug but is not: those flags select the ABI, so they
must reach every language and the link driver alike. Rename them to what they are,
TC_EXTRA_BUILD_FLAGS, and add it to CFLAGS, CPPFLAGS, CXXFLAGS, FFLAGS and LDFLAGS
in one place. This also fixes Fortran, which only ever got the (empty)
TC_EXTRA_FFLAGS and so built objects with a different ABI than the C/C++ ones.
Per-language TC_EXTRA_<LANG>FLAGS now sit beside it for genuinely language-specific
extras, and the cmake/meson crossfiles list them for a holistic view (uniq drops
the duplicate the folded *FLAGS already carry).
-latomic filtering folds back into TC_EXTRA_LDFLAGS itself -- one variable every
consumer reads, no separate _SELECTED -- kept lazy via a captured copy because the
libatomic probe runs a compiler that is not extracted yet at parse time.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEH1b4ASNYSrZFQnEeroj8
…rywhere
Rather than pair TC_EXTRA_BUILD_FLAGS with a per-language extra at every use site,
fold it once into each TC_EXTRA_<LANG>FLAGS (CFLAGS/CPPFLAGS/CXXFLAGS/FFLAGS, and
the link one). Each then becomes the single residual list its language reads --
the ABI first, then whatever a toolchain adds for that language, always last in
the chain and a clean place to extend -- and CFLAGS/.../LDFLAGS, tc_vars and the
cmake/meson crossfiles all read that one variable.
TC_EXTRA_RUSTFLAGS is left out on purpose: rustc takes its ABI via -Ctarget-cpu
(already in TC_EXTRA_RUSTFLAGS), and rust's C dependencies get the build flags
through CFLAGS_<target> = TC_EXTRA_CFLAGS in tc-rust.mk. tc_vars now emits each
per-language variable so a package (and the crossfiles) can read it directly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEH1b4ASNYSrZFQnEeroj8
…CFLAGS
Two coherence tweaks, no behaviour change:
- Move the TC_EXTRA_LDFLAGS declaration (and its comment) right after
  TC_HAS_LIBATOMIC, whose result it is the sole consumer of -- definition and use
  now sit together instead of a per-language block apart.
- tc-rust.mk feeds CFLAGS_<target> from TC_EXTRA_CFLAGS (not TC_EXTRA_BUILD_FLAGS),
  matching what the comment in tc-flags.mk already states and what every other
  language reads.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEH1b4ASNYSrZFQnEeroj8
…LDFLAGS
- framework/toolchain.md: a new 'Extra flags a toolchain can declare' section --
  TC_EXTRA_BUILD_FLAGS as the ABI folded into each TC_EXTRA_<LANG>FLAGS and the
  link, why every language must get it, why rust is excluded, and the -lrt vs
  -latomic behaviour with libatomic auto-detection.
- packaging/makefile-variables.md: note that ADDITIONAL_* are package-scoped and
  point to the toolchain-wide TC_EXTRA_* counterparts.
- framework/changes.md: a Highlights bullet and a dated log entry for #7314.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEH1b4ASNYSrZFQnEeroj8
Now that -lrt and -latomic are declared once per toolchain instead of per
package, they reach every link -- yet most binaries call neither clock_gettime
nor an atomic builtin, so each would otherwise record a spurious librt/libatomic
DT_NEEDED (harmless for librt, part of core glibc, but a real risk for libatomic,
a gcc runtime lib not guaranteed on the target).
Wrap just these injected libs in -Wl,--as-needed ... -Wl,--no-as-needed: the
linker keeps the dependency only where the objects reference a symbol the library
provides, and the default is restored right after so the scope is these two libs
alone -- a package library kept only for its side effects is never dropped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEH1b4ASNYSrZFQnEeroj8
Document why the toolchain-wide link libraries are wrapped in --as-needed (a
binary depends on librt/libatomic only when it truly references one) in the
toolchain reference, the #7314 changelog entry and its Highlights bullet.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEH1b4ASNYSrZFQnEeroj8

@th0ma7 th0ma7 changed the title toolchain: declare TC_EXTRA_LDFLAGS (-lrt/-latomic) instead of per-package flags toolchain: declare the ABI and link flags once (TC_EXTRA_BUILD_FLAGS / TC_EXTRA_LDFLAGS)

Jul 23, 2026
Clarify the tc_vars.flags.mk note: give the concrete mapping (CFLAGS ends with
TC_EXTRA_CFLAGS, CXXFLAGS with TC_EXTRA_CXXFLAGS, ..., LDFLAGS with
TC_EXTRA_LDFLAGS) and state that each already carries the folded ABI, so it reaches
every compiler and the link driver -- the elliptical wording read as if only the
compilers got it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEH1b4ASNYSrZFQnEeroj8

@th0ma7

@th0ma7

th0ma7 deleted the master-tc-extra-ldflags branch

July 23, 2026 00:27

This was referenced

Jul 23, 2026

Open

Draft

th0ma7 added a commit to th0ma7/spksrc that referenced this pull request

Jul 24, 2026
ffmpeg4's ARMv5 block carried '--extra-ldflags=-lrt', added long ago so libsrt could
resolve clock_gettime on glibc < 2.17 (which keeps it in librt). SynoCommunity#7314 moved -lrt into
the toolchain's TC_EXTRA_LDFLAGS -- declared toolchain-wide and wrapped --as-needed, so
it lands on the link exactly where a symbol needs it -- for every glibc < 2.17 arch,
ARMv5 (88f6281, glibc 2.15) included. The per-package flag is now a duplicate of that;
remove it. Same cleanup SynoCommunity#7314 did for the two dozen other per-package -lrt/-latomic
lists.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEH1b4ASNYSrZFQnEeroj8

hgy59

Read the original on github.com ↗