[PATCH] Link static C++ tests against libatomic.a if needed
H.J. Lu
hjl.tools@gmail.com
Tue May 5 01:50:00 GMT 2026
On Tue, May 5, 2026 at 9:42 AM Sam James <sam@gentoo.org> wrote:
>
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
> > On Mon, May 4, 2026 at 10:33 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >>
> >> Define cxx-static-link-libatomic to -latomic if DT_NEEDED entries in
> >> libstdc++.so include libatomic.so. Update link-extra-libs-static to
> >> include $(cxx-static-link-libatomic) if -lstdc++ is used.
> >>
> >> Tested with sparcv8-linux-gnu-leon3 and sparcv9-linux-gnu using
> >> uild-many-glibcs.py. This fixes BZ #34121.
> >>
> >
> > FWIW, sparc g++ does pass -latomic_asneeded to ld. But glibc tests
> > are built with -nostdlib -nostartfiles using gcc, not g++.
>
> https://inbox.sourceware.org/gcc-patches/CACb0b4m+ex47Tpyp1qvW9+0p4onyEvsfXeXE_4zZrteMO5q5EQ@mail.gmail.com/
>
> I don't remember what happened with that, there were a few issues with
> the libatomic autolinking so I lost track.
One way to fix the gcc is to create libstdc++.a as linker script, similar to
[hjl@gnu-tgl-3 x86-glibc]$ cat /usr/lib64/libm.a
/* GNU ld script
*/
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /usr/lib64/libm-2.43.a /usr/lib64/libmvec.a )
[hjl@gnu-tgl-3 x86-glibc]$
to include libatomic.a in libstdc++.a if needed. But I don't know if it works
everywhere.
--
H.J.
More information about the Libc-alpha
mailing list