Skip to content

Commit 4952c2a

Browse files
committed
feat: add support for checking unsupported build configurations
1 parent 4b42cfd commit 4952c2a

File tree

4 files changed

+137
-0
lines changed

4 files changed

+137
-0
lines changed

build-scripts/config_common.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ if (WAMR_BUILD_REF_TYPES EQUAL 1)
282282
set (WAMR_BUILD_CALL_INDIRECT_OVERLONG 1)
283283
endif ()
284284

285+
include(${CMAKE_CURRENT_LIST_DIR}/unsupported_combination.cmake)
286+
285287
message ("-- Build Configurations:")
286288
message (" Build as target ${WAMR_BUILD_TARGET}")
287289
message (" Build for platform ${WAMR_BUILD_PLATFORM}")
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
# Define a function to check for unsupported combinations
5+
function(check_aot_mode_error error_message)
6+
if(WAMR_BUILD_AOT EQUAL 1)
7+
message(FATAL_ERROR "${error_message}")
8+
endif()
9+
endfunction()
10+
11+
# Define a function to check for unsupported combinations with CLASSIC_INTERP
12+
function(check_classic_interp_error error_message)
13+
if(WAMR_BUILD_INTERP EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 0)
14+
message(FATAL_ERROR "${error_message}")
15+
endif()
16+
endfunction()
17+
18+
# Define a function to check for unsupported combinations with FAST_INTERP
19+
function(check_fast_interp_error error_message)
20+
if(WAMR_BUILD_INTERP EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1)
21+
message(FATAL_ERROR "${error_message}")
22+
endif()
23+
endfunction()
24+
25+
# Define a function to check for unsupported combinations with FAST_JIT
26+
function(check_fast_jit_error error_message)
27+
if(WAMR_BUILD_FAST_JIT EQUAL 1)
28+
message(FATAL_ERROR "${error_message}")
29+
endif()
30+
endfunction()
31+
32+
# Define a function to check for unsupported combinations with LLVM_JIT
33+
function(check_llvm_jit_error error_message)
34+
if(WAMR_BUILD_JIT EQUAL 1)
35+
message(FATAL_ERROR "${error_message}")
36+
endif()
37+
endfunction()
38+
39+
# Below are the unsupported combinations checks
40+
# Please keep this list in sync with tests/unit/unsupported-features/CMakeLists.txt
41+
# and tests/wamr-test-suites/test_wamr.sh
42+
if(WAMR_BUILD_EXCE_HANDLING EQUAL 1)
43+
check_aot_mode_error("Unsupported build configuration: EXCE_HANDLING + AOT")
44+
check_fast_interp_error("Unsupported build configuration: EXCE_HANDLING + FAST_INTERP")
45+
check_fast_jit_error("Unsupported build configuration: EXCE_HANDLING + FAST_JIT")
46+
check_llvm_jit_error("Unsupported build configuration: EXCE_HANDLING + JIT")
47+
endif()
48+
49+
if(WAMR_BUILD_MEMORY64 EQUAL 1)
50+
check_fast_interp_error("Unsupported build configuration: MEMORY64 + FAST_INTERP")
51+
check_fast_jit_error("Unsupported build configuration: MEMORY64 + FAST_JIT")
52+
check_llvm_jit_error("Unsupported build configuration: MEMORY64 + JIT")
53+
endif()
54+
55+
if(WAMR_BUILD_GC EQUAL 1)
56+
check_fast_jit_error("Unsupported build configuration: GC + FAST_JIT")
57+
endif()
58+
59+
if(WAMR_BUILD_MULTI_MEMORY EQUAL 1)
60+
check_aot_mode_error("Unsupported build configuration: EXCE_HANDLING + AOT")
61+
check_fast_interp_error("Unsupported build configuration: EXCE_HANDLING + FAST_INTERP")
62+
check_fast_jit_error("Unsupported build configuration: EXCE_HANDLING + FAST_JIT")
63+
check_llvm_jit_error("Unsupported build configuration: EXCE_HANDLING + JIT")
64+
endif()
65+
66+
if(WAMR_BUILD_MULTI_MODULE EQUAL 1)
67+
check_fast_jit_error("Unsupported build configuration: MULTI_MODULE + FAST_JIT")
68+
check_llvm_jit_error("Unsupported build configuration: MULTI_MODULE + JIT")
69+
endif()
70+
71+
if(WAMR_BUILD_SIMD EQUAL 1)
72+
check_classic_interp_error("Unsupported build configuration: SIMD + CLASSIC_INTERP")
73+
check_fast_jit_error("Unsupported build configuration: SIMD + FAST_JIT")
74+
endif()

tests/unit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ add_subdirectory(linear-memory-aot)
6363
add_subdirectory(linux-perf)
6464
add_subdirectory(gc)
6565
add_subdirectory(tid-allocator)
66+
add_subdirectory(unsupported-features)
6667

6768
if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32")
6869
add_subdirectory(aot-stack-frame)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
cmake_minimum_required(VERSION 3.14)
5+
6+
project(unsupported_features_tests)
7+
8+
include(CMakePrintHelpers)
9+
10+
# fake target
11+
include(../unit_common.cmake)
12+
add_library(unsupported_features_tests EXCLUDE_FROM_ALL ${WAMR_RUNTIME_LIB_SOURCE})
13+
14+
enable_testing()
15+
16+
# Define a function to add tests with unsupported features
17+
function(add_unsupported_feature_test test_name flags)
18+
cmake_print_variables(test_name flags)
19+
add_test(
20+
NAME verify_${test_name}
21+
COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_LIST_DIR} -B build_${test_name} ${flags} --fresh
22+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
23+
)
24+
set_tests_properties(verify_${test_name} PROPERTIES WILL_FAIL TRUE)
25+
endfunction()
26+
27+
# List of unsupported feature tests
28+
set(UNSUPPORTED_FEATURE_TESTS
29+
"exce_handling_aot -DWAMR_BUILD_EXCE_HANDLING=1 -DWAMR_BUILD_AOT=1"
30+
"exce_handling_fast_interp -DWAMR_BUILD_EXCE_HANDLING=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1"
31+
"exce_handling_fast_jit -DWAMR_BUILD_EXCE_HANDLING=1 -DWAMR_BUILD_FAST_JIT=1"
32+
"exce_handling_llvm_jit -DWAMR_BUILD_EXCE_HANDLING=1 -DWAMR_BUILD_JIT=1"
33+
"gc_fast_jit -DWAMR_BUILD_GC=1 -DWAMR_BUILD_FAST_JIT=1"
34+
"memory64_fast_interp -DWAMR_BUILD_MEMORY64=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1"
35+
"memory64_fast_jit -DWAMR_BUILD_MEMORY64=1 -DWAMR_BUILD_FAST_JIT=1"
36+
"memory64_llvm_jit -DWAMR_BUILD_MEMORY64=1 -DWAMR_BUILD_JIT=1"
37+
"multi_memory_aot -DWAMR_BUILD_MULTI_MEMORY=1 -DWAMR_BUILD_AOT=1"
38+
"multi_memory_fast_interp -DWAMR_BUILD_MULTI_MEMORY=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1"
39+
"multi_memory_fast_jit -DWAMR_BUILD_MULTI_MEMORY=1 -DWAMR_BUILD_FAST_JIT=1"
40+
"multi_memory_llvm_jit -DWAMR_BUILD_MULTI_MEMORY=1 -DWAMR_BUILD_JIT=1"
41+
"multi_module_fast_jit -DWAMR_BUILD_MULTI_MODULE=1 -DWAMR_BUILD_FAST_JIT=1"
42+
"multi_module_llvm_jit -DWAMR_BUILD_MULTI_MODULE=1 -DWAMR_BUILD_JIT=1"
43+
"simd_classic_interp -DWAMR_BUILD_SIMD=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0"
44+
"simd_fast_jit -DWAMR_BUILD_SIMD=1 -DWAMR_BUILD_FAST_JIT=1"
45+
)
46+
47+
# Add each test using the function
48+
foreach(test ${UNSUPPORTED_FEATURE_TESTS})
49+
# string -> list by replacing space with ;
50+
string(REPLACE " " ";" test_parts "${test}")
51+
# list[0]
52+
list(GET test_parts 0 test_name)
53+
# list[1:]
54+
list(REMOVE_AT test_parts 0)
55+
# pass list to cmake and let cmake split it
56+
set(flags ${test_parts})
57+
58+
add_unsupported_feature_test(${test_name} "${flags}")
59+
endforeach()
60+

0 commit comments

Comments
 (0)