different "gmp.h" for 32 and 64-bit ABIs - why ? - simple to fix

Jason Vas Dias jason.vas.dias at gmail.com
Sat Mar 10 13:39:30 CET 2012

Good day GMP developers - first, thanks for the excellent gmplib!

Just one niggle though - to support both 64-bit and 32-bit
installations of gmplib 5.0.4 on
my Linux x86_64 host ,  I have to either use separate /usr/include and
directories (not a nice option) or a gmp.h wrapper that conditionally
includes gmp_64.h
or gmp_32.h,  or edit gmp.h to conditionally define GMP_LIMB_BITS .

This is still a problem with gmp-5.0.4 - and is the only problem I
have found with GMP on my linux x86_64 host -
All "make check" tests pass for both x86 (ABI==32) and x86_64 (ABI==64)
builds, and the "GMP_LIMB_BITS" #define is the ONLY /usr/include/gmp*.h
header file difference.

This breaks builds of software that depends on gmp - eg. building
the Parma Polyhedra Library (ppl-0.11) fails for 64-bit if the 32-bit
gmp.h is installed, and for 32-bit if the 64-bit gmp.h is installed.

IMHO,  the upstream gmp library source should not be depending on
distribution maintainers fixing this problem in order to support multi-arch /
multi-lib platforms, as for instance Thomas Woerner<twoerner at redhat.com>
does for Redhat distros by supplying a wrapper gmp.h (see attached
gmp-wrapper.h) ,
which replaces /usr/include/gmp.h with a file that conditionally
includes "gmp-<arch>.h" ,
which is the gmp.h produced by the GMP build .

If it really is true that GMP_LIMB_BITS will be the ONLY difference on
ALL multi-lib
platforms, then something like this must be done :

 1. modify the mpn/$arch/gmp-mparam.h for multi-arch platforms
(platforms that support
   conditional 32-bit or 64-bit compilation) to define both

 2. modify gmp-h.in @ line 33 :

  #ifdef    _LP64

   I think you can trust the _LP64 cpp pre-defined macro on all
multi-lib platforms
   as they are part of the standard UNIX ABI specifications.

OR ship 'gmp.h' as 'gmp-{32,64}.h' and make 'gmp.h' do:

Otherwise if there are going to be other differences in gmp.h on other
multi-arch platforms
then an approach such as Thomas' should be used.

Please can the GMP developers indicate whether they intend to fix this
problem or not .

Thanks & Regards,
Jason Vas Dias <jason.vas.dias at gmail.org> a software engineer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gmp-wrapper.h
Type: text/x-chdr
Size: 2135 bytes
Desc: not available
URL: <http://gmplib.org/list-archives/gmp-bugs/attachments/20120310/710353e1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gmp.h.patch
Type: application/octet-stream
Size: 901 bytes
Desc: not available
URL: <http://gmplib.org/list-archives/gmp-bugs/attachments/20120310/710353e1/attachment.obj>

More information about the gmp-bugs mailing list