Enable AOT linux perf support (#2930)
And refactor the original perf support - use WAMR_BUILD_LINUX_PERF as the cmake compilation control - use WASM_ENABLE_LINUX_PERF as the compiler macro - use `wamrc --enable-linux-perf` to generate aot file which contains fp operations - use `iwasm --enable-linux-perf` to create perf map for `perf record`
This commit is contained in:
@ -48,7 +48,11 @@ add_definitions(-DWASM_ENABLE_MODULE_INST_CONTEXT=1)
|
||||
|
||||
if (WAMR_BUILD_LLVM_LEGACY_PM EQUAL 1)
|
||||
add_definitions(-DWASM_ENABLE_LLVM_LEGACY_PM=1)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (LINUX)
|
||||
add_definitions(-DWASM_ENABLE_LINUX_PERF=1)
|
||||
endif ()
|
||||
|
||||
if (DEFINED WAMR_BUILD_AOT_FUNC_PREFIX)
|
||||
add_definitions(-DAOT_FUNC_PREFIX="${WAMR_BUILD_AOT_FUNC_PREFIX}")
|
||||
|
||||
@ -184,9 +184,12 @@ print_help()
|
||||
printf(" multiple names, e.g.\n");
|
||||
printf(" --emit-custom-sections=section1,section2,sectionN\n");
|
||||
#if BH_HAS_DLFCN
|
||||
printf(" --native-lib=<lib> Register native libraries to the WASM module, which\n");
|
||||
printf(" are shared object (.so) files, for example:\n");
|
||||
printf(" --native-lib=test1.so --native-lib=test2.so\n");
|
||||
printf(" --native-lib=<lib> Register native libraries to the WASM module, which\n");
|
||||
printf(" are shared object (.so) files, for example:\n");
|
||||
printf(" --native-lib=test1.so --native-lib=test2.so\n");
|
||||
#endif
|
||||
#if WASM_ENABLE_LINUX_PERF != 0
|
||||
printf(" --enable-linux-perf Enable linux perf support\n");
|
||||
#endif
|
||||
printf(" -v=n Set log verbose level (0 to 5, default is 2), larger with more log\n");
|
||||
printf(" --version Show version information\n");
|
||||
@ -325,6 +328,9 @@ main(int argc, char *argv[])
|
||||
void *native_handle_list[8] = { NULL };
|
||||
uint32 native_handle_count = 0;
|
||||
#endif
|
||||
#if WASM_ENABLE_LINUX_PERF != 0
|
||||
bool enable_linux_perf = false;
|
||||
#endif
|
||||
|
||||
option.opt_level = 3;
|
||||
option.size_level = 3;
|
||||
@ -525,6 +531,11 @@ main(int argc, char *argv[])
|
||||
}
|
||||
native_lib_list[native_lib_count++] = argv[0] + 13;
|
||||
}
|
||||
#endif
|
||||
#if WASM_ENABLE_LINUX_PERF != 0
|
||||
else if (!strncmp(argv[0], "--enable-linux-perf", 19)) {
|
||||
enable_linux_perf = true;
|
||||
}
|
||||
#endif
|
||||
else if (!strncmp(argv[0], "--version", 9)) {
|
||||
uint32 major, minor, patch;
|
||||
@ -579,6 +590,9 @@ main(int argc, char *argv[])
|
||||
init_args.mem_alloc_option.allocator.malloc_func = malloc;
|
||||
init_args.mem_alloc_option.allocator.realloc_func = realloc;
|
||||
init_args.mem_alloc_option.allocator.free_func = free;
|
||||
#if WASM_ENABLE_LINUX_PERF != 0
|
||||
init_args.enable_linux_perf = enable_linux_perf;
|
||||
#endif
|
||||
|
||||
/* initialize runtime environment */
|
||||
if (!wasm_runtime_full_init(&init_args)) {
|
||||
|
||||
Reference in New Issue
Block a user