Skip to content

Commit 82e771e

Browse files
committed
enh: conditionally include JIT-related code and update CMake configuration
1 parent 418be9d commit 82e771e

4 files changed

Lines changed: 45 additions & 12 deletions

File tree

core/iwasm/compilation/aot_compiler.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4065,6 +4065,7 @@ aot_compile_wasm(AOTCompContext *comp_ctx)
40654065
os_printf("\n");
40664066
#endif
40674067

4068+
#if WAMR_BUILD_JIT != 0
40684069
if (comp_ctx->is_jit_mode) {
40694070
LLVMErrorRef err;
40704071
LLVMOrcJITDylibRef orc_main_dylib;
@@ -4104,7 +4105,7 @@ aot_compile_wasm(AOTCompContext *comp_ctx)
41044105
comp_ctx->jit_stack_sizes = (uint32 *)addr;
41054106
}
41064107
}
4107-
4108+
#endif /* WAMR_BUILD_JIT != 0*/
41084109
return true;
41094110
}
41104111

core/iwasm/compilation/aot_llvm.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2416,6 +2416,7 @@ aot_handle_llvm_errmsg(const char *string, LLVMErrorRef err)
24162416
LLVMDisposeErrorMessage(err_msg);
24172417
}
24182418

2419+
#if WAMR_BUILD_JIT != 0
24192420
static bool
24202421
create_target_machine_detect_host(AOTCompContext *comp_ctx)
24212422
{
@@ -2599,6 +2600,7 @@ orc_jit_create(AOTCompContext *comp_ctx)
25992600
LLVMOrcDisposeLLLazyJIT(orc_jit);
26002601
return ret;
26012602
}
2603+
#endif /* WAMR_BUILD_JIT != 0*/
26022604

26032605
bool
26042606
aot_compiler_init(void)
@@ -2809,6 +2811,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
28092811
comp_ctx->custom_sections_wp = option->custom_sections;
28102812
comp_ctx->custom_sections_count = option->custom_sections_count;
28112813

2814+
#if WASM_ENABLE_JIT != 0
28122815
if (option->is_jit_mode) {
28132816
comp_ctx->is_jit_mode = true;
28142817

@@ -2840,7 +2843,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
28402843
if (!orc_jit_create(comp_ctx))
28412844
goto fail;
28422845
}
2843-
else {
2846+
else
2847+
#endif /*WASM_ENABLE_JIT != 0*/
2848+
{
28442849
/* Create LLVM target machine */
28452850
if (!option->target_arch || !strstr(option->target_arch, "-")) {
28462851
/* Retrieve the target triple based on user input */
@@ -3484,9 +3489,11 @@ aot_destroy_comp_context(AOTCompContext *comp_ctx)
34843489
/* Note: don't dispose comp_ctx->context and comp_ctx->module as
34853490
they are disposed when disposing the thread safe context */
34863491

3492+
#if WAMR_BUILD_JIT != 0
34873493
/* Has to be the last one */
34883494
if (comp_ctx->orc_jit)
34893495
LLVMOrcDisposeLLLazyJIT(comp_ctx->orc_jit);
3496+
#endif
34903497

34913498
if (comp_ctx->func_ctxes)
34923499
aot_destroy_func_contexts(comp_ctx, comp_ctx->func_ctxes,

core/iwasm/compilation/iwasm_compl.cmake

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,36 @@ set (IWASM_COMPL_DIR ${CMAKE_CURRENT_LIST_DIR})
33
include_directories(${IWASM_COMPL_DIR})
44
enable_language(CXX)
55

6+
file (GLOB source_all
7+
${IWASM_COMPL_DIR}/aot.c
8+
${IWASM_COMPL_DIR}/aot_compiler.c
9+
${IWASM_COMPL_DIR}/aot_llvm.c
10+
${IWASM_COMPL_DIR}/aot_llvm_extra*.cpp
11+
${IWASM_COMPL_DIR}/aot_stack_frame*.c
12+
${IWASM_COMPL_DIR}/aot_emit_*.c
13+
)
14+
615
if (WAMR_BUILD_DEBUG_AOT EQUAL 1)
7-
file (GLOB_RECURSE source_all
8-
${IWASM_COMPL_DIR}/*.c
9-
${IWASM_COMPL_DIR}/*.cpp)
10-
else()
11-
file (GLOB source_all
12-
${IWASM_COMPL_DIR}/simd/*.c
13-
${IWASM_COMPL_DIR}/simd/*.cpp
14-
${IWASM_COMPL_DIR}/*.c
15-
${IWASM_COMPL_DIR}/*.cpp)
16-
endif()
16+
file(GLOB debug_sources
17+
${IWASM_COMPL_DIR}/debug/*.c
18+
)
19+
list(APPEND source_all ${debug_sources})
20+
endif ()
21+
22+
if (WAMR_BUILD_SIMD EQUAL 1)
23+
file(GLOB simd_sources
24+
${IWASM_COMPL_DIR}/simd/*.c
25+
)
26+
list(APPEND source_all ${simd_sources})
27+
endif ()
28+
29+
if (WAMR_BUILD_LLVM EQUAL 1)
30+
message("Build with LLVM ORC JIT support")
31+
file(GLOB orc_jit_sources
32+
${IWASM_COMPL_DIR}/aot_orc_extra*.cpp
33+
)
34+
list(APPEND source_all ${orc_jit_sources})
35+
endif ()
1736

1837
set (IWASM_COMPL_SOURCE ${source_all})
1938

wamr-compiler/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
3232
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
3333

3434
# Turn on SIMD by default, can be turned off by setting WAMR_BUILD_SIMD to 0
35+
if (NOT WAMR_BUILD_SIMD)
36+
set (WAMR_BUILD_SIMD 1)
37+
endif ()
38+
3539
if (WAMR_BUILD_SIMD EQUAL 0)
3640
add_definitions(-DWASM_ENABLE_SIMD=0)
3741
else()
3842
add_definitions(-DWASM_ENABLE_SIMD=1)
3943
endif()
4044

45+
set(WAMR_BUILD_JIT 0)
46+
4147
add_definitions(-DWASM_ENABLE_INTERP=1)
4248
add_definitions(-DWASM_ENABLE_WAMR_COMPILER=1)
4349
add_definitions(-DWASM_ENABLE_BULK_MEMORY=1)

0 commit comments

Comments
 (0)