Subject: bug#18947: unexpected EOF while looking for matching

From: Peter Rosin <[email-masked]>
Date: Wed, 05 Nov 2014 09:07:22 +0100

Hi!

Thanks for the report!

On 2014-11-04 14:27, Theuns Heydenrych wrote:
> HI 
> When building Geos 3.4.2 with MinGW on Win7, the build fails at the last step when trying to link the dll, with the following.
> 
> libtool: link: g++ -shared -nostdlib c:/Tools/MinGW/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/lib/../lib/dllcrt2.o c:/Tools/MinGW/bin/../lib/gcc/i686-w64-mingw32/4.9.1/crtbegin.o  .libs/inlines.o  -Wl,--whole-archive algorithm/.libs/libalgorithm.a geom/.libs/libgeom.a geomgraph/.libs/libgeomgraph.a index/.libs/libindex.a io/.libs/libio.a linearref/.libs/liblinearref.a noding/.libs/libnoding.a operation/.libs/liboperation.a planargraph/.libs/libplanargraph.a precision/.libs/libprecision.a simplify/.libs/libsimplify.a triangulate/.libs/libtriangulate.a util/.libs/libutil.a -Wl,--no-whole-archive  -L/c/mingw491/i686-491-posix-dwarf-rt_v3-rev0/mingw32/opt/lib -L/c/mingw491/prerequisites/i686-zlib-static/lib -L/c/mingw491/prerequisites/i686-w64-mingw32-static/lib' -Lc:/Tools/MinGW/bin/../lib/gcc/i686-w64-mingw32/4.9.1 -Lc:/Tools/MinGW/bin/../lib/gcc -Lc:/Tools/MinGW/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/lib/../lib
> -Lc:/Tools/MinGW/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../lib -Lc:/Tools/MinGW/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/lib -Lc:/Tools/MinGW/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../.. -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/Tools/MinGW/bin/../lib/gcc/i686-w64-mingw32/4.9.1/crtend.o    -o .libs/libgeos-3-4-2.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libgeos.dll.a
> 
> ../libtool: eval: line 7867: unexpected EOF while looking for matching `''
> ../libtool: eval: line 7868: syntax error: unexpected end of file
> make[3]: *** [libgeos.la <http://libgeos.la/>] Error 1
> make[3]: Leaving directory `/c/cpp/dev/LibsExternal_/Gis/geos/geos-3.4.2/src'
> make[2]: *** [all-recursive] Error 1
> make[2]: Leaving directory `/c/cpp/dev/LibsExternal_/Gis/geos/geos-3.4.2/src'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/c/cpp/dev/LibsExternal_/Gis/geos/geos-3.4.2'
> make: *** [all] Error 2
> 
> What i have figured out so far is to list the default search path for gcc in MinGW is to issue the command
> gcc -### -o foo foo.c
> 
> This will produce the following:
> $ gcc -### -o foo foo.c > /c/dev/gcc.txt
> gcc.exe: error: foo.c: No such file or directory
> Using built-in specs.
> COLLECT_GCC=c:\Tools\MinGW\bin\gcc.exe
> COLLECT_LTO_WRAPPER=c:/Tools/MinGW/bin/../libexec/gcc/i686-w64-mingw32/4.9.1/lto-wrapper.exe
> Target: i686-w64-mingw32
> Configured with: ../../../src/gcc-4.9.1/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw491/i686-491-posix-dwarf-rt_v3-rev0/mingw32 
> --with-gxx-include-dir=/mingw32/i686-w64-mingw32/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=ada,c,c++,fortran,objc,obj-c++,lto --enable-libstdcxx-time=yes --enable-threads=posix 
> --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-sjlj-exceptions --with-dwarf2 
> --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror 
> --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/c/mingw491/prerequisites/i686-w64-mingw32-static 
> --with-mpfr=/c/mingw491/prerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw491/prerequisites/i686-w64-mingw32-static --with-isl=/c/mingw491/prerequisites/i686-w64-mingw32-static 
> --with-cloog=/c/mingw491/prerequisites/i686-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='i686-posix-dwarf-rev0, 
> Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 
> CFLAGS='-O2 -pipe -I/c/mingw491/i686-491-posix-dwarf-rt_v3-rev0/mingw32/opt/include -I/c/mingw491/prerequisites/i686-zlib-static/include -I/c/mingw491/prerequisites/i686-w64-mingw32-static/include' 
> CXXFLAGS='-O2 -pipe -I/c/mingw491/i686-491-posix-dwarf-rt_v3-rev0/mingw32/opt/include -I/c/mingw491/prerequisites/i686-zlib-static/include -I/c/mingw491/prerequisites/i686-w64-mingw32-static/include' 
> CPPFLAGS= LDFLAGS='-pipe -L/c/mingw491/i686-491-posix-dwarf-rt_v3-rev0/mingw32/opt/lib -L/c/mingw491/prerequisites/i686-zlib-static/lib -L/c/mingw491/prerequisites/i686-w64-mingw32-static/lib'
> Thread model: posix
> gcc version 4.9.1 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)
> 
> So there right at the end is the "offending" path, some script that should extract the -L paths, is bringing the ' character in, at the end of the line.
> 
> I am not sure if it is the libtool's configure scripts, but somewhere in the configure scripts, the ' (single quote character) should not be part of the library path.

I think this is a bug caused by libtools desire to dig out "predeps" and
"postdeps" in order to then be able to link with -nostdlib. Libtool tries
to find out the pre- and postdeps by linking a shared library with -v and
analyzing the output. I suspect that the -v output matches what you quoted
above (the -### output), and if that's the case, the -v output analyzer
code will fail. Basically, libtool looks for all -R, -L and -l options in
all lines which do not start with "Configured with:". Your MinGW-W64
compiler seems to have some extra lines starting with CFLAGS, CXXFLAGS and
CPPFLAGS which should also be excluded from the hunt.

I don't know if that is something the MinGW-W64 team can change, or if it
is some property of newer GCC, but if my analysis is correct, many projects
are b0rked.

I have no time to look further, sorry...

Cheers,
Peter