Skip to content

Commit 41b2c6d

Browse files
authored
Show wasm proposals status during compilation and execution (#3989)
- add default build configuration options and enhance message output for WAMR features - Add Wasm proposal status printing functionality
1 parent c6712b4 commit 41b2c6d

File tree

4 files changed

+159
-48
lines changed

4 files changed

+159
-48
lines changed

build-scripts/config_common.cmake

+106-47
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,61 @@ if (NOT DEFINED WAMR_BUILD_SHRUNK_MEMORY)
167167
set (WAMR_BUILD_SHRUNK_MEMORY 1)
168168
endif ()
169169

170+
########################################
171+
# Default values
172+
########################################
173+
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
174+
set (WAMR_BUILD_BULK_MEMORY 1)
175+
endif ()
176+
177+
if (NOT DEFINED WAMR_BUILD_EXCE_HANDLING)
178+
set (WAMR_BUILD_EXCE_HANDLING 0)
179+
endif ()
180+
181+
if (NOT DEFINED WAMR_BUILD_GC)
182+
set (WAMR_BUILD_GC 0)
183+
endif ()
184+
185+
if (NOT DEFINED WAMR_BUILD_MEMORY64)
186+
set (WAMR_BUILD_MEMORY64 0)
187+
endif ()
188+
189+
if (NOT DEFINED WAMR_BUILD_MULTI_MEMORY)
190+
set (WAMR_BUILD_MULTI_MEMORY 0)
191+
endif ()
192+
193+
if (NOT DEFINED WAMR_BUILD_SHARED_MEMORY)
194+
set(WAMR_BUILD_SHARED_MEMORY 0)
195+
endif ()
196+
197+
if (NOT DEFINED WAMR_BUILD_STRINGREF)
198+
set(WAMR_BUILD_STRINGREF 0)
199+
endif ()
200+
201+
if (NOT DEFINED WAMR_BUILD_TAIL_CALL)
202+
set (WAMR_BUILD_TAIL_CALL 0)
203+
endif ()
204+
205+
########################################
206+
# Compilation options to marco
170207
########################################
171208

172209
message ("-- Build Configurations:")
173210
message (" Build as target ${WAMR_BUILD_TARGET}")
174211
message (" CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
212+
################## running mode ##################
175213
if (WAMR_BUILD_INTERP EQUAL 1)
176214
message (" WAMR Interpreter enabled")
177215
else ()
178216
message (" WAMR Interpreter disabled")
179217
endif ()
218+
if ((WAMR_BUILD_FAST_INTERP EQUAL 1) AND (WAMR_BUILD_INTERP EQUAL 1))
219+
add_definitions (-DWASM_ENABLE_FAST_INTERP=1)
220+
message (" Fast interpreter enabled")
221+
else ()
222+
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
223+
message (" Fast interpreter disabled")
224+
endif ()
180225
if (WAMR_BUILD_AOT EQUAL 1)
181226
message (" WAMR AOT enabled")
182227
else ()
@@ -207,6 +252,16 @@ if (WAMR_BUILD_FAST_JIT EQUAL 1 AND WAMR_BUILD_JIT EQUAL 1
207252
AND WAMR_BUILD_LAZY_JIT EQUAL 1)
208253
message (" Multi-tier JIT enabled")
209254
endif ()
255+
################## test modes ##################
256+
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
257+
add_definitions (-DWASM_ENABLE_SPEC_TEST=1)
258+
message (" spec test compatible mode is on")
259+
endif ()
260+
if (WAMR_BUILD_WASI_TEST EQUAL 1)
261+
add_definitions (-DWASM_ENABLE_WASI_TEST=1)
262+
message (" wasi test compatible mode is on")
263+
endif ()
264+
################## native ##################
210265
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
211266
message (" Libc builtin enabled")
212267
else ()
@@ -219,38 +274,36 @@ elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
219274
else ()
220275
message (" Libc WASI disabled")
221276
endif ()
222-
if ((WAMR_BUILD_FAST_INTERP EQUAL 1) AND (WAMR_BUILD_INTERP EQUAL 1))
223-
add_definitions (-DWASM_ENABLE_FAST_INTERP=1)
224-
message (" Fast interpreter enabled")
225-
else ()
226-
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
227-
message (" Fast interpreter disabled")
277+
if (WAMR_BUILD_THREAD_MGR EQUAL 1)
278+
message (" Thread manager enabled")
279+
endif ()
280+
if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
281+
message (" Lib pthread enabled")
228282
endif ()
283+
if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1)
284+
message (" Lib pthread semaphore enabled")
285+
endif ()
286+
if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1)
287+
message (" Lib wasi-threads enabled")
288+
endif ()
289+
if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
290+
message (" Libc emcc enabled")
291+
endif ()
292+
if (WAMR_BUILD_LIB_RATS EQUAL 1)
293+
message (" Lib rats enabled")
294+
endif()
295+
################## WAMR features ##################
229296
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
230297
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
231298
message (" Multiple modules enabled")
232299
else ()
233300
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
234301
message (" Multiple modules disabled")
235302
endif ()
236-
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
237-
add_definitions (-DWASM_ENABLE_SPEC_TEST=1)
238-
message (" spec test compatible mode is on")
239-
endif ()
240-
if (WAMR_BUILD_WASI_TEST EQUAL 1)
241-
add_definitions (-DWASM_ENABLE_WASI_TEST=1)
242-
message (" wasi test compatible mode is on")
243-
endif ()
244-
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
245-
# Enable bulk memory by default
246-
set (WAMR_BUILD_BULK_MEMORY 1)
247-
endif ()
248303
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
249304
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
250-
message (" Bulk memory feature enabled")
251305
else ()
252306
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
253-
message (" Bulk memory feature disabled")
254307
endif ()
255308
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
256309
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
@@ -270,31 +323,11 @@ if (WAMR_BUILD_MEMORY64 EQUAL 1)
270323
endif()
271324
add_definitions (-DWASM_ENABLE_MEMORY64=1)
272325
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
273-
message (" Memory64 memory enabled")
274326
endif ()
275327
if (WAMR_BUILD_MULTI_MEMORY EQUAL 1)
276328
add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1)
277-
message (" Multi memory enabled")
278329
set (WAMR_BUILD_DEBUG_INTERP 0)
279330
endif ()
280-
if (WAMR_BUILD_THREAD_MGR EQUAL 1)
281-
message (" Thread manager enabled")
282-
endif ()
283-
if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
284-
message (" Lib pthread enabled")
285-
endif ()
286-
if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1)
287-
message (" Lib pthread semaphore enabled")
288-
endif ()
289-
if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1)
290-
message (" Lib wasi-threads enabled")
291-
endif ()
292-
if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
293-
message (" Libc emcc enabled")
294-
endif ()
295-
if (WAMR_BUILD_LIB_RATS EQUAL 1)
296-
message (" Lib rats enabled")
297-
endif()
298331
if (WAMR_BUILD_MINI_LOADER EQUAL 1)
299332
add_definitions (-DWASM_ENABLE_MINI_LOADER=1)
300333
message (" WASM mini loader enabled")
@@ -324,7 +357,6 @@ endif ()
324357
if (WAMR_BUILD_SIMD EQUAL 1)
325358
if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*")
326359
add_definitions (-DWASM_ENABLE_SIMD=1)
327-
message (" SIMD enabled")
328360
else ()
329361
message (" SIMD disabled due to not supported on target RISCV64")
330362
endif ()
@@ -354,16 +386,11 @@ if (WAMR_BUILD_DUMP_CALL_STACK EQUAL 1)
354386
endif ()
355387
if (WAMR_BUILD_TAIL_CALL EQUAL 1)
356388
add_definitions (-DWASM_ENABLE_TAIL_CALL=1)
357-
message (" Tail call enabled")
358389
endif ()
359390
if (WAMR_BUILD_REF_TYPES EQUAL 1)
360391
add_definitions (-DWASM_ENABLE_REF_TYPES=1)
361-
message (" Reference types enabled")
362-
else ()
363-
message (" Reference types disabled")
364392
endif ()
365393
if (WAMR_BUILD_GC EQUAL 1)
366-
message (" GC enabled")
367394
if (WAMR_TEST_GC EQUAL 1)
368395
message(" GC testing enabled")
369396
endif()
@@ -375,7 +402,6 @@ else ()
375402
message (" GC performance profiling disabled")
376403
endif ()
377404
if (WAMR_BUILD_STRINGREF EQUAL 1)
378-
message (" Stringref enabled")
379405
if (NOT DEFINED WAMR_STRINGREF_IMPL_SOURCE)
380406
message (" Using WAMR builtin implementation for stringref")
381407
else ()
@@ -615,3 +641,36 @@ if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1)
615641
message (" AOT validator enabled")
616642
add_definitions (-DWASM_ENABLE_AOT_VALIDATOR=1)
617643
endif ()
644+
645+
########################################
646+
# Show Phase4 Wasm proposals status.
647+
########################################
648+
649+
message (
650+
"-- About Wasm Proposals:\n"
651+
" Always-on:\n"
652+
" \"Extended Constant Expressions\"\n"
653+
" \"Multi-value\"\n"
654+
" \"Non-trapping float-to-int conversions\"\n"
655+
" \"Sign-extension operators\"\n"
656+
" \"WebAssembly C and C++ API\"\n"
657+
" Configurable. 0 is OFF. 1 is ON:\n"
658+
" \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n"
659+
" \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
660+
" \"Garbage collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
661+
" \"Legacy Exception handling\" via WAMR_BUILD_EXCE_HANDLING: ${WAMR_BUILD_EXCE_HANDLING}\n"
662+
" \"Memory64\" via WAMR_BUILD_MEMORY64: ${WAMR_BUILD_MEMORY64}\n"
663+
" \"Multiple memories\" via WAMR_BUILD_MULTI_MEMORY: ${WAMR_BUILD_MULTI_MEMORY}\n"
664+
" \"Reference Types\" via WAMR_BUILD_REF_TYPES: ${WAMR_BUILD_REF_TYPES}\n"
665+
" \"Reference-Typed Strings\" via WAMR_BUILD_STRINGREF: ${WAMR_BUILD_STRINGREF}\n"
666+
" \"Tail call\" via WAMR_BUILD_TAIL_CALL: ${WAMR_BUILD_TAIL_CALL}\n"
667+
" \"Threads\" via WAMR_BUILD_SHARED_MEMORY: ${WAMR_BUILD_SHARED_MEMORY}\n"
668+
" \"Typed Function References\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
669+
" Unsupported (>= Phase4):\n"
670+
" \"Branch Hinting\"\n"
671+
" \"Custom Annotation Syntax in the Text Format\"\n"
672+
" \"Exception handling\"\n"
673+
" \"Import/Export of Mutable Globals\"\n"
674+
" \"JS String Builtins\"\n"
675+
" \"Relaxed SIMD\"\n"
676+
)

doc/stability_wasm_proposals.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Users can turn those features on or off by using compilation options. If a relev
3535
| Multiple memories[^3] | Yes | `WAMR_BUILD_MULTI_MEMORY` |
3636
| Reference-Typed Strings | No | `WAMR_BUILD_STRINGREF` |
3737
| Tail call | Yes | `WAMR_BUILD_TAIL_CALL` |
38-
| Thread[^4] | Yes | `WAMR_BUILD_SHARED_MEMORY` |
38+
| Threads[^4] | Yes | `WAMR_BUILD_SHARED_MEMORY` |
3939
| Typed Function References | Yes | `WAMR_BUILD_GC` |
4040

4141
[^2]:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (C) 2023 Amazon.com Inc. or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
*/
5+
6+
#include <stdio.h>
7+
8+
void
9+
wasm_proposal_print_status(void)
10+
{
11+
printf("About Wasm Proposals:\n");
12+
printf(" Always-on:\n");
13+
printf(" - Extended Constant Expressions\n");
14+
printf(" - Multi-value\n");
15+
printf(" - Non-trapping float-to-int conversions\n");
16+
printf(" - Sign-extension operators\n");
17+
printf(" - WebAssembly C and C++ API\n");
18+
printf(" Compilation Configurable. 0 is OFF. 1 is ON:\n");
19+
printf(" - Bulk Memory Operation via WASM_ENABLE_BULK_MEMORY: %u\n",
20+
WASM_ENABLE_BULK_MEMORY);
21+
printf(" - Fixed-Width SIMD via WASM_ENABLE_SIMD: %u\n",
22+
WASM_ENABLE_SIMD);
23+
printf(" - Garbage Collection via WASM_ENABLE_GC: %u\n", WASM_ENABLE_GC);
24+
printf(
25+
" - Legacy Exception Handling via WASM_ENABLE_EXCE_HANDLING: %u\n",
26+
WASM_ENABLE_EXCE_HANDLING);
27+
printf(" - Memory64 via WASM_ENABLE_MEMORY64: %u\n",
28+
WASM_ENABLE_MEMORY64);
29+
printf(" - Multiple Memory via WASM_ENABLE_MULTI_MEMORY: %u\n",
30+
WASM_ENABLE_MULTI_MEMORY);
31+
printf(" - Reference Types via WASM_ENABLE_REF_TYPES: %u\n",
32+
WASM_ENABLE_REF_TYPES);
33+
printf(" - Reference-Typed Strings via WASM_ENABLE_REF_TYPES: %u\n",
34+
WASM_ENABLE_REF_TYPES);
35+
printf(" - Tail Call via WASM_ENABLE_TAIL_CALL: %u\n",
36+
WASM_ENABLE_TAIL_CALL);
37+
printf(" - Threads via WASM_ENABLE_SHARED_MEMORY: %u\n",
38+
WASM_ENABLE_SHARED_MEMORY);
39+
printf(" - Typed Function References via WASM_ENABLE_GC: %u\n",
40+
WASM_ENABLE_GC);
41+
printf(" Unsupported (>= Phase4):\n");
42+
printf(" - Branch Hinting\n");
43+
printf(" - Custom Annotation Syntax in the Text Format\n");
44+
printf(" - Exception handling\n");
45+
printf(" - Import/Export of Mutable Globals\n");
46+
printf(" - JS String Builtins\n");
47+
printf(" - Relaxed SIMD\n");
48+
}

product-mini/platforms/posix/main.c

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "../common/libc_wasi.c"
1919
#endif
2020

21+
#include "../common/wasm_proposal.c"
22+
2123
#if BH_HAS_DLFCN
2224
#include <dlfcn.h>
2325
#endif
@@ -798,6 +800,8 @@ main(int argc, char *argv[])
798800
wasm_runtime_get_version(&major, &minor, &patch);
799801
printf("iwasm %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", major, minor,
800802
patch);
803+
printf("\n");
804+
wasm_proposal_print_status();
801805
return 0;
802806
}
803807
else {

0 commit comments

Comments
 (0)