summary refs log tree commit diff
path: root/pkgs/development/interpreters/python/cpython/platform-triplet-detection.patch
blob: ec76546f54ee88eb74698a659c7e2652b9534c64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
diff --git a/configure.ac b/configure.ac
index ba768aea93..621ac166bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -936,125 +936,192 @@ cat > conftest.c <<EOF
 #if defined(__ANDROID__)
     # Android is not a multiarch system.
 #elif defined(__linux__)
+# include <features.h>
+# if defined(__UCLIBC__)
+#  error uclibc not supported
+# elif defined(__dietlibc__)
+#  error dietlibc not supported
+# elif defined(__GLIBC__)
+#  define LIBC gnu
+#  define LIBC_X32 gnux32
+#  if defined(__ARM_PCS_VFP)
+#   define LIBC_ARM gnueabihf
+#  else
+#   define LIBC_ARM gnueabi
+#  endif
+#  if defined(__loongarch__)
+#   if defined(__loongarch_soft_float)
+#    define LIBC_LA gnusf
+#   elif defined(__loongarch_single_float)
+#    define LIBC_LA gnuf32
+#   elif defined(__loongarch_double_float)
+#    define LIBC_LA gnu
+#   else
+#    error unknown loongarch floating-point base abi
+#   endif
+#  endif
+#  if defined(_MIPS_SIM)
+#   if defined(__mips_hard_float)
+#    if _MIPS_SIM == _ABIO32
+#     define LIBC_MIPS gnu
+#    elif _MIPS_SIM == _ABIN32
+#     define LIBC_MIPS gnuabin32
+#    elif _MIPS_SIM == _ABI64
+#     define LIBC_MIPS gnuabi64
+#    else
+#     error unknown mips sim value
+#    endif
+#   else
+#    if _MIPS_SIM == _ABIO32
+#     define LIBC_MIPS gnusf
+#    elif _MIPS_SIM == _ABIN32
+#     define LIBC_MIPS gnuabin32sf
+#    elif _MIPS_SIM == _ABI64
+#     define LIBC_MIPS gnuabi64sf
+#    else
+#     error unknown mips sim value
+#    endif
+#   endif
+#  endif
+#  if defined(__SPE__)
+#   define LIBC_PPC gnuspe
+#  else
+#   define LIBC_PPC gnu
+#  endif
+# else
+#  include <stdarg.h>
+#  ifdef __DEFINED_va_list
+#   define LIBC musl
+#   define LIBC_X32 muslx32
+#   if defined(__ARM_PCS_VFP)
+#    define LIBC_ARM musleabihf
+#   else
+#    define LIBC_ARM musleabi
+#   endif
+#   if defined(__loongarch__)
+#    if defined(__loongarch_soft_float)
+#     define LIBC_LA muslsf
+#    elif defined(__loongarch_single_float)
+#     define LIBC_LA muslf32
+#    elif defined(__loongarch_double_float)
+#     define LIBC_LA musl
+#    else
+#     error unknown loongarch floating-point base abi
+#    endif
+#   endif
+#   if defined(_MIPS_SIM)
+#    if defined(__mips_hard_float)
+#     if _MIPS_SIM == _ABIO32
+#      define LIBC_MIPS musl
+#     elif _MIPS_SIM == _ABIN32
+#      define LIBC_MIPS musln32
+#     elif _MIPS_SIM == _ABI64
+#      define LIBC_MIPS musl
+#     else
+#      error unknown mips sim value
+#     endif
+#    else
+#     if _MIPS_SIM == _ABIO32
+#      define LIBC_MIPS muslsf
+#     elif _MIPS_SIM == _ABIN32
+#      define LIBC_MIPS musln32sf
+#     elif _MIPS_SIM == _ABI64
+#      define LIBC_MIPS muslsf
+#     else
+#      error unknown mips sim value
+#     endif
+#    endif
+#   endif
+#   if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
+#    define LIBC_PPC muslsf
+#   else
+#    define LIBC_PPC musl
+#   endif
+#  else
+#   error unknown libc
+#  endif
+# endif
 # if defined(__x86_64__) && defined(__LP64__)
-        x86_64-linux-gnu
+        x86_64-linux-LIBC
 # elif defined(__x86_64__) && defined(__ILP32__)
-        x86_64-linux-gnux32
+        x86_64-linux-LIBC_X32
 # elif defined(__i386__)
-        i386-linux-gnu
+        i386-linux-LIBC
 # elif defined(__aarch64__) && defined(__AARCH64EL__)
 #  if defined(__ILP32__)
-        aarch64_ilp32-linux-gnu
+        aarch64_ilp32-linux-LIBC
 #  else
-        aarch64-linux-gnu
+        aarch64-linux-LIBC
 #  endif
 # elif defined(__aarch64__) && defined(__AARCH64EB__)
 #  if defined(__ILP32__)
-        aarch64_be_ilp32-linux-gnu
+        aarch64_be_ilp32-linux-LIBC
 #  else
-        aarch64_be-linux-gnu
+        aarch64_be-linux-LIBC
 #  endif
 # elif defined(__alpha__)
-        alpha-linux-gnu
-# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP)
+        alpha-linux-LIBC
+# elif defined(__ARM_EABI__)
 #  if defined(__ARMEL__)
-        arm-linux-gnueabihf
+        arm-linux-LIBC_ARM
 #  else
-        armeb-linux-gnueabihf
-#  endif
-# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP)
-#  if defined(__ARMEL__)
-        arm-linux-gnueabi
-#  else
-        armeb-linux-gnueabi
+        armeb-linux-LIBC_ARM
 #  endif
 # elif defined(__hppa__)
-        hppa-linux-gnu
+        hppa-linux-LIBC
 # elif defined(__ia64__)
-        ia64-linux-gnu
-# elif defined(__loongarch__)
-#  if defined(__loongarch_lp64)
-#   if defined(__loongarch_soft_float)
-        loongarch64-linux-gnusf
-#   elif defined(__loongarch_single_float)
-        loongarch64-linux-gnuf32
-#   elif defined(__loongarch_double_float)
-        loongarch64-linux-gnu
+        ia64-linux-LIBC
+# elif defined(__loongarch__) && defined(__loongarch_lp64)
+        loongarch64-linux-LIBC_LA
+# elif defined(__m68k__) && !defined(__mcoldfire__)
+        m68k-linux-LIBC
+# elif defined(__mips__)
+#  if defined(__mips_isa_rev) && (__mips_isa_rev >=6)
+#   if defined(_MIPSEL) && defined(__mips64)
+        mipsisa64r6el-linux-LIBC_MIPS
+#   elif defined(_MIPSEL)
+        mipsisa32r6el-linux-LIBC_MIPS
+#   elif defined(__mips64)
+        mipsisa64r6-linux-LIBC_MIPS
 #   else
-#    error unknown platform triplet
+        mipsisa32r6-linux-LIBC_MIPS
 #   endif
 #  else
-#   error unknown platform triplet
-#  endif
-# elif defined(__m68k__) && !defined(__mcoldfire__)
-        m68k-linux-gnu
-# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) && defined(_MIPSEL)
-#  if _MIPS_SIM == _ABIO32
-        mipsisa32r6el-linux-gnu
-#  elif _MIPS_SIM == _ABIN32
-        mipsisa64r6el-linux-gnuabin32
-#  elif _MIPS_SIM == _ABI64
-        mipsisa64r6el-linux-gnuabi64
-#  else
-#   error unknown platform triplet
-#  endif
-# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6)
-#  if _MIPS_SIM == _ABIO32
-        mipsisa32r6-linux-gnu
-#  elif _MIPS_SIM == _ABIN32
-        mipsisa64r6-linux-gnuabin32
-#  elif _MIPS_SIM == _ABI64
-        mipsisa64r6-linux-gnuabi64
-#  else
-#   error unknown platform triplet
-#  endif
-# elif defined(__mips_hard_float) && defined(_MIPSEL)
-#  if _MIPS_SIM == _ABIO32
-        mipsel-linux-gnu
-#  elif _MIPS_SIM == _ABIN32
-        mips64el-linux-gnuabin32
-#  elif _MIPS_SIM == _ABI64
-        mips64el-linux-gnuabi64
-#  else
-#   error unknown platform triplet
-#  endif
-# elif defined(__mips_hard_float)
-#  if _MIPS_SIM == _ABIO32
-        mips-linux-gnu
-#  elif _MIPS_SIM == _ABIN32
-        mips64-linux-gnuabin32
-#  elif _MIPS_SIM == _ABI64
-        mips64-linux-gnuabi64
-#  else
-#   error unknown platform triplet
+#   if defined(_MIPSEL) && defined(__mips64)
+        mips64el-linux-LIBC_MIPS
+#   elif defined(_MIPSEL)
+        mipsel-linux-LIBC_MIPS
+#   elif defined(__mips64)
+        mips64-linux-LIBC_MIPS
+#   else
+        mips-linux-LIBC_MIPS
+#   endif
 #  endif
 # elif defined(__or1k__)
-        or1k-linux-gnu
-# elif defined(__powerpc__) && defined(__SPE__)
-        powerpc-linux-gnuspe
+        or1k-linux-LIBC
 # elif defined(__powerpc64__)
 #  if defined(__LITTLE_ENDIAN__)
-        powerpc64le-linux-gnu
+        powerpc64le-linux-LIBC
 #  else
-        powerpc64-linux-gnu
+        powerpc64-linux-LIBC
 #  endif
 # elif defined(__powerpc__)
-        powerpc-linux-gnu
+        powerpc-linux-LIBC_PPC
 # elif defined(__s390x__)
-        s390x-linux-gnu
+        s390x-linux-LIBC
 # elif defined(__s390__)
-        s390-linux-gnu
+        s390-linux-LIBC
 # elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
-        sh4-linux-gnu
+        sh4-linux-LIBC
 # elif defined(__sparc__) && defined(__arch64__)
-        sparc64-linux-gnu
+        sparc64-linux-LIBC
 # elif defined(__sparc__)
-        sparc-linux-gnu
+        sparc-linux-LIBC
 # elif defined(__riscv)
 #  if __riscv_xlen == 32
-        riscv32-linux-gnu
+        riscv32-linux-LIBC
 #  elif __riscv_xlen == 64
-        riscv64-linux-gnu
+        riscv64-linux-LIBC
 #  else
 #   error unknown platform triplet
 #  endif
@@ -1102,12 +1169,7 @@ cat > conftest.c <<EOF
 EOF
 
 if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
-  PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' 	'`
-  case "$build_os" in
-  linux-musl*)
-    PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'`
-    ;;
-  esac
+  PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | grep -v typedef | tr -d ' 	'`
   AC_MSG_RESULT([$PLATFORM_TRIPLET])
 else
   AC_MSG_RESULT([none])