Skip to content

Commit 1f97b4f

Browse files
committed
Enable AOT validator in build configuration and update related source files
1 parent d3ef7b3 commit 1f97b4f

File tree

9 files changed

+28
-8
lines changed

9 files changed

+28
-8
lines changed

build-scripts/config_common.cmake

+4
Original file line numberDiff line numberDiff line change
@@ -610,4 +610,8 @@ if (WAMR_BUILD_SHRUNK_MEMORY EQUAL 1)
610610
else ()
611611
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=0)
612612
message (" Shrunk memory disabled")
613+
endif()
614+
if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1)
615+
message (" AOT validator enabled")
616+
add_definitions (-DWASM_ENABLE_AOT_VALIDATOR=1)
613617
endif ()

core/config.h

+4
Original file line numberDiff line numberDiff line change
@@ -702,4 +702,8 @@
702702
#define WASM_ENABLE_SHRUNK_MEMORY 1
703703
#endif
704704

705+
#ifndef WASM_ENABLE_AOT_VALIDATOR
706+
#define WASM_ENABLE_AOT_VALIDATOR 0
707+
#endif
708+
705709
#endif /* end of _CONFIG_H_ */

core/iwasm/aot/SConscript

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ src = Split('''
1414
aot_loader.c
1515
aot_runtime.c
1616
aot_intrinsic.c
17-
aot_validator.c
1817
''')
1918

2019
if rtconfig.ARCH == 'arm':

core/iwasm/aot/aot_loader.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include "../common/wasm_native.h"
1111
#include "../common/wasm_loader_common.h"
1212
#include "../compilation/aot.h"
13+
#if WASM_ENABLE_AOT_VALIDATOR != 0
1314
#include "aot_validator.h"
15+
#endif
1416

1517
#if WASM_ENABLE_DEBUG_AOT != 0
1618
#include "debug/elf_parser.h"
@@ -4401,11 +4403,12 @@ aot_load_from_aot_file(const uint8 *buf, uint32 size, const LoadArgs *args,
44014403
os_thread_jit_write_protect_np(true); /* Make memory executable */
44024404
os_icache_flush(module->code, module->code_size);
44034405

4404-
/*TODO: use a CLI option to control? */
4406+
#if WASM_ENABLE_AOT_VALIDATOR != 0
44054407
if (!aot_module_validate(module, error_buf, error_buf_size)) {
44064408
aot_unload(module);
44074409
return NULL;
44084410
}
4411+
#endif /* WASM_ENABLE_AOT_VALIDATOR != 0 */
44094412

44104413
LOG_VERBOSE("Load module success.\n");
44114414
return module;

core/iwasm/aot/aot_perf_map.c

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "bh_log.h"
88
#include "bh_platform.h"
99

10-
#if WASM_ENABLE_LINUX_PERF != 0
1110
struct func_info {
1211
uint32 idx;
1312
void *ptr;
@@ -117,4 +116,3 @@ aot_create_perf_map(const AOTModule *module, char *error_buf,
117116

118117
return ret;
119118
}
120-
#endif /* WASM_ENABLE_LINUX_PERF != 0 */

core/iwasm/aot/aot_validator.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ aot_module_validate(const AOTModule *module, char *error_buf,
4242
}
4343

4444
return true;
45-
}
45+
}

core/iwasm/aot/iwasm_aot.cmake

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@ add_definitions (-DWASM_ENABLE_AOT=1)
77

88
include_directories (${IWASM_AOT_DIR})
99

10-
file (GLOB c_source_all ${IWASM_AOT_DIR}/*.c)
10+
list (APPEND c_source_all
11+
${IWASM_AOT_DIR}/aot_intrinsic.c
12+
${IWASM_AOT_DIR}/aot_loader.c
13+
${IWASM_AOT_DIR}/aot_runtime.c
14+
)
15+
16+
if (WAMR_BUILD_LINUX_PERF EQUAL 1)
17+
list (APPEND c_source_all ${IWASM_AOT_DIR}/aot_perf_map.c)
18+
endif ()
19+
20+
if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1)
21+
list (APPEND c_source_all ${IWASM_AOT_DIR}/aot_validator.c)
22+
endif ()
1123

1224
if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
1325
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_x86_64.c)

product-mini/platforms/nuttx/wamr.mk

+1-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ CFLAGS += -DWASM_ENABLE_AOT=1
126126
CSRCS += aot_loader.c \
127127
$(AOT_RELOC) \
128128
aot_intrinsic.c \
129-
aot_runtime.c \
130-
aot_validator.c
129+
aot_runtime.c
131130
ifeq ($(CONFIG_INTERPRETERS_WAMR_DEBUG_AOT),y)
132131
CFLAGS += -DWASM_ENABLE_DEBUG_AOT=1
133132
CSRCS += elf_parser.c \

wamr-compiler/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ if (WAMR_BUILD_LLVM_LEGACY_PM EQUAL 1)
5858
endif ()
5959

6060
if (LINUX)
61+
set(WAMR_BUILD_LINUX_PERF 1)
6162
add_definitions(-DWASM_ENABLE_LINUX_PERF=1)
6263
endif ()
6364

0 commit comments

Comments
 (0)