Next: , Previous: Build Options, Up: Installing MPIR   [Index]


2.2 ABI and ISA

ABI (Application Binary Interface) refers to the calling conventions between functions, meaning what registers are used and what sizes the various C data types are. ISA (Instruction Set Architecture) refers to the instructions and registers a CPU has available.

Some 64-bit ISA CPUs have both a 64-bit ABI and a 32-bit ABI defined, the latter for compatibility with older CPUs in the family. MPIR supports some CPUs like this in both ABIs. In fact within MPIR ‘ABI’ means a combination of chip ABI, plus how MPIR chooses to use it. For example in some 32-bit ABIs, MPIR may support a limb as either a 32-bit long or a 64-bit long long.

By default MPIR chooses the best ABI available for a given system, and this generally gives significantly greater speed. But an ABI can be chosen explicitly to make MPIR compatible with other libraries, or particular application requirements. For example,

./configure ABI=32

In all cases it’s vital that all object code used in a given program is compiled for the same ABI.

Usually a limb is implemented as a long. When a long long limb is used this is encoded in the generated mpir.h. This is convenient for applications, but it does mean that mpir.h will vary, and can’t be just copied around. mpir.h remains compiler independent though, since all compilers for a particular ABI will be expected to use the same limb type.

Currently no attempt is made to follow whatever conventions a system has for installing library or header files built for a particular ABI. This will probably only matter when installing multiple builds of MPIR, and it might be as simple as configuring with a special ‘libdir’, or it might require more than that. Note that builds for different ABIs need to done separately, with a fresh (make distclean), ./configure and make.


AMD64 (‘x86_64’)

On AMD64 systems supporting both 32-bit and 64-bit modes for applications, the following ABI choices are available.

ABI=64

The 64-bit ABI uses 64-bit limbs and pointers and makes full use of the chip architecture. This is the default. Applications will usually not need special compiler flags, but for reference the option is

gcc  -m64
ABI=32

The 32-bit ABI is the usual i386 conventions. This will be slower, and is not recommended except for inter-operating with other code not yet 64-bit capable. Applications must be compiled with

gcc  -m32

(In GCC 2.95 and earlier there’s no ‘-m32’ option, it’s the only mode.)


IA-64 under HP-UX (‘ia64*-*-hpux*’, ‘itanium*-*-hpux*’)

HP-UX supports two ABIs for IA-64. MPIR performance is the same in both.

ABI=32

In the 32-bit ABI, pointers, ints and longs are 32 bits and MPIR uses a 64 bit long long for a limb. Applications can be compiled without any special flags since this ABI is the default in both HP C and GCC, but for reference the flags are

gcc  -milp32
cc   +DD32
ABI=64

In the 64-bit ABI, longs and pointers are 64 bits and MPIR uses a long for a limb. Applications must be compiled with

gcc  -mlp64
cc   +DD64

On other IA-64 systems, GNU/Linux for instance, ‘ABI=64’ is the only choice.


PowerPC 64 (‘powerpc64’, ‘powerpc620’, ‘powerpc630’, ‘powerpc970’)
ABI=aix64

The AIX 64 ABI uses 64-bit limbs and pointers and is the default on PowerPC 64 ‘*-*-aix*’ systems. Applications must be compiled with

gcc  -maix64
xlc  -q64
ABI=mode32

The ‘mode32’ ABI uses a 64-bit long long limb but with the chip still in 32-bit mode and using 32-bit calling conventions. This is the default on PowerPC 64 ‘*-*-darwin*’ systems. No special compiler options are needed for applications.

ABI=32

This is the basic 32-bit PowerPC ABI, with a 32-bit limb. No special compiler options are needed for applications.

MPIR speed is greatest in ‘aix64’ and ‘mode32’. In ‘ABI=32’ only the 32-bit ISA is used and this doesn’t make full use of a 64-bit chip. On a suitable system we could perhaps use more of the ISA, but there are no plans to do so.


Sparc V9 (‘sparc64’, ‘sparcv9’, ‘ultrasparc*’)
ABI=64

The 64-bit V9 ABI is available on the various BSD sparc64 ports, recent versions of Sparc64 GNU/Linux, and Solaris 2.7 and up (when the kernel is in 64-bit mode). GCC 3.2 or higher, or Sun cc is required. On GNU/Linux, depending on the default gcc mode, applications must be compiled with

gcc  -m64

On Solaris applications must be compiled with

gcc  -m64 -mptr64 -Wa,-xarch=v9 -mcpu=v9
cc   -xarch=v9

On the BSD sparc64 systems no special options are required, since 64-bits is the only ABI available.

ABI=32

For the basic 32-bit ABI, MPIR still uses as much of the V9 ISA as it can. In the Sun documentation this combination is known as “v8plus”. On GNU/Linux, depending on the default gcc mode, applications may need to be compiled with

gcc  -m32

On Solaris, no special compiler options are required for applications, though using something like the following is recommended. (gcc 2.8 and earlier only support ‘-mv8’ though.)

gcc  -mv8plus
cc   -xarch=v8plus

MPIR speed is greatest in ‘ABI=64’, so it’s the default where available. The speed is partly because there are extra registers available and partly because 64-bits is considered the more important case and has therefore had better code written for it.

Don’t be confused by the names of the ‘-m’ and ‘-x’ compiler options, they’re called ‘arch’ but effectively control both ABI and ISA.

On Solaris 2.6 and earlier, only ‘ABI=32’ is available since the kernel doesn’t save all registers.

On Solaris 2.7 with the kernel in 32-bit mode, a normal native build will reject ‘ABI=64’ because the resulting executables won’t run. ‘ABI=64’ can still be built if desired by making it look like a cross-compile, for example

./configure --build=none --host=sparcv9-sun-solaris2.7 ABI=64

Next: , Previous: Build Options, Up: Installing MPIR   [Index]