https://gcc.gnu.org/g:f7d97316e5b7b1326494c61dc71ba6210c77710f
commit r16-7616-gf7d97316e5b7b1326494c61dc71ba6210c77710f Author: Jakub Jelinek <[email protected]> Date: Sat Feb 21 21:17:43 2026 +0100 libatomic: Fix race condition in libatomic all-local In the past few bootstraps/regtests, I got occassionally one random FAIL in libgomp testsuite, and the log said in each of the cases something like obj02/x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.log:/usr/bin/ld: error: /home/jakub/src/gcc/obj02/gcc/libatomic.so: file too short obj02/x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.log:/usr/bin/ld: error: /home/jakub/src/gcc/obj02/gcc/libatomic.so: file too short obj05/i686-pc-linux-gnu/libgomp/testsuite/libgomp.log:/home/jakub/src/gcc/obj05/gcc/libatomic.so: file not recognized: file format not recognized obj05/i686-pc-linux-gnu/libgomp/testsuite/libgomp.log:/home/jakub/src/gcc/obj05/gcc/libatomic.so: file not recognized: file format not recognized I think what happens is that make check in libgomp and make check in libatomic directories happen concurrently and in libatomic there is the check -> check_recursive -> check-am -> all-am -> all-local chain of dependencies. And all-local is like many other automake goals .PHONY, so even when it depends on libatomic.la, it is reexecuted each time and each time attempts to install libatomic*.{so,a}* again, which can race with make check in other directories. The following patch fixes it by just adding dependency for all-local on stmp-libatomic file and only rule for that file dependent on libatomic.la and performing the installation. So, if libatomic.la is not relinked, nothing is reinstalled. 2026-02-21 Jakub Jelinek <[email protected]> * Makefile.am (all-local): Depend on stmp-libatomic and otherwise do nothing. (stmp-libatomic): New goal, move all commands from all-local here plus touch $@ at the end. * Makefile.in: Regenerate. Diff: --- libatomic/Makefile.am | 4 +++- libatomic/Makefile.in | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am index 459b883084fe..49689d451018 100644 --- a/libatomic/Makefile.am +++ b/libatomic/Makefile.am @@ -181,7 +181,8 @@ all-multi: $(libatomic_la_LIBADD) # from $gcc_objdir seems to fix the issue. gcc_objdir = `pwd`/$(MULTIBUILDTOP)../../gcc/ -all-local: libatomic.la +all-local: stmp-libatomic +stmp-libatomic: libatomic.la $(LIBTOOL) --mode=install $(INSTALL_DATA) libatomic.la $(gcc_objdir)$(MULTISUBDIR)/ if LIBAT_BUILD_ASNEEDED_SOLINK cd $(gcc_objdir)$(MULTISUBDIR) || exit 1; \ @@ -193,6 +194,7 @@ if LIBAT_BUILD_ASNEEDED_SOLINK $(LN_S) libatomic.a libatomic_asneeded.a; fi endif rm $(gcc_objdir)$(MULTISUBDIR)/libatomic.la + touch $@ if LIBAT_BUILD_ASNEEDED_SOLINK install-data-am: install-asneeded diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in index 39299cb0fc11..887ae41e4402 100644 --- a/libatomic/Makefile.in +++ b/libatomic/Makefile.in @@ -929,7 +929,8 @@ vpath % $(strip $(search_path)) # makefile fragments to avoid broken *.Ppo getting included into the Makefile # when it is reloaded during the build of all-multi. all-multi: $(libatomic_la_LIBADD) -all-local: libatomic.la +all-local: stmp-libatomic +stmp-libatomic: libatomic.la $(LIBTOOL) --mode=install $(INSTALL_DATA) libatomic.la $(gcc_objdir)$(MULTISUBDIR)/ @LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@ cd $(gcc_objdir)$(MULTISUBDIR) || exit 1; \ @LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@ if test -f libatomic.so; then (echo "/* GNU ld script"; \ @@ -939,6 +940,7 @@ all-local: libatomic.la @LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@ if test -f libatomic.a; then rm -f libatomic_asneeded.a; \ @LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@ $(LN_S) libatomic.a libatomic_asneeded.a; fi rm $(gcc_objdir)$(MULTISUBDIR)/libatomic.la + touch $@ @LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@install-data-am: install-asneeded
