Hi!

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.
The following patch attempts to deal with the libatomic_asneeded.so
file creation by using move-if-change and for libatomic_asneeded.a
it will only create the symlink if the file libatomic_asneeded.a
doesn't exist (because sometimes it is a symlink and sometimes file
copy and not sure how exactly portably verify if it either is a symlink
to the right file or the right file copy).

Though, now that I think about it again, the errors are not about
libatomic_asneeded.{so,a} but libatomic.so, which is something installed by
$(LIBTOOL) --mode=install $(INSTALL_DATA) libatomic.la 
$(gcc_objdir)$(MULTISUBDIR)/
So I'm afraid this needs to go back to the drawing board, but unsure about
to arrange it safely.  Maybe libtool install it into a fresh tmp
subdirectory and move-if-change each file in that subdirectory, though
again dunno how to deal with symlinks.  Or somehow figure out whether
all-local is run from check-am and in that case don't perform all-local
at all or do it only after some checks.

2026-02-19  Jakub Jelinek  <[email protected]>

        * Makefile.am (all-local): Use move-if-change for
        libatomic_asneeded.so and never remove libatomic_asneeded.a,
        just create the symlink if it doesn't exist.
        * Makefile.in: Regenerate.

--- libatomic/Makefile.am.jj    2026-01-30 11:43:46.690560100 +0100
+++ libatomic/Makefile.am       2026-02-18 22:07:57.774094876 +0100
@@ -188,8 +188,10 @@ if LIBAT_BUILD_ASNEEDED_SOLINK
        if test -f libatomic.so; then (echo "/* GNU ld script"; \
         echo "   Add DT_NEEDED entry for -latomic only if needed.  */"; \
         echo "INPUT ( AS_NEEDED ( -latomic ) )" \
-       ) > libatomic_asneeded.so; fi; \
-       if test -f libatomic.a; then rm -f libatomic_asneeded.a; \
+       ) > tmp-libatomic_asneeded.so; fi; \
+       $(SHELL) $(abs_top_srcdir)/../move-if-change tmp-libatomic_asneeded.so \
+         libatomic_asneeded.so; \
+       if test -f libatomic.a -a ! -f libatomic_asneeded.a; then \
        $(LN_S) libatomic.a libatomic_asneeded.a; fi
 endif
        rm $(gcc_objdir)$(MULTISUBDIR)/libatomic.la
--- libatomic/Makefile.in.jj    2026-01-30 11:43:46.692177633 +0100
+++ libatomic/Makefile.in       2026-02-18 22:10:48.894645248 +0100
@@ -935,8 +935,10 @@ all-local: libatomic.la
 @LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@     if test -f libatomic.so; then (echo "/* 
GNU ld script"; \
 @LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@      echo "   Add DT_NEEDED entry for 
-latomic only if needed.  */"; \
 @LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@      echo "INPUT ( AS_NEEDED ( -latomic ) 
)" \
-@LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@     ) > libatomic_asneeded.so; fi; \
-@LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@     if test -f libatomic.a; then rm -f 
libatomic_asneeded.a; \
+@LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@     ) > tmp-libatomic_asneeded.so; fi; \
+@LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@     $(SHELL) 
$(abs_top_srcdir)/../move-if-change tmp-libatomic_asneeded.so \
+@LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@       libatomic_asneeded.so; \
+@LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@     if test -f libatomic.a -a ! -f 
libatomic_asneeded.a; then \
 @LIBAT_BUILD_ASNEEDED_SOLINK_TRUE@     $(LN_S) libatomic.a 
libatomic_asneeded.a; fi
        rm $(gcc_objdir)$(MULTISUBDIR)/libatomic.la
 

        Jakub

Reply via email to