public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Opt-out static C++ link check and tests
@ 2024-05-25 12:26 H.J. Lu
  2024-05-25 12:26 ` [PATCH v2 1/2] Add --disable-static-c++-link-check option [BZ #31412] H.J. Lu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: H.J. Lu @ 2024-05-25 12:26 UTC (permalink / raw)
  To: libc-alpha; +Cc: fweimer

The current glibc build and test will fail if static C++ link doesn't
work.  There are cases where static C++ link is hard to supported:

1. Building i686 glibc with GCC 6.4 on Fedora 40 failed since the C++
header files couldn't be found which was caused by the static C++ link
check failure due to missing __divmoddi4 which was referenced in i686
libc.a and added to GCC 7. 
2. Glibc test won't finish because static C++ tests fail when the C++
toolchain doesn't have necessary static C++ libraries which may not be
easily installed.

Add --disable-static-c++-link-check configure option to disable the static
C++ link check.  Add --disable-static-c++-tests option to skip the static
C++ tests which also implies --disable-static-c++-link-check.

H.J. Lu (2):
  Add --disable-static-c++-link-check option [BZ #31412]
  Add --disable-static-c++-tests option [BZ #31797]

 INSTALL             | 17 +++++++++++++++++
 configure           | 44 ++++++++++++++++++++++++++++++++++++--------
 configure.ac        | 35 +++++++++++++++++++++++++----------
 manual/install.texi | 16 ++++++++++++++++
 nptl/Makefile       |  3 +++
 5 files changed, 97 insertions(+), 18 deletions(-)

-- 
2.45.1


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

* [PATCH v2 1/2] Add --disable-static-c++-link-check option [BZ #31412]
  2024-05-25 12:26 [PATCH v2 0/2] Opt-out static C++ link check and tests H.J. Lu
@ 2024-05-25 12:26 ` H.J. Lu
  2024-06-20 18:22   ` Carlos O'Donell
  2024-05-25 12:26 ` [PATCH v2 2/2] Add --disable-static-c++-tests option [BZ #31797] H.J. Lu
  2024-06-20 18:23 ` [PATCH v2 0/2] Opt-out static C++ link check and tests Carlos O'Donell
  2 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2024-05-25 12:26 UTC (permalink / raw)
  To: libc-alpha; +Cc: fweimer

The current minimum GCC version of glibc build is GCC 6.2 or newer. But
building i686 glibc with GCC 6.4 on Fedora 40 failed since the C++ header
files couldn't be found which was caused by the static C++ link check
failure due to missing __divmoddi4 which was referenced in i686 libc.a
and added to GCC 7.  Add --disable-static-c++-link-check configure option
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>
---
 INSTALL             |  8 ++++++++
 configure           | 24 +++++++++++++++++++-----
 configure.ac        | 22 +++++++++++++++-------
 manual/install.texi |  8 ++++++++
 4 files changed, 50 insertions(+), 12 deletions(-)

diff --git a/INSTALL b/INSTALL
index c8c524527b..d8b06f20aa 100644
--- a/INSTALL
+++ b/INSTALL
@@ -224,6 +224,14 @@ if 'CFLAGS' is specified it must enable optimization.  For example:
      By default for x86_64, the GNU C Library is built with the vector
      math library.  Use this option to disable the vector math library.
 
+'--disable-static-c++-link-check'
+     By default, if the C++ toolchain doesn't not support static
+     linking, configure couldn't find the C++ header files and the glibc
+     build fails.  Use this option to disable the static C++ link check
+     so that the C++ header files can be located.  The newly built
+     libc.a can be used to create static C++ tests if the C++ toolchain
+     has necessary static C++ libraries.
+
 '--disable-scv'
      Disable using 'scv' instruction for syscalls.  All syscalls will
      use 'sc' instead, even if the kernel supports 'scv'.  PowerPC only.
diff --git a/configure b/configure
index 432e40a592..31205ce568 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]
+  --disable-static-c++-link-check
+                          disable static C++ link check [default=no]
   --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..ee64d49b03 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([--disable-static-c++-link-check],
+			     [disable static C++ link check @<:@default=no@:>@]),
+	      [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=])
 
diff --git a/manual/install.texi b/manual/install.texi
index 7c44594617..ac3728c301 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -252,6 +252,14 @@ configure with @option{--disable-werror}.
 By default for x86_64, @theglibc{} is built with the vector math library.
 Use this option to disable the vector math library.
 
+@item --disable-static-c++-link-check
+By default, if the C++ toolchain doesn't not support static linking,
+configure couldn't find the C++ header files and the glibc build fails.
+Use this option to disable the static C++ link check so that the C++
+header files can be located.  The newly built libc.a can be used to
+create static C++ tests if the C++ toolchain has necessary static C++
+libraries.
+
 @item --disable-scv
 Disable using @code{scv} instruction for syscalls. All syscalls will use
 @code{sc} instead, even if the kernel supports @code{scv}. PowerPC only.
-- 
2.45.1


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

* [PATCH v2 2/2] Add --disable-static-c++-tests option [BZ #31797]
  2024-05-25 12:26 [PATCH v2 0/2] Opt-out static C++ link check and tests H.J. Lu
  2024-05-25 12:26 ` [PATCH v2 1/2] Add --disable-static-c++-link-check option [BZ #31412] H.J. Lu
@ 2024-05-25 12:26 ` H.J. Lu
  2024-06-20 18:22   ` Carlos O'Donell
  2024-06-20 18:23 ` [PATCH v2 0/2] Opt-out static C++ link check and tests Carlos O'Donell
  2 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2024-05-25 12:26 UTC (permalink / raw)
  To: libc-alpha; +Cc: fweimer

By default, if the C++ toolchain doesn't not support static linking,
configure couldn't find the C++ header files and the glibc build fails.
The --disable-static-c++-link-check option allows the glibc build to
finish, but static C++ tests will fail if the C++ toolchain doesn't
have necessary static C++ libraries which may not be easily installed.
Add --disable-static-c++-tests option to skip the static C++ link check
and tests.  This fixes BZ #31797.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 INSTALL             |  9 +++++++++
 configure           | 22 ++++++++++++++++++----
 configure.ac        | 15 +++++++++++----
 manual/install.texi |  8 ++++++++
 nptl/Makefile       |  3 +++
 5 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/INSTALL b/INSTALL
index d8b06f20aa..00c07e1515 100644
--- a/INSTALL
+++ b/INSTALL
@@ -224,6 +224,15 @@ if 'CFLAGS' is specified it must enable optimization.  For example:
      By default for x86_64, the GNU C Library is built with the vector
      math library.  Use this option to disable the vector math library.
 
+'--disable-static-c++-tests'
+     By default, if the C++ toolchain doesn't not support static
+     linking, configure couldn't find the C++ header files and the glibc
+     build fails.  '--disable-static-c++-link-check' allows the glibc
+     build to finish, but static C++ tests will fail if the C++
+     toolchain doesn't have necessary static C++ libraries.  Use this
+     option to skip the static C++ tests.  This option implies
+     '--disable-static-c++-link-check'.
+
 '--disable-static-c++-link-check'
      By default, if the C++ toolchain doesn't not support static
      linking, configure couldn't find the C++ header files and the glibc
diff --git a/configure b/configure
index 31205ce568..49b093043c 100755
--- a/configure
+++ b/configure
@@ -778,6 +778,7 @@ ac_user_opts='
 enable_option_checking
 with_pkgversion
 with_bugurl
+enable_static_c___tests
 enable_static_c___link_check
 with_gd
 with_gd_include
@@ -1448,6 +1449,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]
+  --disable-static-c++-tests
+                          disable static C++ tests[default=no]
   --disable-static-c++-link-check
                           disable static C++ link check [default=no]
   --disable-sanity-checks really do not use threads (should not be used except
@@ -3813,6 +3816,20 @@ if test -z "$CPP"; then
 fi
 
 
+# This will get text that should go into config.make.
+config_vars=
+
+# Check whether --enable-static-c++-tests was given.
+if test ${enable_static_c___tests+y}
+then :
+  enableval=$enable_static_c___tests; static_cxx_tests=$enableval
+else $as_nop
+  static_cxx_tests=yes
+fi
+
+config_vars="$config_vars
+static-cxx-tests = $static_cxx_tests"
+
 # Check whether --enable-static-c++-link-check was given.
 if test ${enable_static_c___link_check+y}
 then :
@@ -4232,7 +4249,7 @@ else $as_nop
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
-if test $static_cxx_link_check = yes; then
+if test $static_cxx_link_check$static_cxx_tests = yesyes; then
   # Static case.
   old_LDFLAGS="$LDFLAGS"
   LDFLAGS="$LDFLAGS -static"
@@ -4277,9 +4294,6 @@ if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
   as_fn_error $? "you must configure in a separate build directory" "$LINENO" 5
 fi
 
-# This will get text that should go into config.make.
-config_vars=
-
 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
 
 # Check whether --with-gd was given.
diff --git a/configure.ac b/configure.ac
index ee64d49b03..e48957f318 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,16 @@ fi
 AC_SUBST(cross_compiling)
 AC_PROG_CPP
 
+# This will get text that should go into config.make.
+config_vars=
+
+AC_ARG_ENABLE([static-c++-tests],
+	      AS_HELP_STRING([--disable-static-c++-tests],
+			     [disable static C++ tests@<:@default=no@:>@]),
+	      [static_cxx_tests=$enableval],
+	      [static_cxx_tests=yes])
+LIBC_CONFIG_VAR([static-cxx-tests], [$static_cxx_tests])
+
 AC_ARG_ENABLE([static-c++-link-check],
 	      AS_HELP_STRING([--disable-static-c++-link-check],
 			     [disable static C++ link check @<:@default=no@:>@]),
@@ -67,7 +77,7 @@ AC_LANG_PUSH([C++])
 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
 	       [libc_cv_cxx_link_ok=yes],
 	       [libc_cv_cxx_link_ok=no])
-if test $static_cxx_link_check = yes; then
+if test $static_cxx_link_check$static_cxx_tests = yesyes; then
   # Static case.
   old_LDFLAGS="$LDFLAGS"
   LDFLAGS="$LDFLAGS -static"
@@ -92,9 +102,6 @@ if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
   AC_MSG_ERROR([you must configure in a separate build directory])
 fi
 
-# This will get text that should go into config.make.
-config_vars=
-
 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
 AC_ARG_WITH([gd],
 	    AS_HELP_STRING([--with-gd=DIR],
diff --git a/manual/install.texi b/manual/install.texi
index ac3728c301..916b33f2a7 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -252,6 +252,14 @@ configure with @option{--disable-werror}.
 By default for x86_64, @theglibc{} is built with the vector math library.
 Use this option to disable the vector math library.
 
+@item --disable-static-c++-tests
+By default, if the C++ toolchain doesn't not support static linking,
+configure couldn't find the C++ header files and the glibc build fails.
+@option{--disable-static-c++-link-check} allows the glibc build to finish,
+but static C++ tests will fail if the C++ toolchain doesn't have necessary
+static C++ libraries.  Use this option to skip the static C++ tests.  This
+option implies @option{--disable-static-c++-link-check}.
+
 @item --disable-static-c++-link-check
 By default, if the C++ toolchain doesn't not support static linking,
 configure couldn't find the C++ header files and the glibc build fails.
diff --git a/nptl/Makefile b/nptl/Makefile
index b3f8af2e1c..cf85a3717d 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -545,6 +545,9 @@ tests-static += \
   # tests-static
 
 tests += tst-cancel24-static
+ifeq ($(static-cxx-tests),no)
+tests-unsupported += tst-cancel24-static
+endif
 
 tests-internal += \
   tst-sem11-static \
-- 
2.45.1


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

* Re: [PATCH v2 2/2] Add --disable-static-c++-tests option [BZ #31797]
  2024-05-25 12:26 ` [PATCH v2 2/2] Add --disable-static-c++-tests option [BZ #31797] H.J. Lu
@ 2024-06-20 18:22   ` Carlos O'Donell
  0 siblings, 0 replies; 6+ messages in thread
From: Carlos O'Donell @ 2024-06-20 18:22 UTC (permalink / raw)
  To: H.J. Lu, libc-alpha; +Cc: fweimer

On 5/25/24 8:26 AM, H.J. Lu wrote:
> By default, if the C++ toolchain doesn't not support static linking,
> configure couldn't find the C++ header files and the glibc build fails.
> The --disable-static-c++-link-check option allows the glibc build to
> finish, but static C++ tests will fail if the C++ toolchain doesn't
> have necessary static C++ libraries which may not be easily installed.
> Add --disable-static-c++-tests option to skip the static C++ link check
> and tests.  This fixes BZ #31797.

Suggest commit message:

By default, if the C++ toolchain lacks support for static linking,
configure fails to find the C++ header files and the glibc build fails.
The --disable-static-c++-link-check option allows the glibc build to
finish, but static C++ tests will fail if the C++ toolchain doesn't
have the necessary static C++ libraries which may not be easily installed.
Add --disable-static-c++-tests option to skip the static C++ link check
and tests.  This fixes BZ #31797.

OK if you accept the suggested text changes.

You may keep my RB if you make the suggested textual changes.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  INSTALL             |  9 +++++++++
>  configure           | 22 ++++++++++++++++++----
>  configure.ac        | 15 +++++++++++----
>  manual/install.texi |  8 ++++++++
>  nptl/Makefile       |  3 +++
>  5 files changed, 49 insertions(+), 8 deletions(-)
> 
> diff --git a/INSTALL b/INSTALL
> index d8b06f20aa..00c07e1515 100644
> --- a/INSTALL
> +++ b/INSTALL
> @@ -224,6 +224,15 @@ if 'CFLAGS' is specified it must enable optimization.  For example:
>       By default for x86_64, the GNU C Library is built with the vector
>       math library.  Use this option to disable the vector math library.
>  
> +'--disable-static-c++-tests'
> +     By default, if the C++ toolchain doesn't not support static
> +     linking, configure couldn't find the C++ header files and the glibc
> +     build fails.  '--disable-static-c++-link-check' allows the glibc
> +     build to finish, but static C++ tests will fail if the C++
> +     toolchain doesn't have necessary static C++ libraries.  Use this
> +     option to skip the static C++ tests.  This option implies
> +     '--disable-static-c++-link-check'.
> +
>  '--disable-static-c++-link-check'
>       By default, if the C++ toolchain doesn't not support static
>       linking, configure couldn't find the C++ header files and the glibc
> diff --git a/configure b/configure
> index 31205ce568..49b093043c 100755
> --- a/configure
> +++ b/configure
> @@ -778,6 +778,7 @@ ac_user_opts='
>  enable_option_checking
>  with_pkgversion
>  with_bugurl
> +enable_static_c___tests
>  enable_static_c___link_check
>  with_gd
>  with_gd_include
> @@ -1448,6 +1449,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]
> +  --disable-static-c++-tests
> +                          disable static C++ tests[default=no]
>    --disable-static-c++-link-check
>                            disable static C++ link check [default=no]
>    --disable-sanity-checks really do not use threads (should not be used except
> @@ -3813,6 +3816,20 @@ if test -z "$CPP"; then
>  fi
>  
>  
> +# This will get text that should go into config.make.
> +config_vars=
> +
> +# Check whether --enable-static-c++-tests was given.
> +if test ${enable_static_c___tests+y}
> +then :
> +  enableval=$enable_static_c___tests; static_cxx_tests=$enableval
> +else $as_nop
> +  static_cxx_tests=yes
> +fi
> +
> +config_vars="$config_vars
> +static-cxx-tests = $static_cxx_tests"
> +
>  # Check whether --enable-static-c++-link-check was given.
>  if test ${enable_static_c___link_check+y}
>  then :
> @@ -4232,7 +4249,7 @@ else $as_nop
>  fi
>  rm -f core conftest.err conftest.$ac_objext conftest.beam \
>      conftest$ac_exeext conftest.$ac_ext
> -if test $static_cxx_link_check = yes; then
> +if test $static_cxx_link_check$static_cxx_tests = yesyes; then
>    # Static case.
>    old_LDFLAGS="$LDFLAGS"
>    LDFLAGS="$LDFLAGS -static"
> @@ -4277,9 +4294,6 @@ if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
>    as_fn_error $? "you must configure in a separate build directory" "$LINENO" 5
>  fi
>  
> -# This will get text that should go into config.make.
> -config_vars=
> -
>  # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
>  
>  # Check whether --with-gd was given.
> diff --git a/configure.ac b/configure.ac
> index ee64d49b03..e48957f318 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -52,6 +52,16 @@ fi
>  AC_SUBST(cross_compiling)
>  AC_PROG_CPP
>  
> +# This will get text that should go into config.make.
> +config_vars=
> +
> +AC_ARG_ENABLE([static-c++-tests],
> +	      AS_HELP_STRING([--disable-static-c++-tests],
> +			     [disable static C++ tests@<:@default=no@:>@]),
> +	      [static_cxx_tests=$enableval],
> +	      [static_cxx_tests=yes])
> +LIBC_CONFIG_VAR([static-cxx-tests], [$static_cxx_tests])
> +
>  AC_ARG_ENABLE([static-c++-link-check],
>  	      AS_HELP_STRING([--disable-static-c++-link-check],
>  			     [disable static C++ link check @<:@default=no@:>@]),
> @@ -67,7 +77,7 @@ AC_LANG_PUSH([C++])
>  AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
>  	       [libc_cv_cxx_link_ok=yes],
>  	       [libc_cv_cxx_link_ok=no])
> -if test $static_cxx_link_check = yes; then
> +if test $static_cxx_link_check$static_cxx_tests = yesyes; then
>    # Static case.
>    old_LDFLAGS="$LDFLAGS"
>    LDFLAGS="$LDFLAGS -static"
> @@ -92,9 +102,6 @@ if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
>    AC_MSG_ERROR([you must configure in a separate build directory])
>  fi
>  
> -# This will get text that should go into config.make.
> -config_vars=
> -
>  # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
>  AC_ARG_WITH([gd],
>  	    AS_HELP_STRING([--with-gd=DIR],
> diff --git a/manual/install.texi b/manual/install.texi
> index ac3728c301..916b33f2a7 100644
> --- a/manual/install.texi
> +++ b/manual/install.texi
> @@ -252,6 +252,14 @@ configure with @option{--disable-werror}.
>  By default for x86_64, @theglibc{} is built with the vector math library.
>  Use this option to disable the vector math library.
>  
> +@item --disable-static-c++-tests
> +By default, if the C++ toolchain doesn't not support static linking,
> +configure couldn't find the C++ header files and the glibc build fails.
> +@option{--disable-static-c++-link-check} allows the glibc build to finish,
> +but static C++ tests will fail if the C++ toolchain doesn't have necessary
> +static C++ libraries.  Use this option to skip the static C++ tests.  This
> +option implies @option{--disable-static-c++-link-check}.

Suggested:

By default, if the C++ toolchain lacks support for static linking,
configure fails to find the C++ header files and the glibc build fails.
@option{--disable-static-c++-link-check} allows the glibc build to finish,
but static C++ tests will fail if the C++ toolchain doesn't have the
necessary static C++ libraries.  Use this option to skip the static C++
tests.  This option implies @option{--disable-static-c++-link-check}.

> +
>  @item --disable-static-c++-link-check
>  By default, if the C++ toolchain doesn't not support static linking,
>  configure couldn't find the C++ header files and the glibc build fails.
> diff --git a/nptl/Makefile b/nptl/Makefile
> index b3f8af2e1c..cf85a3717d 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -545,6 +545,9 @@ tests-static += \
>    # tests-static
>  
>  tests += tst-cancel24-static
> +ifeq ($(static-cxx-tests),no)
> +tests-unsupported += tst-cancel24-static
> +endif

OK. Though we now have checks for $(CXX), $(have-cxx-thread_local), and $(static-cxx-tests).
I'm OK with this going here because it's close to the test definition, but I'll note that
further down we have:

568 ifeq (,$(CXX))
569 # These tests require a C++ compiler and runtime.
570 tests-unsupported += \
571   tst-cancel24 \
572   tst-cancel24-static \
573   tst-minstack-throw \
574   tst-once5 \
575   tst-thread-exit-clobber \
576   # tests-unsupported
577 endif
578 # These tests require a C++ compiler and runtime with thread_local support.
579 ifneq ($(have-cxx-thread_local),yes)
580 tests-unsupported += tst-thread_local1
581 endif

So in the future we might consolidate more the test disabling here.

>  
>  tests-internal += \
>    tst-sem11-static \

-- 
Cheers,
Carlos.


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

* Re: [PATCH v2 1/2] Add --disable-static-c++-link-check option [BZ #31412]
  2024-05-25 12:26 ` [PATCH v2 1/2] Add --disable-static-c++-link-check option [BZ #31412] H.J. Lu
@ 2024-06-20 18:22   ` Carlos O'Donell
  0 siblings, 0 replies; 6+ messages in thread
From: Carlos O'Donell @ 2024-06-20 18:22 UTC (permalink / raw)
  To: H.J. Lu, libc-alpha; +Cc: fweimer

On 5/25/24 8:26 AM, H.J. Lu wrote:
> The current minimum GCC version of glibc build is GCC 6.2 or newer. But
> building i686 glibc with GCC 6.4 on Fedora 40 failed since the C++ header
> files couldn't be found which was caused by the static C++ link check
> failure due to missing __divmoddi4 which was referenced in i686 libc.a
> and added to GCC 7.  Add --disable-static-c++-link-check configure option
> 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.

OK with the suggested text changes.

You may keep my RB if you make the suggested textual changes.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  INSTALL             |  8 ++++++++
>  configure           | 24 +++++++++++++++++++-----
>  configure.ac        | 22 +++++++++++++++-------
>  manual/install.texi |  8 ++++++++
>  4 files changed, 50 insertions(+), 12 deletions(-)
> 
> diff --git a/INSTALL b/INSTALL
> index c8c524527b..d8b06f20aa 100644
> --- a/INSTALL
> +++ b/INSTALL
> @@ -224,6 +224,14 @@ if 'CFLAGS' is specified it must enable optimization.  For example:
>       By default for x86_64, the GNU C Library is built with the vector
>       math library.  Use this option to disable the vector math library.
>  
> +'--disable-static-c++-link-check'
> +     By default, if the C++ toolchain doesn't not support static
> +     linking, configure couldn't find the C++ header files and the glibc
> +     build fails.  Use this option to disable the static C++ link check
> +     so that the C++ header files can be located.  The newly built
> +     libc.a can be used to create static C++ tests if the C++ toolchain
> +     has necessary static C++ libraries.
> +
>  '--disable-scv'
>       Disable using 'scv' instruction for syscalls.  All syscalls will
>       use 'sc' instead, even if the kernel supports 'scv'.  PowerPC only.
> diff --git a/configure b/configure
> index 432e40a592..31205ce568 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]
> +  --disable-static-c++-link-check
> +                          disable static C++ link check [default=no]
>    --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..ee64d49b03 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([--disable-static-c++-link-check],
> +			     [disable static C++ link check @<:@default=no@:>@]),
> +	      [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=])
>  
> diff --git a/manual/install.texi b/manual/install.texi
> index 7c44594617..ac3728c301 100644
> --- a/manual/install.texi
> +++ b/manual/install.texi
> @@ -252,6 +252,14 @@ configure with @option{--disable-werror}.
>  By default for x86_64, @theglibc{} is built with the vector math library.
>  Use this option to disable the vector math library.
>  
> +@item --disable-static-c++-link-check
> +By default, if the C++ toolchain doesn't not support static linking,
> +configure couldn't find the C++ header files and the glibc build fails.
> +Use this option to disable the static C++ link check so that the C++
> +header files can be located.  The newly built libc.a can be used to
> +create static C++ tests if the C++ toolchain has necessary static C++
> +libraries.

Suggest:

By default, if the C++ toolchain lacks support for static linking,
configure fails to find the C++ header files and the glibc build fails.
Use this option to disable the static C++ link check so that the C++
header files can be located.  The newly built libc.a can be used to
create static C++ tests if the C++ toolchain has the necessary static
C++ libraries.


> +
>  @item --disable-scv
>  Disable using @code{scv} instruction for syscalls. All syscalls will use
>  @code{sc} instead, even if the kernel supports @code{scv}. PowerPC only.

-- 
Cheers,
Carlos.


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

* Re: [PATCH v2 0/2] Opt-out static C++ link check and tests
  2024-05-25 12:26 [PATCH v2 0/2] Opt-out static C++ link check and tests H.J. Lu
  2024-05-25 12:26 ` [PATCH v2 1/2] Add --disable-static-c++-link-check option [BZ #31412] H.J. Lu
  2024-05-25 12:26 ` [PATCH v2 2/2] Add --disable-static-c++-tests option [BZ #31797] H.J. Lu
@ 2024-06-20 18:23 ` Carlos O'Donell
  2 siblings, 0 replies; 6+ messages in thread
From: Carlos O'Donell @ 2024-06-20 18:23 UTC (permalink / raw)
  To: H.J. Lu, libc-alpha; +Cc: fweimer

On 5/25/24 8:26 AM, H.J. Lu wrote:
> The current glibc build and test will fail if static C++ link doesn't
> work.  There are cases where static C++ link is hard to supported:

OK.

> 1. Building i686 glibc with GCC 6.4 on Fedora 40 failed since the C++
> header files couldn't be found which was caused by the static C++ link
> check failure due to missing __divmoddi4 which was referenced in i686
> libc.a and added to GCC 7. 

OK.

> 2. Glibc test won't finish because static C++ tests fail when the C++
> toolchain doesn't have necessary static C++ libraries which may not be
> easily installed.

OK.

> Add --disable-static-c++-link-check configure option to disable the static
> C++ link check.  Add --disable-static-c++-tests option to skip the static
> C++ tests which also implies --disable-static-c++-link-check.

OK.
 
> H.J. Lu (2):
>   Add --disable-static-c++-link-check option [BZ #31412]
>   Add --disable-static-c++-tests option [BZ #31797]

Overall they look OK to me, but text needed a little updating to avoid
the double negative.

Reviews provided for both.

> 
>  INSTALL             | 17 +++++++++++++++++
>  configure           | 44 ++++++++++++++++++++++++++++++++++++--------
>  configure.ac        | 35 +++++++++++++++++++++++++----------
>  manual/install.texi | 16 ++++++++++++++++
>  nptl/Makefile       |  3 +++
>  5 files changed, 97 insertions(+), 18 deletions(-)
> 

-- 
Cheers,
Carlos.


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

end of thread, other threads:[~2024-06-20 18:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-25 12:26 [PATCH v2 0/2] Opt-out static C++ link check and tests H.J. Lu
2024-05-25 12:26 ` [PATCH v2 1/2] Add --disable-static-c++-link-check option [BZ #31412] H.J. Lu
2024-06-20 18:22   ` Carlos O'Donell
2024-05-25 12:26 ` [PATCH v2 2/2] Add --disable-static-c++-tests option [BZ #31797] H.J. Lu
2024-06-20 18:22   ` Carlos O'Donell
2024-06-20 18:23 ` [PATCH v2 0/2] Opt-out static C++ link check and tests Carlos O'Donell

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).