[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 --- Comment #12 from Andrew Pinski --- My bet it is due to --enable-version-specific-runtime-libs which does not get as tested any more.
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 Jim Wilson changed: What|Removed |Added CC||wilson at gcc dot gnu.org --- Comment #11 from Jim Wilson --- The -lstdc++ is added by lang_specific_driver in g++spec.c. g++spec.o is linked into xg++. In the function lang_specific_driver, library is set to 1 if the input file is not a header file, and then near the bottom a generate_option call adds the -lstdc++ to the command line options. You should debug lang_specific_driver to see why it isn't working.
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 --- Comment #10 from Jakub Jelinek --- (In reply to Jason Vas Dias from comment #9) > (In reply to Jakub Jelinek from comment #8) > > Where do you see -nostdlib being used? I see it neither in your #c0, nor in > > #c1. > > Looking at my buildlog, -nostdlib is used to link only some libraries, like > > libstdc++.so.6 itself, or libvtv, libsanitizer libraries, > > libcc1/libcc1plugin, libcilkrts, libgcj, libgcj_bc, libgij, libjvm, > > libgcj-tools, but certainly not when linking build/*, or gcov, or cc1, ... > > Yes, sorry, -nostdlib is not being used explicitly - but we seem to be > getting the same effect with xg++ . Only you seem to be getting that effect, for everybody else it works just fine. So the question is why it doesn't work for you.
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 --- Comment #9 from Jason Vas Dias --- (In reply to Jakub Jelinek from comment #8) > Where do you see -nostdlib being used? I see it neither in your #c0, nor in > #c1. > Looking at my buildlog, -nostdlib is used to link only some libraries, like > libstdc++.so.6 itself, or libvtv, libsanitizer libraries, > libcc1/libcc1plugin, libcilkrts, libgcj, libgcj_bc, libgij, libjvm, > libgcj-tools, but certainly not when linking build/*, or gcov, or cc1, ... Yes, sorry, -nostdlib is not being used explicitly - but we seem to be getting the same effect with xg++ . The problem is then that the stage2 xg++ is not adding -lstd++ automatically, and the scripts are not adding it to the stage2 configure's LDFLAGS - I think they should be, or the part of them that is meant to be doing this has failed to do so in my case . Any pointers as to where precisely in the build script code to look for where -lstdc++ should be being added to the stage2 build LDFLAGS , or is it that xg++ should have been adding -lstdc++ if required , but wasn't ? Some clarification on that last point would be greatly appreciated.
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 --- Comment #8 from Jakub Jelinek --- Where do you see -nostdlib being used? I see it neither in your #c0, nor in #c1. Looking at my buildlog, -nostdlib is used to link only some libraries, like libstdc++.so.6 itself, or libvtv, libsanitizer libraries, libcc1/libcc1plugin, libcilkrts, libgcj, libgcj_bc, libgij, libjvm, libgcj-tools, but certainly not when linking build/*, or gcov, or cc1, ...
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 --- Comment #7 from Jason Vas Dias --- So since I've produced a working Stage3 compiler in the build directory, './', './prev-gcc' should be the directory containing the Stage2 gcc build, and it does in my case, with a config.log : $ grep '^LDFLAGS=' prev-gcc/config.log LDFLAGS='-static-libstdc++ -static-libgcc ' Now I think that this command should produce the output : $ grep '^LDFLAGS=' prev-gcc/config.log LDFLAGS='-static-libstdc++ -static-libgcc -lstdc++' because we know that all the executables are produced with xg++ given the '-nostdlib' option, and all C++ executables should be linked against libstdc++ . My question is simply why isn't the missing '-lstdc++' there ? Next question: where is the code that is meant to be adding it somehow ?
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 --- Comment #6 from Jason Vas Dias --- Yes, Jakub, thanks, I know : > If you link with g++ or xg++ instead of gcc or xgcc, then the driver is > adding > -lstdc++ automatically. But it is not ME linking, it is the gcc-5.3.0 Makefile.in / configure.ac scripts . It seems to me on cursory inspection of these huge scripts that neither of them are explicitly adding '-lstdc' anywhere onto the link lines for xg++ links, nor to LDFLAGS or ALL_LINKERFLAGS or BUILD_LDFLAGS or any link line containing LDFLAGS , as shown by this grep in the unmodified GCC 5.3.0 source directory: [root@localhost:/usr/os_src/gcc-5.3.0 [4360] 16:23:17 #:8!:4399] $ egrep '(LINKER|LD)FLAGS' Makefile.in Makefile.def Makefile.tpl gcc/Makefile.in | egrep -i stdc\\+\\+\|stdc\[xp\]+ [root@localhost:/usr/os_src/gcc-5.3.0 $ ie. no references to 'stdc++' or stdcxx (case insensitive) in any line containing LDFLAGS or LINKER in any make script . So it is very difficult to find the exact line of code that is meant to be adding the '-lstdc++' and somehow failed to do so in my case ! Is it meant to be added to LDFLAGS during the stage2 gcc configure using xg++ as the compiler ($CC) ? A search of the huge configure.ac scripts yields no results : $ egrep '(LINKER|LD)FLAGS' configure.ac gcc/configure.ac | egrep -i stdc\\+\\+\|stdc\[xp]+ configure.ac: LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc" $ So how are the build scripts meant to be adding '-lstdc++' to the link lines of executables produced by the stage2 xg++ ? This is far from clear.
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #5 from Jakub Jelinek --- If you link with g++ or xg++ instead of gcc or xgcc, then the driver is adding -lstdc++ automatically.
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 --- Comment #4 from Jason Vas Dias --- Thanks for having a look at this, Richard . Yes, "some weirdness" is definitely going on - but I'd like to determine precisely which "weirdness". This occurred when building my new LFS system's system compiler for the first time, with a GCC-5.2.0 instance built for RHEL-6, whose installation directories were all mounted with the 'bind' option ( /usr/lib/gcc/x86_64-redhat-linux/5.2.0 , /usr/libexec/gcc/x86_64-redhat-linux/5.2.0 , etc. ) and where $PATH picked up all gcc binaries from a 'bin/' directory containing links like : gcc -> /${path_to_rhel6_usr_bin}/gcc5.2.0 ... etc. My configure options were : /usr/os_src/gcc-5.3.0/configure --prefix=/usr --libdir=/usr/lib64 --enable-shared \ --enable-languages=all \ --enable-bootstrap \ --enable-multilib \ --with-cpu-64=haswell \ --with-cpu-32=atom \ --with-arch-64=x86-64 \ --with-tune-64=haswell \ --with-arch-32=i686 \ --with-tune-32=atom \ --enable-targets=all \ --enable-threads=posix \ --enable-lto \ --enable-serial-configure \ --enable-checking=release \ --with-stage1-ldflags='-L/usr/lib64 -L/usr/local/lib64 -L/usr/lib32 -L/usr/local/lib32 -Wl,-R,/usr/lib64:/usr/local/lib64:/usr/lib32:/usr/local/lib32' \ --with-gmp=/usr --with-gmp-lib=/usr/lib64 \ --with-mpfr=/usr --with-mpfr-lib=/usr/lib64 \ --with-mpc=/usr --with-mpc-lib=/usr/lib64 \ --with-isl=/usr --with-isl-lib=/usr/lib64 \ --with-cloog=/usr --with-cloog-lib=/usr/lib64 \ --with-gnu-ld \ --with-gnu-as \ --enable-linker-build-id \ --disable-libunwind-exceptions \ --disable-nls \ --enable-version-specific-runtime-libs \ --enable-__cxa_atexit \ --without-x \ --disable-gtk-cairo \ --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre \ --enable-libgcj-multifile \ --with-ecj-jar=/usr/share/java/eclipse-ecj.jar \ --with-system-zlib \ --enable-java-home \ --with-arch-directory=x86_64 \ --disable-libjava-multilib \ --build=x86_64-pc-linux-gnu \ --host=x86_64-pc-linux-gnu I had to radically modify the ./gcc/Makefile of the build directory to add '-static-libstdc++ -lstdc++' to EVERY executable's link command , finally the 'make' completed with 0 exit status, and 'make DESTDIR=... install' created the installation directory , and the test suite passed (with some expected failures - details on request). The translated gcc/Makefile.in produced a gcc/Makefile containing : LDFLAGS = -static-libstdc++ -static-libgcc Note: no -lstdc++ - I think the '-static-libstdc++' option on its own does NOT imply '-lstdc++' - you have to add it to actually link against libstdc++.a . So that is what I did , modifying the above lines: NEEDS_STDCXX = -static-libstdc++ -lstdc++ LDFLAGS = -static-libgcc $(NEEDS_STDCXX) and I had to add this into many other places where an executable is being produced and LDFLAGS is not referenced: ... ALL_LINKERFLAGS = $(ALL_CXXFLAGS) -static-libgcc $(NEEDS_STDCXX) ... # For stage1 and when cross-compiling use the build libcpp which is # built with NLS disabled. For stage2+ use the host library and # its dependencies. ifeq ($(build_objdir),$(build_libobjdir)) BUILD_CPPLIB = $(build_libobjdir)/libcpp/libcpp.a else BUILD_CPPLIB = $(CPPLIB) $(LIBIBERTY) build/genmatch$(build_exeext): BUILD_LIBDEPS += $(LIBINTL_DEP) $(LIBICONV_DEP) build/genmatch$(build_exeext): BUILD_LIBS += $(LIBINTL) $(LIBICONV) $(NEEDS_STDCXX) endif ... I suggest making the gcc/Makefile.in / $TOPDIR/{configure.ac,Makefile.am} add '-lstdc++' every time it writes '-static-libstdc++' to the Makefile , eg. $TOPDIR/configure.ac @ line 1376: # Check whether -static-libstdc++ -static-libgcc is supported. have_static_libs=no if test "$GCC" = yes; then saved_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc" # ^- add ' -lstdc++' here @ line 1718: [stage1_ldflags= # In stage 1, default to linking libstdc++ and libgcc statically with GCC # if supported. But if the user explicitly specified the libraries to use, # trust that they are doing what they want. if test "$stage1_libs" = "" -a "$have_static_libs" = yes; then stage1_ldflags="-static-libstdc++ -static-libgcc" # ^- add ' -lstdc++' here fi]) @ line 1741: [poststage1_ldflags= # In stages 2 and 3, default to linking libstdc++ and libgcc # statically. But if the user explicitly specified the libraries to # use, trust that they are doing what they want. if test "$poststage1_libs" = ""; then poststage1_ldflags="-static-libstdc++ -static-libgcc" # ^- add ' -lstdc++' here fi]) I can't put my finger on the component that is meant to add '-lstdc++' to the poststage1_ldflags if not above modified lines ATM - what is meant to be doing this ? I will try building with the configure.ac so modified
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 --- Comment #3 from Richard Biener --- xg++ from stage1 should already add -lstdc++. Sth else weird is going on for you.
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 --- Comment #2 from Jason Vas Dias --- In fact, it happens for EVERY executable produced by stage2 compiler! Why is this - do I need to add '-lstdc++' to LDFLAGS or to --with-stage1-ldflags / --with-boot-ldflags in order to build gcc-5.3.0 ?
[Bug bootstrap/70519] genmatch fails to compile under gcc-5.2.0 - missing '-lstdc++' .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70519 --- Comment #1 from Jason Vas Dias --- And it happens for gcov also: /usr/build/linux/gcc-5.3.0/./prev-gcc/xg++ -B/usr/build/linux/gcc-5.3.0/./prev-gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -I/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/include -I/usr/os_src/gcc-5.3.0/libstdc++-v3/libsupc++ -L/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -g -O2 -gtoggle -DIN_GCC-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc gcov.o libcommon.a ../libcpp/libcpp.a ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -o gcov libcommon.a(pretty-print.o): In function `pretty_printer::~pretty_printer()': pretty-print.c:(.text+0x1ce): undefined reference to `operator delete(void*)' libcommon.a(input.o): In function `diagnostic_file_cache_init() [clone .part.5]': input.c:(.text+0x1da): undefined reference to `operator new[](unsigned long)' libcommon.a(input.o): In function `diagnostic_file_cache_fini()': input.c:(.text+0x88d): undefined reference to `operator delete[](void*)' collect2: error: ld returned 1 exit status Makefile:2673: recipe for target 'gcov' failed make[3]: *** [gcov] Error 1 make[3]: *** Waiting for unfinished jobs make[3]: Leaving directory '/usr/build/linux/gcc-5.3.0/gcc' Makefile:4411: recipe for target 'all-stage2-gcc' failed make[2]: *** [all-stage2-gcc] Error 2 make[2]: Leaving directory '/usr/build/linux/gcc-5.3.0' Makefile:21905: recipe for target 'stage2-bubble' failed make[1]: *** [stage2-bubble] Error 2 make[1]: Leaving directory '/usr/build/linux/gcc-5.3.0' Makefile:902: recipe for target 'all' failed make: *** [all] Error 2 [root@[Linux]:/usr/build/linux/gcc-5.3.0 [5067] 14:07:38 #:111!:1990] $ cd gcc [root@[Linux]:/usr/build/linux/gcc-5.3.0/gcc [5067] 14:08:10 #:112!:1991] $ /usr/build/linux/gcc-5.3.0/./prev-gcc/xg++ -B/usr/build/linux/gcc-5.3.0/./prev-gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -I/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/include -I/usr/os_src/gcc-5.3.0/libstdc++-v3/libsupc++ -L/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -g -O2 -gtoggle -DIN_GCC-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc gcov.o libcommon.a ../libcpp/libcpp.a ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -o gcov libcommon.a(pretty-print.o): In function `pretty_printer::~pretty_printer()': pretty-print.c:(.text+0x1ce): undefined reference to `operator delete(void*)' libcommon.a(input.o): In function `diagnostic_file_cache_init() [clone .part.5]': input.c:(.text+0x1da): undefined reference to `operator new[](unsigned long)' libcommon.a(input.o): In function `diagnostic_file_cache_fini()': input.c:(.text+0x88d): undefined reference to `operator delete[](void*)' collect2: error: ld returned 1 exit status [root@[Linux]:/usr/build/linux/gcc-5.3.0/gcc [5067] 14:08:21 #:113!:1992] $ /usr/build/linux/gcc-5.3.0/./prev-gcc/xg++ -B/usr/build/linux/gcc-5.3.0/./prev-gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -I/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/include -I/usr/os_src/gcc-5.3.0/libstdc++-v3/libsupc++ -L/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/usr/build/linux/gcc-5.3.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -g -O2 -gtoggle -DIN_GCC-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic