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
This commit is contained in:
liang.he 2025-02-05 15:28:26 +08:00 committed by GitHub
parent c6712b4033
commit 41b2c6d0d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 177 additions and 66 deletions

View File

@ -167,16 +167,61 @@ if (NOT DEFINED WAMR_BUILD_SHRUNK_MEMORY)
set (WAMR_BUILD_SHRUNK_MEMORY 1) set (WAMR_BUILD_SHRUNK_MEMORY 1)
endif () endif ()
########################################
# Default values
########################################
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
set (WAMR_BUILD_BULK_MEMORY 1)
endif ()
if (NOT DEFINED WAMR_BUILD_EXCE_HANDLING)
set (WAMR_BUILD_EXCE_HANDLING 0)
endif ()
if (NOT DEFINED WAMR_BUILD_GC)
set (WAMR_BUILD_GC 0)
endif ()
if (NOT DEFINED WAMR_BUILD_MEMORY64)
set (WAMR_BUILD_MEMORY64 0)
endif ()
if (NOT DEFINED WAMR_BUILD_MULTI_MEMORY)
set (WAMR_BUILD_MULTI_MEMORY 0)
endif ()
if (NOT DEFINED WAMR_BUILD_SHARED_MEMORY)
set(WAMR_BUILD_SHARED_MEMORY 0)
endif ()
if (NOT DEFINED WAMR_BUILD_STRINGREF)
set(WAMR_BUILD_STRINGREF 0)
endif ()
if (NOT DEFINED WAMR_BUILD_TAIL_CALL)
set (WAMR_BUILD_TAIL_CALL 0)
endif ()
########################################
# Compilation options to marco
######################################## ########################################
message ("-- Build Configurations:") message ("-- Build Configurations:")
message (" Build as target ${WAMR_BUILD_TARGET}") message (" Build as target ${WAMR_BUILD_TARGET}")
message (" CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE}) message (" CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
################## running mode ##################
if (WAMR_BUILD_INTERP EQUAL 1) if (WAMR_BUILD_INTERP EQUAL 1)
message (" WAMR Interpreter enabled") message (" WAMR Interpreter enabled")
else () else ()
message (" WAMR Interpreter disabled") message (" WAMR Interpreter disabled")
endif () endif ()
if ((WAMR_BUILD_FAST_INTERP EQUAL 1) AND (WAMR_BUILD_INTERP EQUAL 1))
add_definitions (-DWASM_ENABLE_FAST_INTERP=1)
message (" Fast interpreter enabled")
else ()
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
message (" Fast interpreter disabled")
endif ()
if (WAMR_BUILD_AOT EQUAL 1) if (WAMR_BUILD_AOT EQUAL 1)
message (" WAMR AOT enabled") message (" WAMR AOT enabled")
else () else ()
@ -207,6 +252,16 @@ if (WAMR_BUILD_FAST_JIT EQUAL 1 AND WAMR_BUILD_JIT EQUAL 1
AND WAMR_BUILD_LAZY_JIT EQUAL 1) AND WAMR_BUILD_LAZY_JIT EQUAL 1)
message (" Multi-tier JIT enabled") message (" Multi-tier JIT enabled")
endif () endif ()
################## test modes ##################
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
add_definitions (-DWASM_ENABLE_SPEC_TEST=1)
message (" spec test compatible mode is on")
endif ()
if (WAMR_BUILD_WASI_TEST EQUAL 1)
add_definitions (-DWASM_ENABLE_WASI_TEST=1)
message (" wasi test compatible mode is on")
endif ()
################## native ##################
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1) if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
message (" Libc builtin enabled") message (" Libc builtin enabled")
else () else ()
@ -219,64 +274,6 @@ elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
else () else ()
message (" Libc WASI disabled") message (" Libc WASI disabled")
endif () endif ()
if ((WAMR_BUILD_FAST_INTERP EQUAL 1) AND (WAMR_BUILD_INTERP EQUAL 1))
add_definitions (-DWASM_ENABLE_FAST_INTERP=1)
message (" Fast interpreter enabled")
else ()
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
message (" Fast interpreter disabled")
endif ()
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
message (" Multiple modules enabled")
else ()
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
message (" Multiple modules disabled")
endif ()
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
add_definitions (-DWASM_ENABLE_SPEC_TEST=1)
message (" spec test compatible mode is on")
endif ()
if (WAMR_BUILD_WASI_TEST EQUAL 1)
add_definitions (-DWASM_ENABLE_WASI_TEST=1)
message (" wasi test compatible mode is on")
endif ()
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
# Enable bulk memory by default
set (WAMR_BUILD_BULK_MEMORY 1)
endif ()
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
message (" Bulk memory feature enabled")
else ()
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
message (" Bulk memory feature disabled")
endif ()
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
message (" Shared memory enabled")
else ()
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0)
endif ()
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
message (" Shared heap enabled")
endif()
if (WAMR_BUILD_MEMORY64 EQUAL 1)
# if native is 32-bit or cross-compiled to 32-bit
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")
message (FATAL_ERROR "-- Memory64 is only available on the 64-bit platform/target")
endif()
add_definitions (-DWASM_ENABLE_MEMORY64=1)
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
message (" Memory64 memory enabled")
endif ()
if (WAMR_BUILD_MULTI_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1)
message (" Multi memory enabled")
set (WAMR_BUILD_DEBUG_INTERP 0)
endif ()
if (WAMR_BUILD_THREAD_MGR EQUAL 1) if (WAMR_BUILD_THREAD_MGR EQUAL 1)
message (" Thread manager enabled") message (" Thread manager enabled")
endif () endif ()
@ -295,6 +292,42 @@ endif ()
if (WAMR_BUILD_LIB_RATS EQUAL 1) if (WAMR_BUILD_LIB_RATS EQUAL 1)
message (" Lib rats enabled") message (" Lib rats enabled")
endif() endif()
################## WAMR features ##################
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
message (" Multiple modules enabled")
else ()
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
message (" Multiple modules disabled")
endif ()
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
else ()
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
endif ()
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
message (" Shared memory enabled")
else ()
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0)
endif ()
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
message (" Shared heap enabled")
endif()
if (WAMR_BUILD_MEMORY64 EQUAL 1)
# if native is 32-bit or cross-compiled to 32-bit
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")
message (FATAL_ERROR "-- Memory64 is only available on the 64-bit platform/target")
endif()
add_definitions (-DWASM_ENABLE_MEMORY64=1)
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
endif ()
if (WAMR_BUILD_MULTI_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1)
set (WAMR_BUILD_DEBUG_INTERP 0)
endif ()
if (WAMR_BUILD_MINI_LOADER EQUAL 1) if (WAMR_BUILD_MINI_LOADER EQUAL 1)
add_definitions (-DWASM_ENABLE_MINI_LOADER=1) add_definitions (-DWASM_ENABLE_MINI_LOADER=1)
message (" WASM mini loader enabled") message (" WASM mini loader enabled")
@ -324,7 +357,6 @@ endif ()
if (WAMR_BUILD_SIMD EQUAL 1) if (WAMR_BUILD_SIMD EQUAL 1)
if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*") if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*")
add_definitions (-DWASM_ENABLE_SIMD=1) add_definitions (-DWASM_ENABLE_SIMD=1)
message (" SIMD enabled")
else () else ()
message (" SIMD disabled due to not supported on target RISCV64") message (" SIMD disabled due to not supported on target RISCV64")
endif () endif ()
@ -354,16 +386,11 @@ if (WAMR_BUILD_DUMP_CALL_STACK EQUAL 1)
endif () endif ()
if (WAMR_BUILD_TAIL_CALL EQUAL 1) if (WAMR_BUILD_TAIL_CALL EQUAL 1)
add_definitions (-DWASM_ENABLE_TAIL_CALL=1) add_definitions (-DWASM_ENABLE_TAIL_CALL=1)
message (" Tail call enabled")
endif () endif ()
if (WAMR_BUILD_REF_TYPES EQUAL 1) if (WAMR_BUILD_REF_TYPES EQUAL 1)
add_definitions (-DWASM_ENABLE_REF_TYPES=1) add_definitions (-DWASM_ENABLE_REF_TYPES=1)
message (" Reference types enabled")
else ()
message (" Reference types disabled")
endif () endif ()
if (WAMR_BUILD_GC EQUAL 1) if (WAMR_BUILD_GC EQUAL 1)
message (" GC enabled")
if (WAMR_TEST_GC EQUAL 1) if (WAMR_TEST_GC EQUAL 1)
message(" GC testing enabled") message(" GC testing enabled")
endif() endif()
@ -375,7 +402,6 @@ else ()
message (" GC performance profiling disabled") message (" GC performance profiling disabled")
endif () endif ()
if (WAMR_BUILD_STRINGREF EQUAL 1) if (WAMR_BUILD_STRINGREF EQUAL 1)
message (" Stringref enabled")
if (NOT DEFINED WAMR_STRINGREF_IMPL_SOURCE) if (NOT DEFINED WAMR_STRINGREF_IMPL_SOURCE)
message (" Using WAMR builtin implementation for stringref") message (" Using WAMR builtin implementation for stringref")
else () else ()
@ -615,3 +641,36 @@ if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1)
message (" AOT validator enabled") message (" AOT validator enabled")
add_definitions (-DWASM_ENABLE_AOT_VALIDATOR=1) add_definitions (-DWASM_ENABLE_AOT_VALIDATOR=1)
endif () endif ()
########################################
# Show Phase4 Wasm proposals status.
########################################
message (
"-- About Wasm Proposals:\n"
" Always-on:\n"
" \"Extended Constant Expressions\"\n"
" \"Multi-value\"\n"
" \"Non-trapping float-to-int conversions\"\n"
" \"Sign-extension operators\"\n"
" \"WebAssembly C and C++ API\"\n"
" Configurable. 0 is OFF. 1 is ON:\n"
" \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n"
" \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
" \"Garbage collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
" \"Legacy Exception handling\" via WAMR_BUILD_EXCE_HANDLING: ${WAMR_BUILD_EXCE_HANDLING}\n"
" \"Memory64\" via WAMR_BUILD_MEMORY64: ${WAMR_BUILD_MEMORY64}\n"
" \"Multiple memories\" via WAMR_BUILD_MULTI_MEMORY: ${WAMR_BUILD_MULTI_MEMORY}\n"
" \"Reference Types\" via WAMR_BUILD_REF_TYPES: ${WAMR_BUILD_REF_TYPES}\n"
" \"Reference-Typed Strings\" via WAMR_BUILD_STRINGREF: ${WAMR_BUILD_STRINGREF}\n"
" \"Tail call\" via WAMR_BUILD_TAIL_CALL: ${WAMR_BUILD_TAIL_CALL}\n"
" \"Threads\" via WAMR_BUILD_SHARED_MEMORY: ${WAMR_BUILD_SHARED_MEMORY}\n"
" \"Typed Function References\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
" Unsupported (>= Phase4):\n"
" \"Branch Hinting\"\n"
" \"Custom Annotation Syntax in the Text Format\"\n"
" \"Exception handling\"\n"
" \"Import/Export of Mutable Globals\"\n"
" \"JS String Builtins\"\n"
" \"Relaxed SIMD\"\n"
)

View File

@ -35,7 +35,7 @@ Users can turn those features on or off by using compilation options. If a relev
| Multiple memories[^3] | Yes | `WAMR_BUILD_MULTI_MEMORY` | | Multiple memories[^3] | Yes | `WAMR_BUILD_MULTI_MEMORY` |
| Reference-Typed Strings | No | `WAMR_BUILD_STRINGREF` | | Reference-Typed Strings | No | `WAMR_BUILD_STRINGREF` |
| Tail call | Yes | `WAMR_BUILD_TAIL_CALL` | | Tail call | Yes | `WAMR_BUILD_TAIL_CALL` |
| Thread[^4] | Yes | `WAMR_BUILD_SHARED_MEMORY` | | Threads[^4] | Yes | `WAMR_BUILD_SHARED_MEMORY` |
| Typed Function References | Yes | `WAMR_BUILD_GC` | | Typed Function References | Yes | `WAMR_BUILD_GC` |
[^2]: [^2]:

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2023 Amazon.com Inc. or its affiliates. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include <stdio.h>
void
wasm_proposal_print_status(void)
{
printf("About Wasm Proposals:\n");
printf(" Always-on:\n");
printf(" - Extended Constant Expressions\n");
printf(" - Multi-value\n");
printf(" - Non-trapping float-to-int conversions\n");
printf(" - Sign-extension operators\n");
printf(" - WebAssembly C and C++ API\n");
printf(" Compilation Configurable. 0 is OFF. 1 is ON:\n");
printf(" - Bulk Memory Operation via WASM_ENABLE_BULK_MEMORY: %u\n",
WASM_ENABLE_BULK_MEMORY);
printf(" - Fixed-Width SIMD via WASM_ENABLE_SIMD: %u\n",
WASM_ENABLE_SIMD);
printf(" - Garbage Collection via WASM_ENABLE_GC: %u\n", WASM_ENABLE_GC);
printf(
" - Legacy Exception Handling via WASM_ENABLE_EXCE_HANDLING: %u\n",
WASM_ENABLE_EXCE_HANDLING);
printf(" - Memory64 via WASM_ENABLE_MEMORY64: %u\n",
WASM_ENABLE_MEMORY64);
printf(" - Multiple Memory via WASM_ENABLE_MULTI_MEMORY: %u\n",
WASM_ENABLE_MULTI_MEMORY);
printf(" - Reference Types via WASM_ENABLE_REF_TYPES: %u\n",
WASM_ENABLE_REF_TYPES);
printf(" - Reference-Typed Strings via WASM_ENABLE_REF_TYPES: %u\n",
WASM_ENABLE_REF_TYPES);
printf(" - Tail Call via WASM_ENABLE_TAIL_CALL: %u\n",
WASM_ENABLE_TAIL_CALL);
printf(" - Threads via WASM_ENABLE_SHARED_MEMORY: %u\n",
WASM_ENABLE_SHARED_MEMORY);
printf(" - Typed Function References via WASM_ENABLE_GC: %u\n",
WASM_ENABLE_GC);
printf(" Unsupported (>= Phase4):\n");
printf(" - Branch Hinting\n");
printf(" - Custom Annotation Syntax in the Text Format\n");
printf(" - Exception handling\n");
printf(" - Import/Export of Mutable Globals\n");
printf(" - JS String Builtins\n");
printf(" - Relaxed SIMD\n");
}

View File

@ -18,6 +18,8 @@
#include "../common/libc_wasi.c" #include "../common/libc_wasi.c"
#endif #endif
#include "../common/wasm_proposal.c"
#if BH_HAS_DLFCN #if BH_HAS_DLFCN
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
@ -798,6 +800,8 @@ main(int argc, char *argv[])
wasm_runtime_get_version(&major, &minor, &patch); wasm_runtime_get_version(&major, &minor, &patch);
printf("iwasm %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", major, minor, printf("iwasm %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", major, minor,
patch); patch);
printf("\n");
wasm_proposal_print_status();
return 0; return 0;
} }
else { else {