public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add --enable-static-c++-link-check option [BZ #31412]
@ 2024-05-24 21:57 H.J. Lu
  2024-05-25  9:54 ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2024-05-24 21:57 UTC (permalink / raw)
  To: libc-alpha; +Cc: fweimer

The current minimum GCC version of glibc build is GCC 6.2 or newer.  When
building i686 glibc on Fedora 40, GCC 6.4 failed the static C++ link test
since the 32-bit libc.a was built with GCC 14 and has references to
__divmoddi4 which was added to GCC 7.  Add --enable-static-c++-link-check
configure option which is on by default.  --disable-static-c++-link-check
can be used to disable the static C++ link test.  The newly built i686
libc.a can be used by GCC 6.4 to create static C++ tests.  This fixes
BZ #31412.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 configure    | 24 +++++++++++++++++++-----
 configure.ac | 22 +++++++++++++++-------
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/configure b/configure
index 432e40a592..58e82d792d 100755
--- a/configure
+++ b/configure
@@ -778,6 +778,7 @@ ac_user_opts='
 enable_option_checking
 with_pkgversion
 with_bugurl
+enable_static_c___link_check
 with_gd
 with_gd_include
 with_gd_lib
@@ -1447,6 +1448,8 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-static-c++-link-check
+                          enable static C++ link check [default=yes]
   --disable-sanity-checks really do not use threads (should not be used except
                           in special situations) [default=yes]
   --enable-shared         build shared library [default=yes if GNU ld]
@@ -3810,6 +3813,15 @@ if test -z "$CPP"; then
 fi
 
 
+# Check whether --enable-static-c++-link-check was given.
+if test ${enable_static_c___link_check+y}
+then :
+  enableval=$enable_static_c___link_check; static_cxx_link_check=$enableval
+else $as_nop
+  static_cxx_link_check=yes
+fi
+
+
 # We need the C++ compiler only for testing.
 
 
@@ -4220,10 +4232,11 @@ else $as_nop
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
-# Static case.
-old_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS -static"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+if test $static_cxx_link_check = yes; then
+  # Static case.
+  old_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS -static"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 #include <iostream>
@@ -4244,7 +4257,8 @@ else $as_nop
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
-LDFLAGS="$old_LDFLAGS"
+  LDFLAGS="$old_LDFLAGS"
+fi
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
diff --git a/configure.ac b/configure.ac
index bdc385d03c..12de4c3d15 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,12 @@ fi
 AC_SUBST(cross_compiling)
 AC_PROG_CPP
 
+AC_ARG_ENABLE([static-c++-link-check],
+	      AS_HELP_STRING([--enable-static-c++-link-check],
+			     [enable static C++ link check @<:@default=yes@:>@]),
+	      [static_cxx_link_check=$enableval],
+	      [static_cxx_link_check=yes])
+
 # We need the C++ compiler only for testing.
 AC_PROG_CXX
 # It's useless to us if it can't link programs (e.g. missing -lstdc++).
@@ -61,10 +67,11 @@ AC_LANG_PUSH([C++])
 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
 	       [libc_cv_cxx_link_ok=yes],
 	       [libc_cv_cxx_link_ok=no])
-# Static case.
-old_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS -static"
-AC_LINK_IFELSE([AC_LANG_SOURCE([
+if test $static_cxx_link_check = yes; then
+  # Static case.
+  old_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS -static"
+  AC_LINK_IFELSE([AC_LANG_SOURCE([
 #include <iostream>
 
 int
@@ -74,9 +81,10 @@ main()
   return 0;
 }
 ])],
-	       [],
-	       [libc_cv_cxx_link_ok=no])
-LDFLAGS="$old_LDFLAGS"
+		 [],
+		 [libc_cv_cxx_link_ok=no])
+  LDFLAGS="$old_LDFLAGS"
+fi
 AC_LANG_POP([C++])])
 AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
 
-- 
2.45.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-26 14:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-24 21:57 [PATCH] Add --enable-static-c++-link-check option [BZ #31412] H.J. Lu
2024-05-25  9:54 ` Florian Weimer
2024-05-25 10:44   ` H.J. Lu
2024-05-25 16:07     ` Florian Weimer
2024-05-25 16:14       ` H.J. Lu
2024-05-26 14:07         ` Florian Weimer
2024-05-26 14:26           ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).