gmp.h needs to detect bit width more dynamically to support universal builds on mac

Niels Möller nisse at
Tue Dec 3 13:04:59 UTC 2013

Dan Kegel <dank at> writes:

> The fix is easy.  Here's a patch that should Do The Right Thing, and
> be completely safe for upstream:

I'm pretty sure it totally breaks builds with --enable-nails, a feature
currently not enabled by default, but which we'd like to be able to play

I think a better way is to have in something like

#define GMP_LIMB_BITS                      @GMP_ALT_LIMB_BITS@
#define GMP_NAIL_BITS                      @GMP_ALT_NAIL_BITS@
#define GMP_LIMB_BITS                      @GMP_LIMB_BITS@
#define GMP_NAIL_BITS                      @GMP_NAIL_BITS@

where configure defines a non-zero GMP_USE_ALT_SIZES only for configurations where
multiple ABI:s with different limb sizes are available. Maybe some other
values, e.g., LONGLONG_LIMB, also needs alternative values.

In your case, you'd have configure define

  GMP_USE_ALT_SIZES __x86_64__

It's a known problem, and solving it is not beneficial just for MacOS.
E.g., it would be nice to be able to install both 32-bit and 64-bit gmp
in parallel on, e.g., gnu/linux x86_64, with libraries in different
directories, say /usr/lib and /use/lib32, but sharing the same
$prefix/include/gmp.h. In this case, it would be nice to automagically
chose default $libdir depending on the ABI (I try do that in Nettle's
configure script, see,
but it's a bit messy).


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-bugs mailing list