Skip to content

Commit ee08d8e

Browse files
committed
Add PLATFORM_TRIPLET= prefix and grep for the prefix directly
1 parent 72e6b7e commit ee08d8e

File tree

3 files changed

+49
-49
lines changed

3 files changed

+49
-49
lines changed

Misc/platform_triplet.c

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Detect platform triplet from builtin defines
2-
* cc -E Misc/platform_triplet.c | grep -v '^#' | grep -v '^ *$' | grep -v '^typedef' | tr -d ' '
2+
* cc -E Misc/platform_triplet.c | grep '^PLATFORM_TRIPLET=' | tr -d ' '
33
*/
44
#undef bfin
55
#undef cris
@@ -72,9 +72,7 @@
7272
# define LIBC_PPC gnu
7373
# endif
7474
# else
75-
/* Heuristic to detect musl libc
76-
* Adds "typedef __builtin_va_list va_list;" to output
77-
*/
75+
// Heuristic to detect musl libc
7876
# include <stdarg.h>
7977
# ifdef __DEFINED_va_list
8078
# define LIBC musl
@@ -129,86 +127,86 @@
129127
# endif
130128

131129
# if defined(__x86_64__) && defined(__LP64__)
132-
x86_64-linux-LIBC
130+
PLATFORM_TRIPLET=x86_64-linux-LIBC
133131
# elif defined(__x86_64__) && defined(__ILP32__)
134-
x86_64-linux-LIBC_X32
132+
PLATFORM_TRIPLET=x86_64-linux-LIBC_X32
135133
# elif defined(__i386__)
136-
i386-linux-LIBC
134+
PLATFORM_TRIPLET=i386-linux-LIBC
137135
# elif defined(__aarch64__) && defined(__AARCH64EL__)
138136
# if defined(__ILP32__)
139-
aarch64_ilp32-linux-LIBC
137+
PLATFORM_TRIPLET=aarch64_ilp32-linux-LIBC
140138
# else
141-
aarch64-linux-LIBC
139+
PLATFORM_TRIPLET=aarch64-linux-LIBC
142140
# endif
143141
# elif defined(__aarch64__) && defined(__AARCH64EB__)
144142
# if defined(__ILP32__)
145-
aarch64_be_ilp32-linux-LIBC
143+
PLATFORM_TRIPLET=aarch64_be_ilp32-linux-LIBC
146144
# else
147-
aarch64_be-linux-LIBC
145+
PLATFORM_TRIPLET=aarch64_be-linux-LIBC
148146
# endif
149147
# elif defined(__alpha__)
150-
alpha-linux-LIBC
148+
PLATFORM_TRIPLET=alpha-linux-LIBC
151149
# elif defined(__ARM_EABI__)
152150
# if defined(__ARMEL__)
153-
arm-linux-LIBC_ARM
151+
PLATFORM_TRIPLET=arm-linux-LIBC_ARM
154152
# else
155-
armeb-linux-LIBC_ARM
153+
PLATFORM_TRIPLET=armeb-linux-LIBC_ARM
156154
# endif
157155
# elif defined(__hppa__)
158-
hppa-linux-LIBC
156+
PLATFORM_TRIPLET=hppa-linux-LIBC
159157
# elif defined(__ia64__)
160-
ia64-linux-LIBC
158+
PLATFORM_TRIPLET=ia64-linux-LIBC
161159
# elif defined(__loongarch__) && defined(__loongarch_lp64)
162-
loongarch64-linux-LIBC_LA
160+
PLATFORM_TRIPLET=loongarch64-linux-LIBC_LA
163161
# elif defined(__m68k__) && !defined(__mcoldfire__)
164-
m68k-linux-LIBC
162+
PLATFORM_TRIPLET=m68k-linux-LIBC
165163
# elif defined(__mips__)
166164
# if defined(__mips_isa_rev) && (__mips_isa_rev >=6)
167165
# if defined(_MIPSEL) && defined(__mips64)
168-
mipsisa64r6el-linux-LIBC_MIPS
166+
PLATFORM_TRIPLET=mipsisa64r6el-linux-LIBC_MIPS
169167
# elif defined(_MIPSEL)
170-
mipsisa32r6el-linux-LIBC_MIPS
168+
PLATFORM_TRIPLET=mipsisa32r6el-linux-LIBC_MIPS
171169
# elif defined(__mips64)
172-
mipsisa64r6-linux-LIBC_MIPS
170+
PLATFORM_TRIPLET=mipsisa64r6-linux-LIBC_MIPS
173171
# else
174-
mipsisa32r6-linux-LIBC_MIPS
172+
PLATFORM_TRIPLET=mipsisa32r6-linux-LIBC_MIPS
175173
# endif
176174
# else
177175
# if defined(_MIPSEL) && defined(__mips64)
178-
mips64el-linux-LIBC_MIPS
176+
PLATFORM_TRIPLET=mips64el-linux-LIBC_MIPS
179177
# elif defined(_MIPSEL)
180-
mipsel-linux-LIBC_MIPS
178+
PLATFORM_TRIPLET=mipsel-linux-LIBC_MIPS
181179
# elif defined(__mips64)
182-
mips64-linux-LIBC_MIPS
180+
PLATFORM_TRIPLET=mips64-linux-LIBC_MIPS
183181
# else
184-
mips-linux-LIBC_MIPS
182+
PLATFORM_TRIPLET=mips-linux-LIBC_MIPS
185183
# endif
186184
# endif
187185
# elif defined(__or1k__)
188-
or1k-linux-LIBC
186+
PLATFORM_TRIPLET=or1k-linux-LIBC
189187
# elif defined(__powerpc__)
190-
powerpc-linux-LIBC_PPC
188+
PLATFORM_TRIPLET=powerpc-linux-LIBC_PPC
191189
# elif defined(__powerpc64__)
192190
# if defined(__LITTLE_ENDIAN__)
193-
powerpc64le-linux-LIBC
191+
PLATFORM_TRIPLET=powerpc64le-linux-LIBC
194192
# else
195-
powerpc64-linux-LIBC
193+
PLATFORM_TRIPLET=powerpc64-linux-LIBC
196194
# endif
197195
# elif defined(__s390x__)
198-
s390x-linux-LIBC
196+
PLATFORM_TRIPLET=s390x-linux-LIBC
199197
# elif defined(__s390__)
200-
s390-linux-LIBC
198+
PLATFORM_TRIPLET=s390-linux-LIBC
201199
# elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
202-
sh4-linux-LIBC
200+
PLATFORM_TRIPLET=sh4-linux-LIBC
203201
# elif defined(__sparc__) && defined(__arch64__)
204-
sparc64-linux-LIBC
202+
PLATFORM_TRIPLET=sparc64-linux-LIBC
205203
# elif defined(__sparc__)
206-
sparc-linux-LIBC
204+
PLATFORM_TRIPLET=sparc-linux-LIBC
207205
# elif defined(__riscv)
208206
# if __riscv_xlen == 32
209-
riscv32-linux-LIBC
207+
PLATFORM_TRIPLET=riscv32-linux-LIBC
210208
# elif __riscv_xlen == 64
211-
riscv64-linux-LIBC
209+
PLATFORM_TRIPLET=riscv64-linux-LIBC
212210
# else
213211
# error unknown platform triplet
214212
# endif
@@ -220,35 +218,35 @@
220218
*/
221219
#elif defined(__FreeBSD_kernel__)
222220
# if defined(__LP64__)
223-
x86_64-kfreebsd-gnu
221+
PLATFORM_TRIPLET=x86_64-kfreebsd-gnu
224222
# elif defined(__i386__)
225-
i386-kfreebsd-gnu
223+
PLATFORM_TRIPLET=i386-kfreebsd-gnu
226224
# else
227225
# error unknown platform triplet
228226
# endif
229227
#elif defined(__gnu_hurd__)
230-
i386-gnu
228+
PLATFORM_TRIPLET=i386-gnu
231229
#elif defined(__APPLE__)
232-
darwin
230+
PLATFORM_TRIPLET=darwin
233231
#elif defined(__VXWORKS__)
234-
vxworks
232+
PLATFORM_TRIPLET=vxworks
235233
#elif defined(__wasm32__)
236234
# if defined(__EMSCRIPTEN__)
237-
wasm32-emscripten
235+
PLATFORM_TRIPLET=wasm32-emscripten
238236
# elif defined(__wasi__)
239237
# if defined(_REENTRANT)
240-
wasm32-wasi-threads
238+
PLATFORM_TRIPLET=wasm32-wasi-threads
241239
# else
242-
wasm32-wasi
240+
PLATFORM_TRIPLET=wasm32-wasi
243241
# endif
244242
# else
245243
# error unknown wasm32 platform
246244
# endif
247245
#elif defined(__wasm64__)
248246
# if defined(__EMSCRIPTEN__)
249-
wasm64-emscripten
247+
PLATFORM_TRIPLET=wasm64-emscripten
250248
# elif defined(__wasi__)
251-
wasm64-wasi
249+
PLATFORM_TRIPLET=wasm64-wasi
252250
# else
253251
# error unknown wasm64 platform
254252
# endif

configure

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,8 @@ fi
922922

923923
AC_MSG_CHECKING([for the platform triplet based on compiler characteristics])
924924
if $CPP $CPPFLAGS $srcdir/Misc/platform_triplet.c >conftest.out 2>/dev/null; then
925-
PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | grep -v '^typedef' | tr -d ' '`
925+
PLATFORM_TRIPLET=`grep '^PLATFORM_TRIPLET=' conftest.out | tr -d ' '`
926+
PLATFORM_TRIPLET="${PLATFORM_TRIPLET#PLATFORM_TRIPLET=}"
926927
AC_MSG_RESULT([$PLATFORM_TRIPLET])
927928
else
928929
AC_MSG_RESULT([none])

0 commit comments

Comments
 (0)