Compiler ANSI check in configure breaks using Clang

Andrew Jeffery andrew at
Fri Dec 11 02:09:48 CET 2009


Purely out of interest I've been exploring using Clang[1] as my system 
compiler. Running Gentoo, I figured I could give it a fairly good 
thrashing by trying to emerge a complete system and report any bugs I 
found. One of these is in libgmp.


* GMP Version:
	4.3.1, unpatched
* Clang Version:
	clang version 1.0 
( exported)
	Target: x86_64-pc-linux-gnu
	Thread model: posix
* uname -a:
	Linux amaya 2.6.32-gentoo #1 SMP Mon Dec 7 16:34:32 CST 2009 x86_64 
Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz GenuineIntel GNU/Linux
* ./config.guess:
* ./configfsf.guess:

The bug revolves around `CC=/usr/bin/clang ./configure`. The check 
GMP_C_FOR_BUILD_ANSI ("checking whether build system compiler is 
ANSI...") fails, due to what seems to be an issue with the main function 
signature. The configure script attempts to compile:

   cat >conftest.c <<EOF
main (int argc, char *argv)

for the test. This code fails when compiled with clang:

$ clang conftest.c
conftest.c:2:1: error: second argument of 'main' should be of type 'char **'
main (int argc, char *argv)
conftest.c:4:3: warning: implicitly declaring C library function 'exit' 
with type 'void (int)'
conftest.c:4:3: note: please include the header <stdlib.h> or explicitly 
provide a declaration for 'exit'
3 diagnostics generated.

It seems clang is stricter on this than GCC, though I can't see why the 
code contained in the configure script would be correct.

I've attached the compressed config.log as well as a patch to fix the 
function declaration.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: config.log.tar.bz2
Type: application/x-bzip
Size: 17634 bytes
Desc: not available
URL: <>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fix-bad-ansi-check.patch
URL: <>

More information about the gmp-bugs mailing list