Skip to content

Commit 1f6eebb

Browse files
committed
chore: Support C++26 toolchain on WASI
1 parent 26d1bb3 commit 1f6eebb

File tree

1 file changed

+49
-38
lines changed

1 file changed

+49
-38
lines changed

src/parser/cxx/wasm32_wasi_toolchain.cc

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ void Wasm32WasiToolchain::addSystemCppIncludePaths() {
7373

7474
void Wasm32WasiToolchain::addPredefinedMacros() {
7575
// clang-format off
76-
defineMacro("_Pragma(x)", "");
77-
defineMacro("__weak", "");
78-
defineMacro("__strong", "");
7976
defineMacro("__autoreleasing", "");
77+
defineMacro("__strong", "");
8078
defineMacro("__unsafe_unretained", "");
81-
defineMacro("_Nullable", "");
79+
defineMacro("__weak", "");
8280
defineMacro("_Nonnull", "");
81+
defineMacro("_Nullable", "");
82+
defineMacro("_Pragma(x)", "");
8383
defineMacro("_Thread_local", "thread_local");
8484

8585
defineMacro("_GNU_SOURCE", "1");
@@ -94,8 +94,8 @@ void Wasm32WasiToolchain::addPredefinedMacros() {
9494
defineMacro("__BITINT_MAXWIDTH__", "128");
9595
defineMacro("__BOOL_WIDTH__", "8");
9696
defineMacro("__BYTE_ORDER__", "__ORDER_LITTLE_ENDIAN__");
97-
defineMacro("__CHAR16_TYPE__", "unsigned short");
98-
defineMacro("__CHAR32_TYPE__", "unsigned int");
97+
defineMacro("__CHAR16_TYPE__", "unsigned");
98+
defineMacro("__CHAR32_TYPE__", "unsigned");
9999
defineMacro("__CHAR_BIT__", "8");
100100
defineMacro("__CLANG_ATOMIC_BOOL_LOCK_FREE", "2");
101101
defineMacro("__CLANG_ATOMIC_CHAR16_T_LOCK_FREE", "2");
@@ -193,22 +193,22 @@ void Wasm32WasiToolchain::addPredefinedMacros() {
193193
defineMacro("__INT64_FMTd__", "\"lld\"");
194194
defineMacro("__INT64_FMTi__", "\"lli\"");
195195
defineMacro("__INT64_MAX__", "9223372036854775807LL");
196-
defineMacro("__INT64_TYPE__", "long long int");
196+
defineMacro("__INT64_TYPE__", "long");
197197
defineMacro("__INT8_C_SUFFIX__", "");
198198
defineMacro("__INT8_FMTd__", "\"hhd\"");
199199
defineMacro("__INT8_FMTi__", "\"hhi\"");
200200
defineMacro("__INT8_MAX__", "127");
201-
defineMacro("__INT8_TYPE__", "signed char");
201+
defineMacro("__INT8_TYPE__", "signed");
202202
defineMacro("__INTMAX_C_SUFFIX__", "LL");
203203
defineMacro("__INTMAX_FMTd__", "\"lld\"");
204204
defineMacro("__INTMAX_FMTi__", "\"lli\"");
205205
defineMacro("__INTMAX_MAX__", "9223372036854775807LL");
206-
defineMacro("__INTMAX_TYPE__", "long long int");
206+
defineMacro("__INTMAX_TYPE__", "long");
207207
defineMacro("__INTMAX_WIDTH__", "64");
208208
defineMacro("__INTPTR_FMTd__", "\"ld\"");
209209
defineMacro("__INTPTR_FMTi__", "\"li\"");
210210
defineMacro("__INTPTR_MAX__", "2147483647L");
211-
defineMacro("__INTPTR_TYPE__", "long int");
211+
defineMacro("__INTPTR_TYPE__", "long");
212212
defineMacro("__INTPTR_WIDTH__", "32");
213213
defineMacro("__INT_FAST16_FMTd__", "\"hd\"");
214214
defineMacro("__INT_FAST16_FMTi__", "\"hi\"");
@@ -223,12 +223,12 @@ void Wasm32WasiToolchain::addPredefinedMacros() {
223223
defineMacro("__INT_FAST64_FMTd__", "\"lld\"");
224224
defineMacro("__INT_FAST64_FMTi__", "\"lli\"");
225225
defineMacro("__INT_FAST64_MAX__", "9223372036854775807LL");
226-
defineMacro("__INT_FAST64_TYPE__", "long long int");
226+
defineMacro("__INT_FAST64_TYPE__", "long");
227227
defineMacro("__INT_FAST64_WIDTH__", "64");
228228
defineMacro("__INT_FAST8_FMTd__", "\"hhd\"");
229229
defineMacro("__INT_FAST8_FMTi__", "\"hhi\"");
230230
defineMacro("__INT_FAST8_MAX__", "127");
231-
defineMacro("__INT_FAST8_TYPE__", "signed char");
231+
defineMacro("__INT_FAST8_TYPE__", "signed");
232232
defineMacro("__INT_FAST8_WIDTH__", "8");
233233
defineMacro("__INT_LEAST16_FMTd__", "\"hd\"");
234234
defineMacro("__INT_LEAST16_FMTi__", "\"hi\"");
@@ -243,12 +243,12 @@ void Wasm32WasiToolchain::addPredefinedMacros() {
243243
defineMacro("__INT_LEAST64_FMTd__", "\"lld\"");
244244
defineMacro("__INT_LEAST64_FMTi__", "\"lli\"");
245245
defineMacro("__INT_LEAST64_MAX__", "9223372036854775807LL");
246-
defineMacro("__INT_LEAST64_TYPE__", "long long int");
246+
defineMacro("__INT_LEAST64_TYPE__", "long");
247247
defineMacro("__INT_LEAST64_WIDTH__", "64");
248248
defineMacro("__INT_LEAST8_FMTd__", "\"hhd\"");
249249
defineMacro("__INT_LEAST8_FMTi__", "\"hhi\"");
250250
defineMacro("__INT_LEAST8_MAX__", "127");
251-
defineMacro("__INT_LEAST8_TYPE__", "signed char");
251+
defineMacro("__INT_LEAST8_TYPE__", "signed");
252252
defineMacro("__INT_LEAST8_WIDTH__", "8");
253253
defineMacro("__INT_MAX__", "2147483647");
254254
defineMacro("__INT_WIDTH__", "32");
@@ -271,6 +271,11 @@ void Wasm32WasiToolchain::addPredefinedMacros() {
271271
defineMacro("__LONG_LONG_MAX__", "9223372036854775807LL");
272272
defineMacro("__LONG_MAX__", "2147483647L");
273273
defineMacro("__LONG_WIDTH__", "32");
274+
defineMacro("__MEMORY_SCOPE_DEVICE", "1");
275+
defineMacro("__MEMORY_SCOPE_SINGLE", "4");
276+
defineMacro("__MEMORY_SCOPE_SYSTEM", "0");
277+
defineMacro("__MEMORY_SCOPE_WRKGRP", "2");
278+
defineMacro("__MEMORY_SCOPE_WVFRNT", "3");
274279
defineMacro("__NO_INLINE__", "1");
275280
defineMacro("__NO_MATH_ERRNO__", "1");
276281
defineMacro("__OBJC_BOOL_IS_BOOL", "0");
@@ -287,7 +292,7 @@ void Wasm32WasiToolchain::addPredefinedMacros() {
287292
defineMacro("__PTRDIFF_FMTd__", "\"ld\"");
288293
defineMacro("__PTRDIFF_FMTi__", "\"li\"");
289294
defineMacro("__PTRDIFF_MAX__", "2147483647L");
290-
defineMacro("__PTRDIFF_TYPE__", "long int");
295+
defineMacro("__PTRDIFF_TYPE__", "long");
291296
defineMacro("__PTRDIFF_WIDTH__", "32");
292297
defineMacro("__SCHAR_MAX__", "127");
293298
defineMacro("__SHRT_MAX__", "32767");
@@ -312,7 +317,7 @@ void Wasm32WasiToolchain::addPredefinedMacros() {
312317
defineMacro("__SIZE_FMTu__", "\"lu\"");
313318
defineMacro("__SIZE_FMTx__", "\"lx\"");
314319
defineMacro("__SIZE_MAX__", "4294967295UL");
315-
defineMacro("__SIZE_TYPE__", "long unsigned int");
320+
defineMacro("__SIZE_TYPE__", "long");
316321
defineMacro("__SIZE_WIDTH__", "32");
317322
defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__", "16UL");
318323
defineMacro("__STDC_HOSTED__", "1");
@@ -326,93 +331,93 @@ void Wasm32WasiToolchain::addPredefinedMacros() {
326331
defineMacro("__UINT16_FMTu__", "\"hu\"");
327332
defineMacro("__UINT16_FMTx__", "\"hx\"");
328333
defineMacro("__UINT16_MAX__", "65535");
329-
defineMacro("__UINT16_TYPE__", "unsigned short");
334+
defineMacro("__UINT16_TYPE__", "unsigned");
330335
defineMacro("__UINT32_C_SUFFIX__", "U");
331336
defineMacro("__UINT32_FMTX__", "\"X\"");
332337
defineMacro("__UINT32_FMTo__", "\"o\"");
333338
defineMacro("__UINT32_FMTu__", "\"u\"");
334339
defineMacro("__UINT32_FMTx__", "\"x\"");
335340
defineMacro("__UINT32_MAX__", "4294967295U");
336-
defineMacro("__UINT32_TYPE__", "unsigned int");
341+
defineMacro("__UINT32_TYPE__", "unsigned");
337342
defineMacro("__UINT64_C_SUFFIX__", "ULL");
338343
defineMacro("__UINT64_FMTX__", "\"llX\"");
339344
defineMacro("__UINT64_FMTo__", "\"llo\"");
340345
defineMacro("__UINT64_FMTu__", "\"llu\"");
341346
defineMacro("__UINT64_FMTx__", "\"llx\"");
342347
defineMacro("__UINT64_MAX__", "18446744073709551615ULL");
343-
defineMacro("__UINT64_TYPE__", "long long unsigned int");
348+
defineMacro("__UINT64_TYPE__", "long");
344349
defineMacro("__UINT8_C_SUFFIX__", "");
345350
defineMacro("__UINT8_FMTX__", "\"hhX\"");
346351
defineMacro("__UINT8_FMTo__", "\"hho\"");
347352
defineMacro("__UINT8_FMTu__", "\"hhu\"");
348353
defineMacro("__UINT8_FMTx__", "\"hhx\"");
349354
defineMacro("__UINT8_MAX__", "255");
350-
defineMacro("__UINT8_TYPE__", "unsigned char");
355+
defineMacro("__UINT8_TYPE__", "unsigned");
351356
defineMacro("__UINTMAX_C_SUFFIX__", "ULL");
352357
defineMacro("__UINTMAX_FMTX__", "\"llX\"");
353358
defineMacro("__UINTMAX_FMTo__", "\"llo\"");
354359
defineMacro("__UINTMAX_FMTu__", "\"llu\"");
355360
defineMacro("__UINTMAX_FMTx__", "\"llx\"");
356361
defineMacro("__UINTMAX_MAX__", "18446744073709551615ULL");
357-
defineMacro("__UINTMAX_TYPE__", "long long unsigned int");
362+
defineMacro("__UINTMAX_TYPE__", "long");
358363
defineMacro("__UINTMAX_WIDTH__", "64");
359364
defineMacro("__UINTPTR_FMTX__", "\"lX\"");
360365
defineMacro("__UINTPTR_FMTo__", "\"lo\"");
361366
defineMacro("__UINTPTR_FMTu__", "\"lu\"");
362367
defineMacro("__UINTPTR_FMTx__", "\"lx\"");
363368
defineMacro("__UINTPTR_MAX__", "4294967295UL");
364-
defineMacro("__UINTPTR_TYPE__", "long unsigned int");
369+
defineMacro("__UINTPTR_TYPE__", "long");
365370
defineMacro("__UINTPTR_WIDTH__", "32");
366371
defineMacro("__UINT_FAST16_FMTX__", "\"hX\"");
367372
defineMacro("__UINT_FAST16_FMTo__", "\"ho\"");
368373
defineMacro("__UINT_FAST16_FMTu__", "\"hu\"");
369374
defineMacro("__UINT_FAST16_FMTx__", "\"hx\"");
370375
defineMacro("__UINT_FAST16_MAX__", "65535");
371-
defineMacro("__UINT_FAST16_TYPE__", "unsigned short");
376+
defineMacro("__UINT_FAST16_TYPE__", "unsigned");
372377
defineMacro("__UINT_FAST32_FMTX__", "\"X\"");
373378
defineMacro("__UINT_FAST32_FMTo__", "\"o\"");
374379
defineMacro("__UINT_FAST32_FMTu__", "\"u\"");
375380
defineMacro("__UINT_FAST32_FMTx__", "\"x\"");
376381
defineMacro("__UINT_FAST32_MAX__", "4294967295U");
377-
defineMacro("__UINT_FAST32_TYPE__", "unsigned int");
382+
defineMacro("__UINT_FAST32_TYPE__", "unsigned");
378383
defineMacro("__UINT_FAST64_FMTX__", "\"llX\"");
379384
defineMacro("__UINT_FAST64_FMTo__", "\"llo\"");
380385
defineMacro("__UINT_FAST64_FMTu__", "\"llu\"");
381386
defineMacro("__UINT_FAST64_FMTx__", "\"llx\"");
382387
defineMacro("__UINT_FAST64_MAX__", "18446744073709551615ULL");
383-
defineMacro("__UINT_FAST64_TYPE__", "long long unsigned int");
388+
defineMacro("__UINT_FAST64_TYPE__", "long");
384389
defineMacro("__UINT_FAST8_FMTX__", "\"hhX\"");
385390
defineMacro("__UINT_FAST8_FMTo__", "\"hho\"");
386391
defineMacro("__UINT_FAST8_FMTu__", "\"hhu\"");
387392
defineMacro("__UINT_FAST8_FMTx__", "\"hhx\"");
388393
defineMacro("__UINT_FAST8_MAX__", "255");
389-
defineMacro("__UINT_FAST8_TYPE__", "unsigned char");
394+
defineMacro("__UINT_FAST8_TYPE__", "unsigned");
390395
defineMacro("__UINT_LEAST16_FMTX__", "\"hX\"");
391396
defineMacro("__UINT_LEAST16_FMTo__", "\"ho\"");
392397
defineMacro("__UINT_LEAST16_FMTu__", "\"hu\"");
393398
defineMacro("__UINT_LEAST16_FMTx__", "\"hx\"");
394399
defineMacro("__UINT_LEAST16_MAX__", "65535");
395-
defineMacro("__UINT_LEAST16_TYPE__", "unsigned short");
400+
defineMacro("__UINT_LEAST16_TYPE__", "unsigned");
396401
defineMacro("__UINT_LEAST32_FMTX__", "\"X\"");
397402
defineMacro("__UINT_LEAST32_FMTo__", "\"o\"");
398403
defineMacro("__UINT_LEAST32_FMTu__", "\"u\"");
399404
defineMacro("__UINT_LEAST32_FMTx__", "\"x\"");
400405
defineMacro("__UINT_LEAST32_MAX__", "4294967295U");
401-
defineMacro("__UINT_LEAST32_TYPE__", "unsigned int");
406+
defineMacro("__UINT_LEAST32_TYPE__", "unsigned");
402407
defineMacro("__UINT_LEAST64_FMTX__", "\"llX\"");
403408
defineMacro("__UINT_LEAST64_FMTo__", "\"llo\"");
404409
defineMacro("__UINT_LEAST64_FMTu__", "\"llu\"");
405410
defineMacro("__UINT_LEAST64_FMTx__", "\"llx\"");
406411
defineMacro("__UINT_LEAST64_MAX__", "18446744073709551615ULL");
407-
defineMacro("__UINT_LEAST64_TYPE__", "long long unsigned int");
412+
defineMacro("__UINT_LEAST64_TYPE__", "long");
408413
defineMacro("__UINT_LEAST8_FMTX__", "\"hhX\"");
409414
defineMacro("__UINT_LEAST8_FMTo__", "\"hho\"");
410415
defineMacro("__UINT_LEAST8_FMTu__", "\"hhu\"");
411416
defineMacro("__UINT_LEAST8_FMTx__", "\"hhx\"");
412417
defineMacro("__UINT_LEAST8_MAX__", "255");
413-
defineMacro("__UINT_LEAST8_TYPE__", "unsigned char");
418+
defineMacro("__UINT_LEAST8_TYPE__", "unsigned");
414419
defineMacro("__USER_LABEL_PREFIX__", "");
415-
defineMacro("__VERSION__", "\"Ubuntu Clang 17.0.6 (++20231209124227+6009708b4367-1~exp1~20231209124336.77)\"");
420+
defineMacro("__VERSION__", "\"Clang");
416421
defineMacro("__WCHAR_MAX__", "2147483647");
417422
defineMacro("__WCHAR_TYPE__", "int");
418423
defineMacro("__WCHAR_WIDTH__", "32");
@@ -421,25 +426,26 @@ void Wasm32WasiToolchain::addPredefinedMacros() {
421426
defineMacro("__WINT_WIDTH__", "32");
422427
defineMacro("__clang__", "1");
423428
defineMacro("__clang_literal_encoding__", "\"UTF-8\"");
424-
defineMacro("__clang_major__", "17");
425-
defineMacro("__clang_minor__", "0");
426-
defineMacro("__clang_patchlevel__", "6");
427-
defineMacro("__clang_version__", "\"17.0.6 (++20231209124227+6009708b4367-1~exp1~20231209124336.77)\"");
429+
defineMacro("__clang_major__", "18");
430+
defineMacro("__clang_minor__", "1");
431+
defineMacro("__clang_patchlevel__", "2");
432+
defineMacro("__clang_version__", "\"18.1.2-wasi-sdk");
428433
defineMacro("__clang_wide_literal_encoding__", "\"UTF-32\"");
429-
defineMacro("__cplusplus", "202002L");
434+
defineMacro("__cplusplus", "202400L");
430435
defineMacro("__cpp_aggregate_bases", "201603L");
431436
defineMacro("__cpp_aggregate_nsdmi", "201304L");
432437
defineMacro("__cpp_aggregate_paren_init", "201902L");
433438
defineMacro("__cpp_alias_templates", "200704L");
434439
defineMacro("__cpp_aligned_new", "201606L");
435440
defineMacro("__cpp_attributes", "200809L");
441+
defineMacro("__cpp_auto_cast", "202110L");
436442
defineMacro("__cpp_binary_literals", "201304L");
437443
defineMacro("__cpp_capture_star_this", "201603L");
438444
defineMacro("__cpp_char8_t", "202207L");
439445
defineMacro("__cpp_concepts", "201907L");
440446
defineMacro("__cpp_conditional_explicit", "201806L");
441447
defineMacro("__cpp_consteval", "202211L");
442-
defineMacro("__cpp_constexpr", "201907L");
448+
defineMacro("__cpp_constexpr", "202306L");
443449
defineMacro("__cpp_constexpr_dynamic_alloc", "201907L");
444450
defineMacro("__cpp_constexpr_in_decltype", "201711L");
445451
defineMacro("__cpp_constinit", "201907L");
@@ -455,29 +461,34 @@ void Wasm32WasiToolchain::addPredefinedMacros() {
455461
defineMacro("__cpp_generic_lambdas", "201707L");
456462
defineMacro("__cpp_guaranteed_copy_elision", "201606L");
457463
defineMacro("__cpp_hex_float", "201603L");
464+
defineMacro("__cpp_if_consteval", "202106L");
458465
defineMacro("__cpp_if_constexpr", "201606L");
459466
defineMacro("__cpp_impl_coroutine", "201902L");
460467
defineMacro("__cpp_impl_destroying_delete", "201806L");
461468
defineMacro("__cpp_impl_three_way_comparison", "201907L");
469+
defineMacro("__cpp_implicit_move", "202011L");
462470
defineMacro("__cpp_inheriting_constructors", "201511L");
463471
defineMacro("__cpp_init_captures", "201803L");
464472
defineMacro("__cpp_initializer_lists", "200806L");
465473
defineMacro("__cpp_inline_variables", "201606L");
466474
defineMacro("__cpp_lambdas", "200907L");
475+
defineMacro("__cpp_multidimensional_subscript", "202211L");
467476
defineMacro("__cpp_named_character_escapes", "202207L");
468477
defineMacro("__cpp_namespace_attributes", "201411L");
469478
defineMacro("__cpp_nested_namespace_definitions", "201411L");
470479
defineMacro("__cpp_noexcept_function_type", "201510L");
471480
defineMacro("__cpp_nontype_template_args", "201411L");
472481
defineMacro("__cpp_nontype_template_parameter_auto", "201606L");
473482
defineMacro("__cpp_nsdmi", "200809L");
483+
defineMacro("__cpp_placeholder_variables", "202306L");
474484
defineMacro("__cpp_range_based_for", "201603L");
475485
defineMacro("__cpp_raw_strings", "200710L");
476486
defineMacro("__cpp_ref_qualifiers", "200710L");
477487
defineMacro("__cpp_return_type_deduction", "201304L");
478488
defineMacro("__cpp_rtti", "199711L");
479489
defineMacro("__cpp_rvalue_references", "200610L");
480-
defineMacro("__cpp_static_assert", "201411L");
490+
defineMacro("__cpp_size_t_suffix", "202011L");
491+
defineMacro("__cpp_static_assert", "202306L");
481492
defineMacro("__cpp_static_call_operator", "202207L");
482493
defineMacro("__cpp_structured_bindings", "201606L");
483494
defineMacro("__cpp_template_auto", "201606L");

0 commit comments

Comments
 (0)