Hi,
On 1/22/25 00:31, Theodore Ts'o wrote:
I guess I could add an autoconf test to see if the linker barfs on
--as-needed, but I'm curious how much this actually matters in
practice.
From an upstream perspective, I think the best approach is
AC_CHECK_LIB([atomic],[main])
That creates a few unnecessary dependencies, but it should work pretty
much everywhere.
If Debian maintainers feel annoyed by warnings about unnecessary
dependencies, they are welcome to replace this with a hardcoded
LDFLAGS="${LDFLAGS} -Wl,--push-state,--as-needed,-latomic,--pop-state"
because unlike upstream, Debian can assume reasonably recent GNU tools.
Someone GNU adjacent might want to build something more sophisticated
for the autoconf-archive -- but I'd draw the line at
0. if the library does not exist, assume it's not needed and explicitly
say so in the build log
1. if --push-state/--pop-state are supported, wrap them around --as-needed
2. if --as-needed is supported, but no state stack, use --no-as-needed
afterwards, and if any other macro wants to use --as-needed, they need
to add their own
3. if neither is supported, unconditionally link
Like libm, what is actually needed at link time depends on inlining,
which is affected by constant propagation, so it is impossible to build
100% reliable tests.
Simon