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

* Re: [PATCH] Add --enable-static-c++-link-check option [BZ #31412]
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2024-05-25  9:54 UTC (permalink / raw)
  To: H.J. Lu; +Cc: libc-alpha

* H. J. Lu:

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

But won't there still be tons of test suite failures?

Even CXX=no will not work because in some configurations, it's actually
libgcc_s.so.1 that can't be loaded, and that breaks pthread_cancel.

Thanks,
Florian


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

* Re: [PATCH] Add --enable-static-c++-link-check option [BZ #31412]
  2024-05-25  9:54 ` Florian Weimer
@ 2024-05-25 10:44   ` H.J. Lu
  2024-05-25 16:07     ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2024-05-25 10:44 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Sat, May 25, 2024 at 2:54 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > 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.
>
> But won't there still be tons of test suite failures?

I only saw

FAIL: misc/tst-pidfd
FAIL: misc/tst-pidfd_getpid

with GCC 6.4.  I will check if it is a testcase issue.

> Even CXX=no will not work because in some configurations, it's actually
> libgcc_s.so.1 that can't be loaded, and that breaks pthread_cancel.
>

c++ still works.  Only "c++ -static" doesn't work with the system libc.a.

-- 
H.J.

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

* Re: [PATCH] Add --enable-static-c++-link-check option [BZ #31412]
  2024-05-25 10:44   ` H.J. Lu
@ 2024-05-25 16:07     ` Florian Weimer
  2024-05-25 16:14       ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2024-05-25 16:07 UTC (permalink / raw)
  To: H.J. Lu; +Cc: libc-alpha

* H. J. Lu:

> On Sat, May 25, 2024 at 2:54 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > 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.
>>
>> But won't there still be tons of test suite failures?
>
> I only saw
>
> FAIL: misc/tst-pidfd
> FAIL: misc/tst-pidfd_getpid
>
> with GCC 6.4.  I will check if it is a testcase issue.
>
>> Even CXX=no will not work because in some configurations, it's actually
>> libgcc_s.so.1 that can't be loaded, and that breaks pthread_cancel.
>>
>
> c++ still works.  Only "c++ -static" doesn't work with the system libc.a.

I think you'll see the issue if you go back further, to the 2.34 branch.

Thanks,
Florian


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

* Re: [PATCH] Add --enable-static-c++-link-check option [BZ #31412]
  2024-05-25 16:07     ` Florian Weimer
@ 2024-05-25 16:14       ` H.J. Lu
  2024-05-26 14:07         ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2024-05-25 16:14 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Sat, May 25, 2024 at 9:08 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Sat, May 25, 2024 at 2:54 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu:
> >>
> >> > 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.
> >>
> >> But won't there still be tons of test suite failures?
> >
> > I only saw
> >
> > FAIL: misc/tst-pidfd
> > FAIL: misc/tst-pidfd_getpid

It is a glibc bug.  I submitted a patch:

https://patchwork.sourceware.org/project/glibc/list/?series=34355

> > with GCC 6.4.  I will check if it is a testcase issue.
> >
> >> Even CXX=no will not work because in some configurations, it's actually
> >> libgcc_s.so.1 that can't be loaded, and that breaks pthread_cancel.
> >>
> >
> > c++ still works.  Only "c++ -static" doesn't work with the system libc.a.
>
> I think you'll see the issue if you go back further, to the 2.34 branch.
>

I set up LD_LIBRARY_PATH to GCC 6.4 run-time libraries and only saw

FAIL: nptl/tst-pthread-gdb-attach
FAIL: nptl/tst-pthread-gdb-attach-static

which is caused by gdb dependency on GCC 14 run-time libraries.

--disable-static-c++-link-check together with --disable-static-c++-tests
allow me to test ppc64le glibc on GCC compiler farm.

-- 
H.J.

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

* Re: [PATCH] Add --enable-static-c++-link-check option [BZ #31412]
  2024-05-25 16:14       ` H.J. Lu
@ 2024-05-26 14:07         ` Florian Weimer
  2024-05-26 14:26           ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2024-05-26 14:07 UTC (permalink / raw)
  To: H.J. Lu; +Cc: libc-alpha

* H. J. Lu:

>> > with GCC 6.4.  I will check if it is a testcase issue.
>> >
>> >> Even CXX=no will not work because in some configurations, it's actually
>> >> libgcc_s.so.1 that can't be loaded, and that breaks pthread_cancel.
>> >>
>> >
>> > c++ still works.  Only "c++ -static" doesn't work with the system libc.a.
>>
>> I think you'll see the issue if you go back further, to the 2.34 branch.
>>
>
> I set up LD_LIBRARY_PATH to GCC 6.4 run-time libraries and only saw
>
> FAIL: nptl/tst-pthread-gdb-attach
> FAIL: nptl/tst-pthread-gdb-attach-static
>
> which is caused by gdb dependency on GCC 14 run-time libraries.
>
> --disable-static-c++-link-check together with --disable-static-c++-tests
> allow me to test ppc64le glibc on GCC compiler farm.

Has this GCC 6.4 been built against system glibc?

The use case for what you are trying to do seems to be really narrow to
me.  In general, building a fresh glibc against system glibc will not
result in a GCC that is compatible with the (earlier) glibc under
development.  GCC before 12 probably has it a lot easier.

Thanks,
Florian


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

* Re: [PATCH] Add --enable-static-c++-link-check option [BZ #31412]
  2024-05-26 14:07         ` Florian Weimer
@ 2024-05-26 14:26           ` H.J. Lu
  0 siblings, 0 replies; 7+ messages in thread
From: H.J. Lu @ 2024-05-26 14:26 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Sun, May 26, 2024 at 7:08 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> >> > with GCC 6.4.  I will check if it is a testcase issue.
> >> >
> >> >> Even CXX=no will not work because in some configurations, it's actually
> >> >> libgcc_s.so.1 that can't be loaded, and that breaks pthread_cancel.
> >> >>
> >> >
> >> > c++ still works.  Only "c++ -static" doesn't work with the system libc.a.
> >>
> >> I think you'll see the issue if you go back further, to the 2.34 branch.
> >>
> >
> > I set up LD_LIBRARY_PATH to GCC 6.4 run-time libraries and only saw
> >
> > FAIL: nptl/tst-pthread-gdb-attach
> > FAIL: nptl/tst-pthread-gdb-attach-static
> >
> > which is caused by gdb dependency on GCC 14 run-time libraries.
> >
> > --disable-static-c++-link-check together with --disable-static-c++-tests
> > allow me to test ppc64le glibc on GCC compiler farm.
>
> Has this GCC 6.4 been built against system glibc?

No.  GCC 6.4 binaries were built years agao.

> The use case for what you are trying to do seems to be really narrow to
> me.  In general, building a fresh glibc against system glibc will not
> result in a GCC that is compatible with the (earlier) glibc under
> development.  GCC before 12 probably has it a lot easier.
>

I used GCC 6.4 on Fedora 40 to verify that glibc source is buildable with
GCC 6 and I discovered a glibc bug:

https://sourceware.org/bugzilla/show_bug.cgi?id=31798

-- 
H.J.

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