]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
support: Link links-dso-program-c with libgcc_s only if available
authorFlorian Weimer <fweimer@redhat.com>
Fri, 21 Mar 2025 20:40:28 +0000 (21:40 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 21 Mar 2025 20:40:28 +0000 (21:40 +0100)
Add a configure check to detect bootstrapping builds that do not
have libgcc_s.

Fixes commit 3e2be87832781a29ed67f38f87c1ce3dd4c1b866 ("support: Link
links-dso-program-c against libgcc_s").

Reviewed-by: Sam James <sam@gentoo.org>
configure
configure.ac
support/Makefile

index 674d1d7e4a69c10f5b992b24590520d8f296d0c2..d11dcf97c564f848b7040dc7dec6e5753f4b635a 100755 (executable)
--- a/configure
+++ b/configure
@@ -9135,6 +9135,46 @@ fi
 config_vars="$config_vars
 enable-static-pie = $libc_cv_static_pie"
 
+# Check if we can link support functionality against libgcc_s.
+# Must not be used for linking installed binaries, to produce the
+# same binaries for bootstrapped and bootstrapping builds (the latter
+# with a GCC that does not build libgcc_s).
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC can link against -lgcc_s" >&5
+printf %s "checking whether $CC can link against -lgcc_s... " >&6; }
+if test ${libc_cv_have_libgcc_s+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e)   old_LIBS="$LIBS"
+  LIBS="$LIBS -lgcc_s"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  libc_cv_have_libgcc_s=yes
+else case e in #(
+  e) libc_cv_have_libgcc_s=no ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+  LIBS="$old_LIBS" ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_have_libgcc_s" >&5
+printf "%s\n" "$libc_cv_have_libgcc_s" >&6; }
+config_vars="$config_vars
+have-libgcc_s = $libc_cv_have_libgcc_s"
+
 # Support configure.ac under sysdeps.
 
 
index 57cd24c87d9b1962255bc310d7ef1a6cbe3ea2d5..d068bb508276b12b1cda69904aeb72b410fcbe7b 100644 (file)
@@ -2061,6 +2061,18 @@ if test "$libc_cv_static_pie" = "yes"; then
 fi
 LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
 
+# Check if we can link support functionality against libgcc_s.
+# Must not be used for linking installed binaries, to produce the
+# same binaries for bootstrapped and bootstrapping builds (the latter
+# with a GCC that does not build libgcc_s).
+AC_CACHE_CHECK([whether $CC can link against -lgcc_s], libc_cv_have_libgcc_s, [dnl
+  old_LIBS="$LIBS"
+  LIBS="$LIBS -lgcc_s"
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+                [libc_cv_have_libgcc_s=yes], [libc_cv_have_libgcc_s=no])
+  LIBS="$old_LIBS"])
+LIBC_CONFIG_VAR([have-libgcc_s], [$libc_cv_have_libgcc_s])
+
 # Support configure.ac under sysdeps.
 AC_SUBST(libc_cv_test_cc_mprefer_vector_width)
 AC_SUBST(test_enable_cet)
index 0c670555ae633d08c47cf828966bff4416b3ae6c..ea7b4cd4a01137c2d98d7cb020351e6fe401183a 100644 (file)
@@ -282,7 +282,10 @@ CFLAGS-temp_file.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
 ifeq (,$(CXX))
 LINKS_DSO_PROGRAM = links-dso-program-c
 CFLAGS-links-dso-program-c.c += -fexceptions
-LDLIBS-links-dso-program-c = -lgcc -lgcc_s $(libunwind)
+LDLIBS-links-dso-program-c = -lgcc
+ifeq ($(have-libgcc_s),yes)
+LDLIBS-links-dso-program-c += -lgcc_s $(libunwind)
+endif
 else
 LINKS_DSO_PROGRAM = links-dso-program
 LDLIBS-links-dso-program = -lstdc++ -lgcc -lgcc_s $(libunwind)