Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 1 | From d2abe7328cea770425405aa0da2f4c2dac89fcad Mon Sep 17 00:00:00 2001 |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 2 | From: Matthias Schoepfer <matthias.schoepfer@ithinx.io> |
| 3 | Date: Fri, 31 May 2019 15:34:34 +0200 |
| 4 | Subject: [PATCH] bpo-36852: proper detection of mips architecture for soft |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 5 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 6 | float |
| 7 | |
| 8 | When (cross) compiling for softfloat mips, __mips_hard_float will not be |
| 9 | defined and detection of OS triplet in configure.ac / configure will fail. |
| 10 | |
| 11 | This also has to do with the custom detection of the build triplet. Trying |
| 12 | to do this in a more autoconf/autotools manner. |
| 13 | |
| 14 | Upstream-Status: Submitted [https://github.com/python/cpython/pull/13196] |
| 15 | Signed-off-by: Matthias Schoepfer <matthias.schoepfer@ithinx.io> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 16 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 17 | --- |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 18 | configure.ac | 196 ++++++--------------------------------------------- |
| 19 | 1 file changed, 21 insertions(+), 175 deletions(-) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 20 | |
| 21 | diff --git a/configure.ac b/configure.ac |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 22 | index 358b6ea..085fc0b 100644 |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 23 | --- a/configure.ac |
| 24 | +++ b/configure.ac |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 25 | @@ -907,181 +907,27 @@ then |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 26 | fi |
| 27 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 28 | |
| 29 | -AC_MSG_CHECKING([for the platform triplet based on compiler characteristics]) |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 30 | -cat > conftest.c <<EOF |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 31 | -#undef bfin |
| 32 | -#undef cris |
| 33 | -#undef fr30 |
| 34 | -#undef linux |
| 35 | -#undef hppa |
| 36 | -#undef hpux |
| 37 | -#undef i386 |
| 38 | -#undef mips |
| 39 | -#undef powerpc |
| 40 | -#undef sparc |
| 41 | -#undef unix |
| 42 | -#if defined(__ANDROID__) |
| 43 | - # Android is not a multiarch system. |
| 44 | -#elif defined(__linux__) |
| 45 | -# if defined(__x86_64__) && defined(__LP64__) |
| 46 | - x86_64-linux-gnu |
| 47 | -# elif defined(__x86_64__) && defined(__ILP32__) |
| 48 | - x86_64-linux-gnux32 |
| 49 | -# elif defined(__i386__) |
| 50 | - i386-linux-gnu |
| 51 | -# elif defined(__aarch64__) && defined(__AARCH64EL__) |
| 52 | -# if defined(__ILP32__) |
| 53 | - aarch64_ilp32-linux-gnu |
| 54 | -# else |
| 55 | - aarch64-linux-gnu |
| 56 | -# endif |
| 57 | -# elif defined(__aarch64__) && defined(__AARCH64EB__) |
| 58 | -# if defined(__ILP32__) |
| 59 | - aarch64_be_ilp32-linux-gnu |
| 60 | -# else |
| 61 | - aarch64_be-linux-gnu |
| 62 | -# endif |
| 63 | -# elif defined(__alpha__) |
| 64 | - alpha-linux-gnu |
| 65 | -# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP) |
| 66 | -# if defined(__ARMEL__) |
| 67 | - arm-linux-gnueabihf |
| 68 | -# else |
| 69 | - armeb-linux-gnueabihf |
| 70 | -# endif |
| 71 | -# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP) |
| 72 | -# if defined(__ARMEL__) |
| 73 | - arm-linux-gnueabi |
| 74 | -# else |
| 75 | - armeb-linux-gnueabi |
| 76 | -# endif |
| 77 | -# elif defined(__hppa__) |
| 78 | - hppa-linux-gnu |
| 79 | -# elif defined(__ia64__) |
| 80 | - ia64-linux-gnu |
| 81 | -# elif defined(__m68k__) && !defined(__mcoldfire__) |
| 82 | - m68k-linux-gnu |
| 83 | -# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) && defined(_MIPSEL) |
| 84 | -# if _MIPS_SIM == _ABIO32 |
| 85 | - mipsisa32r6el-linux-gnu |
| 86 | -# elif _MIPS_SIM == _ABIN32 |
| 87 | - mipsisa64r6el-linux-gnuabin32 |
| 88 | -# elif _MIPS_SIM == _ABI64 |
| 89 | - mipsisa64r6el-linux-gnuabi64 |
| 90 | -# else |
| 91 | -# error unknown platform triplet |
| 92 | -# endif |
| 93 | -# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) |
| 94 | -# if _MIPS_SIM == _ABIO32 |
| 95 | - mipsisa32r6-linux-gnu |
| 96 | -# elif _MIPS_SIM == _ABIN32 |
| 97 | - mipsisa64r6-linux-gnuabin32 |
| 98 | -# elif _MIPS_SIM == _ABI64 |
| 99 | - mipsisa64r6-linux-gnuabi64 |
| 100 | -# else |
| 101 | -# error unknown platform triplet |
| 102 | -# endif |
| 103 | -# elif defined(__mips_hard_float) && defined(_MIPSEL) |
| 104 | -# if _MIPS_SIM == _ABIO32 |
| 105 | - mipsel-linux-gnu |
| 106 | -# elif _MIPS_SIM == _ABIN32 |
| 107 | - mips64el-linux-gnuabin32 |
| 108 | -# elif _MIPS_SIM == _ABI64 |
| 109 | - mips64el-linux-gnuabi64 |
| 110 | -# else |
| 111 | -# error unknown platform triplet |
| 112 | -# endif |
| 113 | -# elif defined(__mips_hard_float) |
| 114 | -# if _MIPS_SIM == _ABIO32 |
| 115 | - mips-linux-gnu |
| 116 | -# elif _MIPS_SIM == _ABIN32 |
| 117 | - mips64-linux-gnuabin32 |
| 118 | -# elif _MIPS_SIM == _ABI64 |
| 119 | - mips64-linux-gnuabi64 |
| 120 | -# else |
| 121 | -# error unknown platform triplet |
| 122 | -# endif |
| 123 | -# elif defined(__or1k__) |
| 124 | - or1k-linux-gnu |
| 125 | -# elif defined(__powerpc__) && defined(__SPE__) |
| 126 | - powerpc-linux-gnuspe |
| 127 | -# elif defined(__powerpc64__) |
| 128 | -# if defined(__LITTLE_ENDIAN__) |
| 129 | - powerpc64le-linux-gnu |
| 130 | -# else |
| 131 | - powerpc64-linux-gnu |
| 132 | -# endif |
| 133 | -# elif defined(__powerpc__) |
| 134 | - powerpc-linux-gnu |
| 135 | -# elif defined(__s390x__) |
| 136 | - s390x-linux-gnu |
| 137 | -# elif defined(__s390__) |
| 138 | - s390-linux-gnu |
| 139 | -# elif defined(__sh__) && defined(__LITTLE_ENDIAN__) |
| 140 | - sh4-linux-gnu |
| 141 | -# elif defined(__sparc__) && defined(__arch64__) |
| 142 | - sparc64-linux-gnu |
| 143 | -# elif defined(__sparc__) |
| 144 | - sparc-linux-gnu |
| 145 | -# elif defined(__riscv) |
| 146 | -# if __riscv_xlen == 32 |
| 147 | - riscv32-linux-gnu |
| 148 | -# elif __riscv_xlen == 64 |
| 149 | - riscv64-linux-gnu |
| 150 | -# else |
| 151 | -# error unknown platform triplet |
| 152 | -# endif |
| 153 | -# else |
| 154 | -# error unknown platform triplet |
| 155 | -# endif |
| 156 | -#elif defined(__FreeBSD_kernel__) |
| 157 | -# if defined(__LP64__) |
| 158 | - x86_64-kfreebsd-gnu |
| 159 | -# elif defined(__i386__) |
| 160 | - i386-kfreebsd-gnu |
| 161 | -# else |
| 162 | -# error unknown platform triplet |
| 163 | -# endif |
| 164 | -#elif defined(__gnu_hurd__) |
| 165 | - i386-gnu |
| 166 | -#elif defined(__APPLE__) |
| 167 | - darwin |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 168 | -#elif defined(__VXWORKS__) |
| 169 | - vxworks |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 170 | -#elif defined(__wasm32__) |
| 171 | -# if defined(__EMSCRIPTEN__) |
| 172 | - wasm32-emscripten |
| 173 | -# elif defined(__wasi__) |
| 174 | - wasm32-wasi |
| 175 | -# else |
| 176 | -# error unknown wasm32 platform |
| 177 | -# endif |
| 178 | -#elif defined(__wasm64__) |
| 179 | -# if defined(__EMSCRIPTEN) |
| 180 | - wasm64-emscripten |
| 181 | -# elif defined(__wasi__) |
| 182 | - wasm64-wasi |
| 183 | -# else |
| 184 | -# error unknown wasm64 platform |
| 185 | -# endif |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 186 | -#else |
| 187 | -# error unknown platform triplet |
| 188 | -#endif |
| 189 | - |
| 190 | -EOF |
| 191 | - |
| 192 | -if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then |
| 193 | - PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '` |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 194 | - case "$build_os" in |
| 195 | - linux-musl*) |
| 196 | - PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'` |
| 197 | - ;; |
| 198 | - esac |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 199 | - AC_MSG_RESULT([$PLATFORM_TRIPLET]) |
| 200 | -else |
| 201 | - AC_MSG_RESULT([none]) |
| 202 | -fi |
| 203 | -rm -f conftest.c conftest.out |
| 204 | +AC_CANONICAL_TARGET |
| 205 | +## Not using $target to filter out vendor |
| 206 | +## Need to handle macos, vxworks and hurd special (?) :-/ |
| 207 | +case ${target_os} in |
| 208 | + darwin*) |
| 209 | + PLATFORM_TRIPLET=darwin |
| 210 | + ;; |
| 211 | + hurd*) |
| 212 | + PLATFORM_TRIPLET=i386-gnu |
| 213 | + ;; |
| 214 | + vxworks*) |
| 215 | + PLATFORM_TRIPLET=vxworks |
| 216 | + ;; |
| 217 | + *) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 218 | + if test "${target_cpu}" != "i686"; then |
| 219 | + PLATFORM_TRIPLET=${target_cpu}-${target_os} |
| 220 | + else |
| 221 | + PLATFORM_TRIPLET=i386-${target_os} |
| 222 | + fi |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 223 | + ;; |
| 224 | +esac |
| 225 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 226 | AC_MSG_CHECKING([for multiarch]) |
| 227 | AS_CASE([$ac_sys_system], |