|
| 1 | +/* Detect platform triplet from builtin defines |
| 2 | + * cc -E Misc/platform_triplet.c | grep -v '^#' | grep -v '^ *$' | grep -v '^typedef' | tr -d ' ' |
| 3 | + */ |
| 4 | +#undef bfin |
| 5 | +#undef cris |
| 6 | +#undef fr30 |
| 7 | +#undef linux |
| 8 | +#undef hppa |
| 9 | +#undef hpux |
| 10 | +#undef i386 |
| 11 | +#undef mips |
| 12 | +#undef powerpc |
| 13 | +#undef sparc |
| 14 | +#undef unix |
| 15 | +#if defined(__ANDROID__) |
| 16 | + # Android is not a multiarch system. |
| 17 | +#elif defined(__linux__) |
| 18 | +/* |
| 19 | + * BEGIN of Linux block |
| 20 | + */ |
| 21 | +// detect libc (glibc, musl) |
| 22 | +# include <features.h> |
| 23 | +# if defined(__UCLIBC__) |
| 24 | +# error "uclibc is not supported" |
| 25 | +# elif defined(__dietlibc__) |
| 26 | +# error "dietlibc is not supported" |
| 27 | +# elif defined(__GLIBC__) |
| 28 | +# define LIBC gnu |
| 29 | +# define LIBC_X32 gnux32 |
| 30 | +# define LIBC_ARM_EABIHF gnueabihf |
| 31 | +# define LIBC_ARM_EABI gnueabi |
| 32 | +# define LIBC_PPC_SPE gnuspe |
| 33 | +# if defined(_MIPS_SIM) |
| 34 | +# if _MIPS_SIM == _ABIO32 |
| 35 | + define LIBC_MIPS_SIM gnu |
| 36 | +# elif _MIPS_SIM == _ABIN32 |
| 37 | + define LIBC_MIPS_SIM gnuabin32 |
| 38 | +# elif _MIPS_SIM == _ABI64 |
| 39 | + define LIBC_MIPS_SIM gnuabi64 |
| 40 | +# endif |
| 41 | +# endif /* defined(_MIPS_SIM) */ |
| 42 | +# else |
| 43 | +/* heuristic to detect musl libc (based on config.guess). |
| 44 | + * Adds "typedef __builtin_va_list va_list;" to output. |
| 45 | + */ |
| 46 | +# include <stdarg.h> |
| 47 | +# ifdef __DEFINED_va_list |
| 48 | +# define LIBC musl |
| 49 | +// # define LIBC_X32 |
| 50 | +# define LIBC_ARM_EABIHF musleabihf |
| 51 | +# define LIBC_ARM_EABI musleabi |
| 52 | +//# define LIBC_PPC_SPE |
| 53 | +# define LIBC_MIPS_SIM musl |
| 54 | +# else |
| 55 | +# error "unknown libc" |
| 56 | +# endif |
| 57 | +#endif |
| 58 | + |
| 59 | +# if defined(__x86_64__) && defined(__LP64__) |
| 60 | + x86_64-linux-LIBC |
| 61 | +# elif defined(__x86_64__) && defined(__ILP32__) && defined(LIBC_X32) |
| 62 | + x86_64-linux-LIBC_X32 |
| 63 | +# elif defined(__i386__) |
| 64 | + i386-linux-LIBC |
| 65 | +# elif defined(__aarch64__) && defined(__AARCH64EL__) |
| 66 | +# if defined(__ILP32__) |
| 67 | + aarch64_ilp32-linux-LIBC |
| 68 | +# else |
| 69 | + aarch64-linux-LIBC |
| 70 | +# endif |
| 71 | +# elif defined(__aarch64__) && defined(__AARCH64EB__) |
| 72 | +# if defined(__ILP32__) |
| 73 | + aarch64_be_ilp32-linux-LIBC |
| 74 | +# else |
| 75 | + aarch64_be-linux-LIBC |
| 76 | +# endif |
| 77 | +# elif defined(__alpha__) |
| 78 | + alpha-linux-LIBC |
| 79 | +# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP) && defined(LIBC_ARM_EABIHF) |
| 80 | +# if defined(__ARMEL__) |
| 81 | + arm-linux-LIBC_ARM_EABIHF |
| 82 | +# else |
| 83 | + armeb-linux-LIBC_ARM_EABIHF |
| 84 | +# endif |
| 85 | +# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP) && defined(LIBC_ARM_EABI) |
| 86 | +# if defined(__ARMEL__) |
| 87 | + arm-linux-LIBC_ARM_EABI |
| 88 | +# else |
| 89 | + armeb-linux-LIBC_ARM_EABI |
| 90 | +# endif |
| 91 | +# elif defined(__hppa__) |
| 92 | + hppa-linux-LIBC |
| 93 | +# elif defined(__ia64__) |
| 94 | + ia64-linux-LIBC |
| 95 | +# elif defined(__m68k__) && !defined(__mcoldfire__) |
| 96 | + m68k-linux-LIBC |
| 97 | +# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) && defined(_MIPSEL) && defined(LIBC_MIPS_SIM) |
| 98 | +# if _MIPS_SIM == _ABIO32 |
| 99 | + mipsisa32r6el-linux-LIBC_MIPS_SIM |
| 100 | +# elif (_MIPS_SIM == _ABIN32) || (_MIPS_SIM == _ABI64) |
| 101 | + mipsisa64r6el-linux-LIBC_MIPS_SIM |
| 102 | +# else |
| 103 | +# error unknown platform triplet |
| 104 | +# endif |
| 105 | +# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) && defined(LIBC_MIPS_SIM) |
| 106 | +# if _MIPS_SIM == _ABIO32 |
| 107 | + mipsisa32r6-linux-LIBC_MIPS_SIM |
| 108 | +# elif (_MIPS_SIM == _ABIN32) || (_MIPS_SIM == _ABI64) |
| 109 | + mipsisa64r6-linux-LIBC_MIPS_SIM |
| 110 | +# else |
| 111 | +# error unknown platform triplet |
| 112 | +# endif |
| 113 | +# elif defined(__mips_hard_float) && defined(_MIPSEL) && defined(LIBC_MIPS_SIM) |
| 114 | +# if _MIPS_SIM == _ABIO32 |
| 115 | + mipsel-linux-LIBC_MIPS_SIM |
| 116 | +# elif (_MIPS_SIM == _ABIN32) || (_MIPS_SIM == _ABI64) |
| 117 | + mips64el-linux-LIBC_MIPS_SIM |
| 118 | +# else |
| 119 | +# error unknown platform triplet |
| 120 | +# endif |
| 121 | +# elif defined(__mips_hard_float) && defined(LIBC_MIPS_SIM) |
| 122 | +# if _MIPS_SIM == _ABIO32 |
| 123 | + mips-linux-LIBC_MIPS_SIM |
| 124 | +# elif (_MIPS_SIM == _ABIN32) || (_MIPS_SIM == _ABI64) |
| 125 | + mips64-linux-LIBC_MIPS_SIM |
| 126 | +# else |
| 127 | +# error unknown platform triplet |
| 128 | +# endif |
| 129 | +# elif defined(__or1k__) |
| 130 | + or1k-linux-LIBC |
| 131 | +# elif defined(__powerpc__) && defined(__SPE__) && defined(LIBC_PPC_SPE) |
| 132 | + powerpc-linux-LIBC_PPC_SPE |
| 133 | +# elif defined(__powerpc64__) |
| 134 | +# if defined(__LITTLE_ENDIAN__) |
| 135 | + powerpc64le-linux-LIBC |
| 136 | +# else |
| 137 | + powerpc64-linux-LIBC |
| 138 | +# endif |
| 139 | +# elif defined(__powerpc__) |
| 140 | + powerpc-linux-LIBC |
| 141 | +# elif defined(__s390x__) |
| 142 | + s390x-linux-LIBC |
| 143 | +# elif defined(__s390__) |
| 144 | + s390-linux-LIBC |
| 145 | +# elif defined(__sh__) && defined(__LITTLE_ENDIAN__) |
| 146 | + sh4-linux-LIBC |
| 147 | +# elif defined(__sparc__) && defined(__arch64__) |
| 148 | + sparc64-linux-LIBC |
| 149 | +# elif defined(__sparc__) |
| 150 | + sparc-linux-LIBC |
| 151 | +# elif defined(__riscv) |
| 152 | +# if __riscv_xlen == 32 |
| 153 | + riscv32-linux-LIBC |
| 154 | +# elif __riscv_xlen == 64 |
| 155 | + riscv64-linux-LIBC |
| 156 | +# else |
| 157 | +# error unknown platform triplet |
| 158 | +# endif |
| 159 | +# else |
| 160 | +# error unknown platform triplet |
| 161 | +# endif |
| 162 | +/* |
| 163 | + * END of Linux block |
| 164 | + */ |
| 165 | +#elif defined(__FreeBSD_kernel__) |
| 166 | +# if defined(__LP64__) |
| 167 | + x86_64-kfreebsd-gnu |
| 168 | +# elif defined(__i386__) |
| 169 | + i386-kfreebsd-gnu |
| 170 | +# else |
| 171 | +# error unknown platform triplet |
| 172 | +# endif |
| 173 | +#elif defined(__gnu_hurd__) |
| 174 | + i386-gnu |
| 175 | +#elif defined(__APPLE__) |
| 176 | + darwin |
| 177 | +#elif defined(__VXWORKS__) |
| 178 | + vxworks |
| 179 | +#elif defined(__EMSCRIPTEN__) |
| 180 | +# if defined(__wasm32__) |
| 181 | + wasm32-emscripten |
| 182 | +# elif defined(__wasm64__) |
| 183 | + wasm64-emscripten |
| 184 | +# else |
| 185 | +# error unknown Emscripten platform |
| 186 | +# endif |
| 187 | +#elif defined(__wasi__) |
| 188 | +# if defined(__wasm32__) |
| 189 | + wasm32-wasi |
| 190 | +# elif defined(__wasm64__) |
| 191 | + wasm64-wasi |
| 192 | +# else |
| 193 | +# error unknown WASI platform |
| 194 | +# endif |
| 195 | +#else |
| 196 | +# error unknown platform triplet |
| 197 | +#endif |
0 commit comments