From 8ef09be604bc61fa859fe38ad139f5c73f652e03 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Tue, 6 Jun 2023 08:33:15 +0800 Subject: [PATCH 1/4] Fix compile error of wamrc with llvm-13/llvm-14 (#2261) --- core/iwasm/compilation/aot_llvm_extra.cpp | 6 +++++- core/iwasm/compilation/aot_llvm_extra2.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/iwasm/compilation/aot_llvm_extra.cpp b/core/iwasm/compilation/aot_llvm_extra.cpp index 492cf3dcf5..27a014d84f 100644 --- a/core/iwasm/compilation/aot_llvm_extra.cpp +++ b/core/iwasm/compilation/aot_llvm_extra.cpp @@ -348,12 +348,16 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module) FPM.addPass(LoadStoreVectorizerPass()); if (comp_ctx->enable_llvm_pgo || comp_ctx->use_prof_file) { - LICMOptions licm_opt; /* LICM pass: loop invariant code motion, attempting to remove as much code from the body of a loop as possible. Experiments show it is good to enable it when pgo is enabled. */ +#if LLVM_VERSION_MAJOR >= 15 + LICMOptions licm_opt; FPM.addPass( createFunctionToLoopPassAdaptor(LICMPass(licm_opt), true)); +#else + FPM.addPass(createFunctionToLoopPassAdaptor(LICMPass(), true)); +#endif } /* diff --git a/core/iwasm/compilation/aot_llvm_extra2.cpp b/core/iwasm/compilation/aot_llvm_extra2.cpp index 9bd44bbff7..2d665c5f69 100644 --- a/core/iwasm/compilation/aot_llvm_extra2.cpp +++ b/core/iwasm/compilation/aot_llvm_extra2.cpp @@ -4,7 +4,11 @@ */ #include +#if LLVM_VERSION_MAJOR >= 14 #include +#else +#include +#endif #include #include "bh_assert.h" From e78f63c7ee0952cedcd2e0025a2e5d601c410012 Mon Sep 17 00:00:00 2001 From: Georgii Rylov Date: Tue, 6 Jun 2023 02:34:06 +0100 Subject: [PATCH 2/4] Update doc on WAMR_DISABLE_HW_BOUND_CHECK 32-bit (#2262) --- doc/build_wamr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/build_wamr.md b/doc/build_wamr.md index a66f27be0d..4af3b73afb 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -98,7 +98,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM #### **Disable boundary check with hardware trap** - **WAMR_DISABLE_HW_BOUND_CHECK**=1/0, default to enable if not set and supported by platform -> Note: by default only platform linux/darwin/android/windows/vxworks 64-bit will enable the boundary check with hardware trap feature, and the wamrc tool will generate AOT code without boundary check instructions in all 64-bit targets except SGX to improve performance. The boundary check includes linear memory access boundary and native stack access boundary, if `WAMR_DISABLE_STACK_HW_BOUND_CHECK` below isn't set. +> Note: by default only platform [linux/darwin/android/windows/vxworks 64-bit](https://github.com/bytecodealliance/wasm-micro-runtime/blob/5fb5119239220b0803e7045ca49b0a29fe65e70e/core/shared/platform/linux/platform_internal.h#L81) will enable the boundary check with hardware trap feature, for 32-bit platforms it's automatically disabled even when the flag set to 0, and the wamrc tool will generate AOT code without boundary check instructions in all 64-bit targets except SGX to improve performance. The boundary check includes linear memory access boundary and native stack access boundary, if `WAMR_DISABLE_STACK_HW_BOUND_CHECK` below isn't set. #### **Disable native stack boundary check with hardware trap** - **WAMR_DISABLE_STACK_HW_BOUND_CHECK**=1/0, default to enable if not set and supported by platform, same as `WAMR_DISABLE_HW_BOUND_CHECK`. From 5d69f364db02d274408f0d0ae800285449b7c947 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 6 Jun 2023 11:18:16 +0900 Subject: [PATCH 3/4] aot/jit: Set module layout (#2260) LLVM 15 and later sometimes perform wrong optimizations without this. --- core/iwasm/compilation/aot_llvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index c2b3be3ad4..81b7e8c362 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -2165,6 +2165,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) aot_set_last_error("create LLVM target data layout failed."); goto fail; } + LLVMSetModuleDataLayout(comp_ctx->module, target_data_ref); comp_ctx->pointer_size = LLVMPointerSize(target_data_ref); LLVMDisposeTargetData(target_data_ref); From 6e3c3fe9ec08faf0f28db91fd952d6bbe2334935 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 6 Jun 2023 14:45:18 +0900 Subject: [PATCH 4/4] Fix build error with LLVM 16 (#2259) --- core/iwasm/compilation/aot_llvm_extra.cpp | 2 ++ core/iwasm/compilation/aot_llvm_extra2.cpp | 2 ++ core/iwasm/compilation/aot_orc_extra.cpp | 2 ++ core/iwasm/libraries/wasi-nn/test/CMakeLists.txt | 2 +- product-mini/platforms/darwin/CMakeLists.txt | 2 +- product-mini/platforms/freebsd/CMakeLists.txt | 2 +- product-mini/platforms/ios/CMakeLists.txt | 2 +- product-mini/platforms/linux/CMakeLists.txt | 2 +- samples/wasm-c-api/CMakeLists.txt | 2 +- wamr-compiler/CMakeLists.txt | 2 +- 10 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/iwasm/compilation/aot_llvm_extra.cpp b/core/iwasm/compilation/aot_llvm_extra.cpp index 27a014d84f..a8843ccea8 100644 --- a/core/iwasm/compilation/aot_llvm_extra.cpp +++ b/core/iwasm/compilation/aot_llvm_extra.cpp @@ -5,6 +5,8 @@ #include #include +#include +#include #include #include #include diff --git a/core/iwasm/compilation/aot_llvm_extra2.cpp b/core/iwasm/compilation/aot_llvm_extra2.cpp index 2d665c5f69..8c3f3a3955 100644 --- a/core/iwasm/compilation/aot_llvm_extra2.cpp +++ b/core/iwasm/compilation/aot_llvm_extra2.cpp @@ -4,6 +4,8 @@ */ #include +#include +#include #if LLVM_VERSION_MAJOR >= 14 #include #else diff --git a/core/iwasm/compilation/aot_orc_extra.cpp b/core/iwasm/compilation/aot_orc_extra.cpp index 8cf253e948..b778b634e0 100644 --- a/core/iwasm/compilation/aot_orc_extra.cpp +++ b/core/iwasm/compilation/aot_orc_extra.cpp @@ -8,6 +8,8 @@ #include "llvm-c/OrcEE.h" #include "llvm-c/TargetMachine.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h" #include "llvm/ExecutionEngine/Orc/LLJIT.h" #include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h" diff --git a/core/iwasm/libraries/wasi-nn/test/CMakeLists.txt b/core/iwasm/libraries/wasi-nn/test/CMakeLists.txt index 33fad71eb5..30be48a226 100644 --- a/core/iwasm/libraries/wasi-nn/test/CMakeLists.txt +++ b/core/iwasm/libraries/wasi-nn/test/CMakeLists.txt @@ -8,7 +8,7 @@ project (iwasm) set (CMAKE_VERBOSE_MAKEFILE OFF) # Reset default linker flags set (CMAKE_C_STANDARD 99) -set (CMAKE_CXX_STANDARD 14) +set (CMAKE_CXX_STANDARD 17) set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") diff --git a/product-mini/platforms/darwin/CMakeLists.txt b/product-mini/platforms/darwin/CMakeLists.txt index 4d68066b0c..865e516fca 100644 --- a/product-mini/platforms/darwin/CMakeLists.txt +++ b/product-mini/platforms/darwin/CMakeLists.txt @@ -34,7 +34,7 @@ if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif () -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) if (NOT DEFINED WAMR_BUILD_INTERP) # Enable Interpreter by default diff --git a/product-mini/platforms/freebsd/CMakeLists.txt b/product-mini/platforms/freebsd/CMakeLists.txt index fee2934c01..dd1bbc41a5 100644 --- a/product-mini/platforms/freebsd/CMakeLists.txt +++ b/product-mini/platforms/freebsd/CMakeLists.txt @@ -34,7 +34,7 @@ if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif () -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) if (NOT DEFINED WAMR_BUILD_INTERP) # Enable Interpreter by default diff --git a/product-mini/platforms/ios/CMakeLists.txt b/product-mini/platforms/ios/CMakeLists.txt index 764bc7f65a..4bbff4cff9 100644 --- a/product-mini/platforms/ios/CMakeLists.txt +++ b/product-mini/platforms/ios/CMakeLists.txt @@ -41,7 +41,7 @@ if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif () -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) if (NOT DEFINED WAMR_BUILD_INTERP) # Enable Interpreter by default diff --git a/product-mini/platforms/linux/CMakeLists.txt b/product-mini/platforms/linux/CMakeLists.txt index 83ccd74590..13efe27a92 100644 --- a/product-mini/platforms/linux/CMakeLists.txt +++ b/product-mini/platforms/linux/CMakeLists.txt @@ -16,7 +16,7 @@ set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") set (CMAKE_C_STANDARD 99) -set (CMAKE_CXX_STANDARD 14) +set (CMAKE_CXX_STANDARD 17) # Set WAMR_BUILD_TARGET, currently values supported: # "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]", diff --git a/samples/wasm-c-api/CMakeLists.txt b/samples/wasm-c-api/CMakeLists.txt index a0f267c544..4dab0185c1 100644 --- a/samples/wasm-c-api/CMakeLists.txt +++ b/samples/wasm-c-api/CMakeLists.txt @@ -16,7 +16,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) ################ runtime settings ################ string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt index 0ae821af65..08f935bb64 100644 --- a/wamr-compiler/CMakeLists.txt +++ b/wamr-compiler/CMakeLists.txt @@ -21,7 +21,7 @@ else() add_definitions(-DCOMPILING_WASM_RUNTIME_API=1) endif() -set (CMAKE_CXX_STANDARD 14) +set (CMAKE_CXX_STANDARD 17) if (NOT DEFINED WAMR_BUILD_PLATFORM) set (WAMR_BUILD_PLATFORM "linux")