On Fri, 10 Oct 2025 at 21:11, Joseph Myers wrote:

> On Fri, 10 Oct 2025, Matthew Malcomson wrote:
>
> > Questions for others:
> > 1) We'd like to double-check that this sounds like a problem before
> trying to
> > change it.
> > 2) Does this trigger thoughts of anything else to look out for?
> > 3) Would the best solution be to add some `--as-needed` push/pop state
> > arguments into the link line?
>
> Yes, I'd expect libstdc++ to be linked (DT_NEEDED) with libatomic only if
> it actually has undefined references that libatomic resolves.
>
>
We try quite hard to avoid libstdc++ having any undefined references to
libatomic functions. The atomics inside the library are defined in terms of
the config/cpu/**/atomicity.h functions, which only operate on int and
which are defined using inline assembly (and spinlocks when needed). That's
partly because those functions predate libatomic, but partly because it
makes libstdc++ self-sufficient.

So until now, users only needed to link to libatomic if their own code used
atomics on types that require libatomic calls, but libstdc++.so doesn't do
that.

Reply via email to