[PATCH] Don't use TEST_CXX as CXX for build
H.J. Lu
hjl.tools@gmail.com
Sun Dec 15 07:28:16 GMT 2024
On Sun, Dec 15, 2024 at 2:49 PM Sam James <sam@gentoo.org> wrote:
>
> Sam James <sam@gentoo.org> writes:
>
> > "H.J. Lu" <hjl.tools@gmail.com> writes:
> >
> >> On Sun, Dec 15, 2024 at 11:15 AM Sam James <sam@gentoo.org> wrote:
> >>>
> >>> "H.J. Lu" <hjl.tools@gmail.com> writes:
> >>>
> >>> > Since the C++ compiler is also used to compile links-dso-program.cc in
> >>> > libsupport, use TEST_CXX to get C++ headers for testing, but don't use
> >>> > TEST_CXX as CXX for build.
> >>> >
> >>> > Tested for m68k-linux-gnu-coldfire build and native build on x86-64.
> >>> >
> >>> > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> >>> > ---
> >>> > configure | 9 +++++++--
> >>> > configure.ac | 9 +++++++--
> >>> > 2 files changed, 14 insertions(+), 4 deletions(-)
> >>> >
> >>> > diff --git a/configure b/configure
> >>> > index 37877d5b97..2c2b19f9a6 100755
> >>> > --- a/configure
> >>> > +++ b/configure
> >>> > @@ -3910,7 +3910,7 @@ esac
> >>> > fi
> >>> >
> >>> >
> >>> > -# We need the C++ compiler only for testing.
> >>> > +# We need the C++ compiler for testing and libsupport.
> >>> >
> >>> >
> >>> >
> >>> > @@ -4300,6 +4300,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
> >>> > ac_compiler_gnu=$ac_cv_c_compiler_gnu
> >>> >
> >>> >
> >>> > +saved_CXX="$CXX"
> >>> > if test -z "$TEST_CXX"; then
> >>> > TEST_CXX="$CXX"
> >>> > else
> >>> > @@ -4378,6 +4379,7 @@ esac
> >>> > fi
> >>> > { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cxx_link_ok" >&5
> >>> > printf "%s\n" "$libc_cv_cxx_link_ok" >&6; }
> >>> > +CXX="$saved_CXX"
> >>> > if test $libc_cv_cxx_link_ok != yes
> >>> > then :
> >>> > CXX=; TEST_CXX=
> >>> > @@ -6535,7 +6537,9 @@ fi
> >>> >
> >>> > # Obtain some C++ header file paths. This is used to make a local
> >>> > # copy of those headers in Makerules.
> >>> > -if test -n "$CXX"; then
> >>> > +if test -n "$TEST_CXX"; then
> >>> > + saved_CXX="$CXX"
> >>> > + CXX="$TEST_CXX"
> >>> > find_cxx_header () {
> >>> > echo "#include <$1>" | $CXX -H -fsyntax-only -x c++ - 2>&1 \
> >>> > | $AWK '$1 == "."{print $2}'
> >>> > @@ -6543,6 +6547,7 @@ if test -n "$CXX"; then
> >>> > CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
> >>> > CXX_CMATH_HEADER="$(find_cxx_header cmath)"
> >>> > CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
> >>> > + CXX="$saved_CXX"
> >>> > fi
> >>> >
> >>> >
> >>> > diff --git a/configure.ac b/configure.ac
> >>> > index dca8991fbf..1de79bd729 100644
> >>> > --- a/configure.ac
> >>> > +++ b/configure.ac
> >>> > @@ -73,10 +73,11 @@ AC_ARG_ENABLE([static-c++-link-check],
> >>> > [static_cxx_link_check=$enableval],
> >>> > [static_cxx_link_check=yes])
> >>> >
> >>> > -# We need the C++ compiler only for testing.
> >>> > +# We need the C++ compiler for testing and libsupport.
> >>> > AC_PROG_CXX
> >>> > AC_ARG_VAR([TEST_CXX],
> >>> > [C++ compiler for testing])
> >>> > +saved_CXX="$CXX"
> >>> > if test -z "$TEST_CXX"; then
> >>> > TEST_CXX="$CXX"
> >>> > else
> >>> > @@ -108,6 +109,7 @@ main()
> >>> > LDFLAGS="$old_LDFLAGS"
> >>> > fi
> >>> > AC_LANG_POP([C++])])
> >>> > +CXX="$saved_CXX"
> >>> > AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=; TEST_CXX=])
> >>> >
> >>> > if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
> >>> > @@ -1077,7 +1079,9 @@ AC_SUBST(CXX_SYSINCLUDES)
> >>> >
> >>> > # Obtain some C++ header file paths. This is used to make a local
> >>> > # copy of those headers in Makerules.
> >>> > -if test -n "$CXX"; then
> >>> > +if test -n "$TEST_CXX"; then
> >>> > + saved_CXX="$CXX"
> >>> > + CXX="$TEST_CXX"
> >>> > find_cxx_header () {
> >>> > echo "#include <$1>" | $CXX -H -fsyntax-only -x c++ - 2>&1 \
> >>> > | $AWK '$1 == "."{print $2}'
> >>> > @@ -1085,6 +1089,7 @@ if test -n "$CXX"; then
> >>> > CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
> >>> > CXX_CMATH_HEADER="$(find_cxx_header cmath)"
> >>> > CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
> >>> > + CXX="$saved_CXX"
> >>> > fi
> >>> > AC_SUBST(CXX_CSTDLIB_HEADER)
> >>> > AC_SUBST(CXX_CMATH_HEADER)
> >>>
> >>> Looks like
> >>> https://inbox.sourceware.org/libc-testresults/173422834592.2674304.8851778744134595286@tor.usersys.redhat.com/
> >>> failed again which is probably related to this.
> >>
> >> I can't reproduce it:
> >>
> >> PASS: compilers-m68k-linux-gnu-coldfire gcc build
> >>
> >> Sam, can you reproduce it?
> >
> > Trying.
> >
> > I couldn't get build-many-glibcs.py to work fully yet (needs some
> > adaptation for Gentoo), but:
> >
> > $ src/glibc/configure '--prefix=/usr' --enable-profile
> > '--build=x86_64-pc-linux-gnu' '--host=m68k-glibc-linux-gnu'
> > 'CC=m68k-glibc-linux-gnu-gcc' CXX=m68k-glibc-linux-gnu-g++
> > [...]
> > make[2]: Leaving directory '/home/sam/git/glibc/support'
> > make[2]: Entering directory '/home/sam/git/glibc/support'
> > m68k-glibc-linux-gnu-gcc
> > -Wl,-rpath-link=/tmp:/tmp/math:/tmp/elf:/tmp/dlfcn:/tmp/nss:/tmp/nis:/tmp/rt:/tmp/resolv:/tmp/mathvec:/tmp/support:/tmp/nptl
> > -o /tmp/support/links-dso-program -pie -Wl,-O1 -nostdlib -nostartfiles
> > -Wl,-z,relro /tmp/csu/Scrt1.o /tmp/csu/crti.o
> > `m68k-glibc-linux-gnu-gcc --print-file-name=crtbeginS.o`
> > /tmp/support/links-dso-program.o -lstdc++-lgcc -lgcc_s
> > -Wl,-dynamic-linker=/lib/ld.so.1 /tmp/libc.so.6 /tmp/libc_nonshared.a
> > -Wl,--as-needed /tmp/elf/ld.so -Wl,--no-as-needed -lgcc
> > `m68k-glibc-linux-gnu-gcc --print-file-name=crtendS.o` /tmp/csu/crtn.o
> > /tmp/support/links-dso-program.o: file not recognized: file format not recognized
> > collect2: error: ld returned 1 exit status
> > make[2]: *** [../Rules:238: /tmp/support/links-dso-program] Error 1
> > make[2]: Leaving directory '/home/sam/git/glibc/support'
> > make[1]: *** [Makefile:484: support/others] Error 2
> > make: *** [Makefile:21: all] Error 2
> >
> > $ grep -rsin CXX=
> > Makefile:25: CC="$(TEST_CC)" CXX="$(TEST_CXX)" \
> > config.log:812:ac_cv_prog_ac_ct_CXX='g++'
> > config.log:901:CXX='g++'
> > config.log:951:TEST_CXX='g++'
> > config.log:954:ac_ct_CXX='g++'
> >
> > If I build with explicit non-existent CXX, it is OK:
> > $ src/configure --prefix=/usr --enable-profile --build=x86_64-pc-linux-gnu
> > --host=m68k-glibc-linux-gnu CC=m68k-glibc-linux-gnu-gcc CXX=m68k-glibc-linux-gnu-g++
> > # fine
> >
> > But reverting your commit from today for TEST_CXX doesn't fix it, even
> > though I thought we saw green results from Joseph with that previous
> > state.
> >
> > Looking more.
>
> So far, it doesn't make sense: even using glibc-2.40 with my
> configuration, it fails when linking unless I specify CXX=m68k-glibc-linux-gnu-g++
> (which doesn't exist), as it uses CBUILD CXX=g++.
>
> The check doesn't work even before, because if no CHOST CXX exists, it
> should leave it empty, not pick a CBUILD one.
>
> So why is it failing now for Joseph?
>
> Can you show me your config.log for successful m68k-linux-gnu-coldfire?
> build-many-glibcs.py doesn't pass CXX= here so it fails. Maybe it's
> supposed to and does for you.
Here are my config.log and config.make.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config.log
Type: text/x-log
Size: 44390 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20241215/14fafbd1/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config.make
Type: application/octet-stream
Size: 4816 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20241215/14fafbd1/attachment-0001.obj>
More information about the Libc-alpha
mailing list