Since the latest libtool update in GCC, I've had problems building libstdc++-v3 on x86_64-linux-gnu. The symptom was an incomplete link command line, resulting from a trailing «'» character in a -L flag added by libtool.
It turned out to be improperly auto-detected from the gcc -shared -v output. The issue is that, after zero or perhaps more reconfigurations of the gcc top-level, the arguments passed to the gcc configure, and that are reported by gcc -v in the build tree, look like this: Configured with: ../configure --cache-file=./config.cache -C --prefix=/l/tmp/build/toolchains/x86_64-linux-gnu --enable-checking --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt-but=gtk --disable-dssi --enable-plugin-but --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --disable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic CC='ccache gcc -fno-working-directory -m64' CXX='ccache g++ -fno-working-directory -m64' CCC='ccache g++ -fno-working-directory -m64' target_alias=x86_64-unknown-linux-gnu CFLAGS='-g -O2' LDFLAGS= CXXFLAGS='-g -O2' 'CC_FOR_TARGET=distccrel /l/tmp/build/gcc/trunk/obj-x86_64-linux-gnu/./gcc/xgcc -B/l/tmp/build/gcc/trunk/obj-x86_64-linux-gnu/./gcc/' 'CXX_FOR_TARGET=distccrel /l/tmp/build/gcc/trunk/obj-x86_64-linux-gnu/./gcc/g++ -B/l/tmp/build/gcc/trunk/obj-x86_64-linux-gnu/./gcc/ -nostdinc++ -L/l/tmp/build/gcc/trunk/obj-x86_64-linux-gnu/x86_64-unknown-linux-gnu/libstdc++-v3/src -L/l/tmp/build/gcc/trunk/obj-x86_64-linux-gnu/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs' 'GCJ_FOR_TARGET=distccrel /l/tmp/build/gcc/trunk/obj-x86_64-linux-gnu/./gcc/gcj -B/l/tmp/build/gcc/trunk/obj-x86_64-linux-gnu/./gcc/' 'GFORTRAN_FOR_TARGET=distccrel /l/tmp/build/gcc/trunk/obj-x86_64-linux-gnu/./gcc/gfortran -B/l/tmp/build/gcc/trunk/obj-x86_64-linux-gnu/./gcc/' AR_FOR_TARGET=ar AS_FOR_TARGET=as DLLTOOL_FOR_TARGET=dlltool LD_FOR_TARGET=ld LIPO_FOR_TARGET=lipo NM_FOR_TARGET=nm OBJDUMP_FOR_TARGET=objdump RANLIB_FOR_TARGET=ranlib STRIP_FOR_TARGET=strip WINDRES_FOR_TARGET=windres WINDMC_FOR_TARGET=windmc --enable-languages=c,ada,c++,fortran,java,objc --no-create --no-recursion The attentive reader will notice the -L flag at the end of CXX_FOR_TARGET. libtool.m4 is not clever enough to realize that the trailing «'» is just closing the one before CXX_FOR_TARGET, and to disregard the whole thing, so it takes the argument at face value, with a trailing apostrophe and all. That doesn't quite work. The fix I came up with was to avoid lines that didn't contain the information libtool was interested in. It turns out that only lines started with blanks contain the actual commands line that GCC runs, so I narrowed the grep for -L flags to such lines. Here's what I'm going to installing in the GCC tree momentarily. I suggest libtool to adopt something along the same lines.
for ChangeLog from Alexandre Oliva <aol...@redhat.com> * libtool.m4 (output_verbose_link_cmd): Require leading blank, and blank before -L. for gcc/ChangeLog from Alexandre Oliva <aol...@redhat.com> * configure: Rebuilt with modified libtool.m4. for libstdc++-v3/ChangeLog from Alexandre Oliva <aol...@redhat.com> * configure: Rebuilt with modified libtool.m4. for boehm-gc/ChangeLog from Alexandre Oliva <aol...@redhat.com> * configure: Rebuilt with modified libtool.m4. for libjava/ChangeLog from Alexandre Oliva <aol...@redhat.com> * configure: Rebuilt with modified libtool.m4. Index: libtool.m4 =================================================================== --- libtool.m4.orig 2009-09-07 04:31:45.000000000 -0300 +++ libtool.m4 2009-09-07 04:33:09.000000000 -0300 @@ -5471,7 +5471,7 @@ if test "$_lt_caught_CXX_error" != yes; # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else GXX=no @@ -5716,7 +5716,7 @@ if test "$_lt_caught_CXX_error" != yes; # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "^ .* -L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -5781,7 +5781,7 @@ if test "$_lt_caught_CXX_error" != yes; # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "^ .* -L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -6125,7 +6125,7 @@ if test "$_lt_caught_CXX_error" != yes; # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else # FIXME: insert proper C++ library support @@ -6209,7 +6209,7 @@ if test "$_lt_caught_CXX_error" != yes; # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. @@ -6220,7 +6220,7 @@ if test "$_lt_caught_CXX_error" != yes; # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' Index: libstdc++-v3/configure =================================================================== --- libstdc++-v3/configure.orig 2009-09-07 04:31:58.000000000 -0300 +++ libstdc++-v3/configure 2009-09-07 04:36:45.000000000 -0300 @@ -12336,7 +12336,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else GXX=no @@ -12673,7 +12673,7 @@ if test -z "$aix_libpath"; then aix_libp # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "^ .* -L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -12738,7 +12738,7 @@ if test -z "$aix_libpath"; then aix_libp # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "^ .* -L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -13082,7 +13082,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else # FIXME: insert proper C++ library support @@ -13166,7 +13166,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. @@ -13177,7 +13177,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' fi hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' Index: boehm-gc/configure =================================================================== --- boehm-gc/configure.orig 2009-09-07 04:33:13.000000000 -0300 +++ boehm-gc/configure 2009-09-07 04:36:20.000000000 -0300 @@ -12407,7 +12407,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else GXX=no @@ -12744,7 +12744,7 @@ if test -z "$aix_libpath"; then aix_libp # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "^ .* -L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -12809,7 +12809,7 @@ if test -z "$aix_libpath"; then aix_libp # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "^ .* -L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -13153,7 +13153,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else # FIXME: insert proper C++ library support @@ -13237,7 +13237,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. @@ -13248,7 +13248,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' fi hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' Index: gcc/configure =================================================================== --- gcc/configure.orig 2009-09-07 04:33:14.000000000 -0300 +++ gcc/configure 2009-09-07 04:36:23.000000000 -0300 @@ -17403,7 +17403,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else GXX=no @@ -17734,7 +17734,7 @@ if test -z "$aix_libpath"; then aix_libp # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "^ .* -L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -17799,7 +17799,7 @@ if test -z "$aix_libpath"; then aix_libp # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "^ .* -L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -18143,7 +18143,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else # FIXME: insert proper C++ library support @@ -18227,7 +18227,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. @@ -18238,7 +18238,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' fi hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' Index: libjava/configure =================================================================== --- libjava/configure.orig 2009-09-07 04:33:17.000000000 -0300 +++ libjava/configure 2009-09-07 04:36:25.000000000 -0300 @@ -14080,7 +14080,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else GXX=no @@ -14417,7 +14417,7 @@ if test -z "$aix_libpath"; then aix_libp # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "^ .* -L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -14482,7 +14482,7 @@ if test -z "$aix_libpath"; then aix_libp # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "^ .* -L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -14826,7 +14826,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else # FIXME: insert proper C++ library support @@ -14910,7 +14910,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. @@ -14921,7 +14921,7 @@ if test -z "$aix_libpath"; then aix_libp # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "^ .* -L"' fi hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
-- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist Red Hat Brazil Compiler Engineer