Skip to content

Commit b16050e

Browse files
committed
refactor: enable LLVM support across various CMake configurations
1 parent 199af21 commit b16050e

File tree

16 files changed

+81
-103
lines changed

16 files changed

+81
-103
lines changed

tests/unit/CMakeLists.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,8 @@ if(WAMR_BUILD_TARGET STREQUAL "X86_32")
3030
set(CMAKE_LIBRARY_ARCHITECTURE "i386-linux-gnu" CACHE STRING "" FORCE)
3131
endif()
3232

33-
# Prevent overriding the parent project's compiler/linker
34-
# settings on Windows
35-
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
36-
3733
# Fetch Google test
3834
include (FetchContent)
39-
4035
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
4136
FetchContent_Declare (
4237
googletest
@@ -50,10 +45,11 @@ else()
5045
)
5146
endif()
5247

48+
# Prevent overriding the parent project's compiler/linker
49+
# settings on Windows
50+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
5351
FetchContent_MakeAvailable(googletest)
5452

55-
SET(GOOGLETEST_INCLUDED 1)
56-
5753
include(GoogleTest)
5854
enable_testing()
5955

@@ -76,7 +72,7 @@ if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32")
7672
add_subdirectory (compilation)
7773

7874
# Fast-JIT or mem64 is not supported on X86_32
79-
# add_subdirectory (running-modes)
75+
add_subdirectory (running-modes)
8076
add_subdirectory (memory64)
8177
# add_subdirectory (shared-heap)
8278

tests/unit/aot-stack-frame/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ add_definitions (-DRUN_ON_LINUX)
99

1010
set (WAMR_BUILD_AOT 1)
1111
set (WAMR_BUILD_INTERP 0)
12-
set (WAMR_BUILD_JIT 0)
12+
# to involve LLVM
13+
set (WAMR_BUILD_JIT 1)
1314
set (WAMR_BUILD_SIMD 1)
1415
set (WAMR_BUILD_REF_TYPES 1)
1516
set (WAMR_BUILD_LIBC_WASI 0)

tests/unit/aot/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ add_definitions (-DWASM_ENABLE_WAMR_COMPILER=1)
1313
add_definitions (-DWASM_ENABLE_DUMP_CALL_STACK=1)
1414
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
1515

16+
set (WAMR_BUILD_AOT 1)
17+
set (WAMR_BUILD_FAST_INTERP 0)
18+
set (WAMR_BUILD_INTERP 0)
19+
# to involve LLVM
20+
set (WAMR_BUILD_JIT 1)
1621
set (WAMR_BUILD_LIBC_WASI 0)
1722
set (WAMR_BUILD_APP_FRAMEWORK 1)
1823

tests/unit/compilation/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ set (WAMR_BUILD_LIBC_WASI 0)
1717
set (WAMR_BUILD_APP_FRAMEWORK 0)
1818
set (WAMR_BUILD_THREAD_MGR 1)
1919
set (WAMR_BUILD_AOT 1)
20+
set (WAMR_BUILD_FAST_INTERP 0)
21+
set (WAMR_BUILD_INTERP 0)
22+
# to involve LLVM
23+
set (WAMR_BUILD_JIT 1)
2024

2125
include (../unit_common.cmake)
2226

tests/unit/custom-section/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ add_definitions (-DRUN_ON_LINUX)
99

1010
set (WAMR_BUILD_LIBC_WASI 0)
1111
set (WAMR_BUILD_LIBC_BUILTIN 0)
12-
set (WAMR_BUILD_JIT 0)
12+
# to involve LLVM
13+
set (WAMR_BUILD_JIT 1)
1314
set (WAMR_BUILD_LAZY_JIT 0)
1415
set (WAMR_BUILD_AOT 1)
1516

tests/unit/interpreter/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ add_definitions (-Dattr_container_malloc=malloc)
1111
add_definitions (-Dattr_container_free=free)
1212
# add_definitions (-DWASM_ENABLE_WAMR_COMPILER=1)
1313

14+
set(WAMR_BUILD_AOT 0)
15+
set(WAMR_BUILD_FAST_INTERP 0)
16+
set(WAMR_BUILD_INTERP 1)
17+
set(WAMR_BUILD_JIT 0)
1418
set (WAMR_BUILD_LIBC_WASI 0)
1519
set (WAMR_BUILD_APP_FRAMEWORK 1)
16-
set (WAMR_BUILD_AOT 0)
1720

1821
include (../unit_common.cmake)
1922

tests/unit/libc-builtin/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ project (test-libc-builtin)
77

88
add_definitions (-DRUN_ON_LINUX)
99

10+
set (WAMR_BUILD_AOT 0)
11+
set (WAMR_BUILD_FAST_INTERP 0)
12+
set (WAMR_BUILD_INTERP 1)
13+
set (WAMR_BUILD_JIT 0)
14+
set (WAMR_BUILD_LIBC_BUILTIN 1)
1015
set (WAMR_BUILD_LIBC_WASI 0)
1116
set (WAMR_BUILD_APP_FRAMEWORK 0)
1217

tests/unit/linear-memory-aot/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ set (WAMR_BUILD_APP_FRAMEWORK 0)
1212
set (WAMR_BUILD_MEMORY_PROFILING 1)
1313
set (WAMR_BUILD_INTERP 0)
1414
set (WAMR_BUILD_AOT 1)
15+
set (WAMR_BUILD_FAST_INTERP 0)
16+
# to involve LLVM
17+
set (WAMR_BUILD_JIT 1)
1518

1619
include (../unit_common.cmake)
1720

@@ -26,12 +29,11 @@ set (unit_test_sources
2629
${WAMR_RUNTIME_LIB_SOURCE}
2730
${UNCOMMON_SHARED_SOURCE}
2831
${IWASM_COMPL_SOURCE}
29-
${WASM_APP_LIB_SOURCE_ALL}
3032
)
3133

3234
# Test case: .aot file with hardware bound check.
3335
add_executable (linear_memory_test_aot ${unit_test_sources})
34-
target_link_libraries (linear_memory_test_aot gtest_main)
36+
target_link_libraries (linear_memory_test_aot ${LLVM_AVAILABLE_LIBS} gtest_main)
3537
gtest_discover_tests(linear_memory_test_aot)
3638
target_compile_definitions(linear_memory_test_aot PRIVATE WAMR_DISABLE_HW_BOUND_CHECK=0)
3739

@@ -63,6 +65,6 @@ add_custom_command(TARGET linear_memory_test_aot POST_BUILD
6365

6466
# Test case: .aot file with no hardware bound check.
6567
add_executable (linear_memory_test_aot_no_hw_bound ${unit_test_sources})
66-
target_link_libraries (linear_memory_test_aot_no_hw_bound gtest_main)
68+
target_link_libraries (linear_memory_test_aot_no_hw_bound ${LLVM_AVAILABLE_LIBS} gtest_main)
6769
gtest_discover_tests(linear_memory_test_aot_no_hw_bound)
6870
target_compile_definitions(linear_memory_test_aot_no_hw_bound PRIVATE WAMR_DISABLE_HW_BOUND_CHECK=1)

tests/unit/linux-perf/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ add_definitions (-DRUN_ON_LINUX)
99

1010
set (WAMR_BUILD_LIBC_WASI 0)
1111
set (WAMR_BUILD_LIBC_BUILTIN 0)
12-
set (WAMR_BUILD_JIT 0)
12+
# to involve LLVM
13+
set (WAMR_BUILD_JIT 1)
1314
set (WAMR_BUILD_LAZY_JIT 0)
1415
set (WAMR_BUILD_AOT 1)
1516
set (WAMR_BUILD_MULTI_MODULE 0)
@@ -26,7 +27,7 @@ include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
2627

2728
add_executable (linux_perf_test test_sort_func_ptrs.cc)
2829
target_compile_options(linux_perf_test PUBLIC -fpermissive)
29-
target_link_libraries(linux_perf_test gtest_main )
30+
target_link_libraries(linux_perf_test ${LLVM_AVAILABLE_LIBS} gtest_main )
3031
target_link_options(linux_perf_test
3132
PUBLIC
3233
LINKER:--unresolved-symbols=ignore-all

tests/unit/running-modes/CMakeLists.txt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,20 @@ cmake_minimum_required(VERSION 3.14)
55

66
project(test-running-modes)
77

8-
# Compile wasm modules
9-
add_subdirectory(wasm-apps)
8+
set(WASI_SDK_DIR "/opt/wasi-sdk")
9+
set(WASISDK_TOOLCHAIN "${WASI_SDK_DIR}/share/cmake/wasi-sdk.cmake")
10+
11+
include(ExternalProject)
12+
ExternalProject_Add(
13+
test-running-modes-wasm-apps
14+
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps
15+
BUILD_ALWAYS YES
16+
CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps -B build
17+
-DWASI_SDK_PREFIX=${WASI_SDK_DIR}
18+
-DCMAKE_TOOLCHAIN_FILE=${WASISDK_TOOLCHAIN}
19+
BUILD_COMMAND ${CMAKE_COMMAND} --build build
20+
INSTALL_COMMAND ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR}
21+
)
1022

1123
add_definitions(-DRUN_ON_LINUX)
1224

@@ -32,7 +44,7 @@ set(unit_test_sources
3244

3345
# Now simply link against gtest or gtest_main as needed. Eg
3446
add_executable(wasm_running_modes_test ${unit_test_sources})
35-
3647
target_link_libraries(wasm_running_modes_test ${LLVM_AVAILABLE_LIBS} gtest_main)
48+
add_dependencies(wasm_running_modes_test test-running-modes-wasm-apps)
3749

3850
gtest_discover_tests(wasm_running_modes_test)

0 commit comments

Comments
 (0)