github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/doc/isa_abi_headache (about) 1 Copyright 2000 Free Software Foundation, Inc. 2 3 This file is part of the GNU MP Library. 4 5 The GNU MP Library is free software; you can redistribute it and/or modify 6 it under the terms of either: 7 8 * the GNU Lesser General Public License as published by the Free 9 Software Foundation; either version 3 of the License, or (at your 10 option) any later version. 11 12 or 13 14 * the GNU General Public License as published by the Free Software 15 Foundation; either version 2 of the License, or (at your option) any 16 later version. 17 18 or both in parallel, as here. 19 20 The GNU MP Library is distributed in the hope that it will be useful, but 21 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 22 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 23 for more details. 24 25 You should have received copies of the GNU General Public License and the 26 GNU Lesser General Public License along with the GNU MP Library. If not, 27 see https://www.gnu.org/licenses/. 28 29 30 31 32 Terms Used In This Document: 33 ISA = Instruction Set Architecture. The instructions the current 34 processor provides. 35 ABI = Application Binary Interface. Specifies calling convention, 36 type sizes, etc. 37 AR64 = Arithmetic operations are 64-bit using 64-bit instructions 38 (E.g., addition, subtraction, load, store, of 64-bit integer types 39 are done with single instructions, not 32 bits at a time.) 40 Environment = The operating system and compiler. 41 42 GMP is a very complex package to build since its speed is very 43 sensitive to the ISA and ABI. For example, if the ISA provides 64-bit 44 instructions, it is crucial that GMP is configured to use them. 45 46 Most environments that run on a 64-bit ISA provide more than one ABI. 47 Typically one of the supported ABI's is a backward compatible 32-bit 48 ABI, and one ABI provides 64-bit addressing and `long' (sometimes 49 known as LP64). But a few environments (IRIX, HP-UX) provide 50 intermediate ABI's using 32-bit addressing but allow efficient 64-bit 51 operations through a `long long' type. For the latter to be useful to 52 GMP, the ABI must allow operations using the native 64-bit 53 instructions provided by the ISA, and allow passing of 64-bit 54 quantities atomically. 55 56 The ABI is typically chosen by means of command line options to the 57 compiler tools (gcc, cc, c89, nm, ar, ld, as). Different environments 58 use different defaults, but as of this writing (May 2000) the 59 dominating default is to the plain 32-bit ABI in its most arcane form. 60 61 The GMP 3.0.x approach was to compile using the ABI that gives the 62 best performance. That places the burden on users to pass special 63 options to the compiler when they compile their GMP applications. 64 That approach has its advantages and disadvantages. The main 65 advantage is that users don't unknowingly get bad GMP performance. 66 The main disadvantage is that users' compiles (actually links) will 67 fail unless they pass special compiler options. 68 69 ** SPARC 70 71 System vendors often confuse ABI, ISA, and implementation. The worst 72 case is Solaris, were the unbundled compiler confuses ISA and ABI, and 73 the options have very confusing names. 74 75 option interpretation 76 ====== ============== 77 cc -xarch=v8plus ISA=sparcv9, ABI=V8plus (PTR=32, see below) 78 gcc -mv8plus ISA=sparcv9, ABI=V8plus (see below) 79 cc -xarch=v9 ISA=sparcv9, ABI=V9 (implying AR=64, PTR=64) 80 81 It's hard to believe, but the option v8plus really means ISA=V9! 82 83 Solaris releases prior to version 7 running on a V9 CPU fails to 84 save/restore the upper 32 bits of the `i' and `l' registers. The 85 `v8plus' option generates code that use as many V9 features as 86 possible under such circumstances. 87 88 ** MIPS 89 90 The IRIX 6 compilers gets things right. They have a clear 91 understanding of the differences between ABI and ISA. The option 92 names are descriptive. 93 94 option interpretation 95 ====== ============== 96 cc -n32 ABI=n32 (implying AR=64, PTR=32) 97 gcc -mabi=n32 ABI=n32 (implying AR=64, PTR=32) 98 cc -64 ABI=64 (implying AR=64, PTR=64) 99 gcc -mabi=64 ABI=64 (implying AR=64, PTR=64) 100 cc -mips3 ISA=mips3 101 gcc -mips3 ISA=mips3 102 cc -mips4 ISA=mips4 103 gcc -mips4 ISA=mips4 104 105 ** HP-PA 106 107 HP-UX is somewhat weird, but not as broken as Solaris. 108 109 option interpretation 110 ====== ============== 111 cc +DA2.0 ABI=32bit (implying AR=64, PTR=32) 112 cc +DD64 ABI=64bit (implying AR=64, PTR=64) 113 114 Code performing 64-bit arithmetic in the HP-UX 32-bit is not 115 compatible with the 64-bit ABI; the former has a calling convention 116 that passes/returns 64-bit integer quantities as two 32-bit chunks. 117 118 ** PowerPC 119 120 While the PowerPC ABI's are capable of supporting 64-bit 121 registers/operations, the compilers under AIX are similar to Solaris' 122 cc in that they don't currently provide any 32-bit addressing with 123 64-bit arithmetic. 124 125 option interpretation 126 ====== ============== 127 cc -q64 ABI=64bit (implying AR=64, PTR=64) 128 gcc -maix64 -mpowerpc64 ABI=64bit (implying AR=64, PTR=64)