Use of the __GMP_CC and __GMP_CFLAGS macros

Marc Glisse marc.glisse at
Fri Oct 5 13:54:12 CEST 2012

On Mon, 24 Sep 2012, Vincent Lefevre wrote:

> The __GMP_CC and __GMP_CFLAGS macros were introduced in gmp.h so that
> the GMP user (in particular, MPFR) doesn't have to guess which ABI GMP
> chose (and how to use it) when it was built and installed, in case GMP
> didn't select the default ABI. You can read the full discussion here:
> The problem is that distributions (like Debian) could have built GMP
> under a particular environment and provide packages with a gmp.h using
> __GMP_CC and __GMP_CFLAGS values from this environment, which may not
> match what is expected on the end user machine. The differences could
> be, e.g.:
>  * a compiler that isn't necessarily installed or have a unusual name
>    (for instance, Debian uses x86_64-linux-gnu-gcc);

And x86_64-linux-gnu-gcc is installed with the gcc package, it isn't very 
hard to find. If you use a different toolchain, of course you can't 
blindly reuse options from another toolchain.

>  * suboptimal compiler options (for instance, Debian uses -O3 without
>    architecture information, which may generate code slower than with
>    -O2, at least this happened in the past).

Preference for -O2 is a matter of taste. It it was changed to -O2, I could 
complain that it is suboptimal and should be -O3, which for a number of 
applications does produce faster code than -O2.

Lack of architecture information: the gmp package was compiled to work on 
generic machines, it seems natural to keep compiling for a generic target. 
If you want machine-specific options, you are the one doing something 
special, and you can either add them yourself or recompile gmp 
specifically for your machine.

I can see why you don't find the flags useful on debian, removing them 
wouldn't hurt at all, and having no flags would actually be a more 
important bit of information, but being rude as early as your 3rd message 
to a good maintainer is definitely not the way to go.

Now we can discuss removing these lines as a possible enhancement. It 
could be as easy as adding a couple lines to the doc: "Distributors who 
provide GMP packages for the default architecture of their platform, with 
only generic optimization options, are advised to remove those 2 lines 
which would provide no useful information and could mislead users". We 
could even add a configure option --disable-compile-flags-in-gmp-h to 

Would that be ok with everyone? Vincent, do you want to provide the patch?

Marc Glisse

More information about the gmp-discuss mailing list