Configure failure with gmp-5.0.4 due to ignored $LDFLAGS in compiler probe

gmp.8eaf7cd8e5128d8191fe at gmp.8eaf7cd8e5128d8191fe at
Mon Apr 2 00:53:11 CEST 2012

Using gmp-5.0.4, I encountered a configure failure stating "could not
find a working compiler" (and after fixing that, "C++ compiler not
available").  After inspecting config.log, I determined that the problem
is that the test for a working compiler assumes that LDFLAGS are
optional for producing an output file.  On my test system, if $LDFLAGS
are not passed, then the link will fail.  The below sed expression
allows the build to complete successfully.

	sed -i \
		-e 's|\$cc \$cflags |&$LDFLAGS |' \
		-e 's|\$CXX \$CPPFLAGS |&$LDFLAGS |' \
		-e 's|"\$CC \$CFLAGS |&$LDFLAGS |' \ acinclude.m4

Some of the changes it introduces are on lines where $LDFLAGS are not
used, but this does not harm the build.  I think the only critical hunk
in acinclude.m4 is around line 3683.

With regard to the items standard in any report:
- gmp-5.0.4
- No test program, since this is a build system problem.
- No crash, since the library failed to build without the changes, but
   worked with the changes.
- configure options:
   --prefix=/usr --enable-cxx --disable-static
- gcc version 4.5.3 (Gentoo Hardened 4.5.3-r2 p1.1, pie-0.4.7)
- x86_64-pc-linux-gnu

I no longer have the config.log, but I can revert the fix and generate a
new one if you feel that is necessary.  The error in config.log
indicated that the compiler failed to find  Since is
not in my binutils default search path, any link that fails to use my
$LDFLAGS (where I have -L/path/to/libc) will fail in this way.

More information about the gmp-bugs mailing list