mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 15:05:19 +00:00
Fix issues of build/run with llvm-17 (#2853)
- Fix compilation error of using PGOOptions - Fix LLVM JIT run error due to `llvm_orc_registerEHFrameSectionWrapper` symbol not found
This commit is contained in:
parent
453a29a9d4
commit
b0d5b8df1d
|
@ -122,6 +122,11 @@ if (WAMR_BUILD_JIT EQUAL 1)
|
||||||
if (CXX_SUPPORTS_REDUNDANT_MOVE_FLAG)
|
if (CXX_SUPPORTS_REDUNDANT_MOVE_FLAG)
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-redundant-move")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-redundant-move")
|
||||||
endif ()
|
endif ()
|
||||||
|
# Enable exporting symbols after llvm-17, or LLVM JIT may run failed
|
||||||
|
# with `llvm_orc_registerEHFrameSectionWrapper` symbol not found error
|
||||||
|
if (${LLVM_PACKAGE_VERSION} VERSION_GREATER_EQUAL "17.0.0")
|
||||||
|
set (CMAKE_ENABLE_EXPORTS 1)
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
else ()
|
else ()
|
||||||
unset (LLVM_AVAILABLE_LIBS)
|
unset (LLVM_AVAILABLE_LIBS)
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <llvm/Support/ErrorHandling.h>
|
#include <llvm/Support/ErrorHandling.h>
|
||||||
#if LLVM_VERSION_MAJOR >= 17
|
#if LLVM_VERSION_MAJOR >= 17
|
||||||
#include <llvm/Support/PGOOptions.h>
|
#include <llvm/Support/PGOOptions.h>
|
||||||
|
#include <llvm/Support/VirtualFileSystem.h>
|
||||||
#endif
|
#endif
|
||||||
#include <llvm/Target/CodeGenCWrappers.h>
|
#include <llvm/Target/CodeGenCWrappers.h>
|
||||||
#include <llvm/Target/TargetMachine.h>
|
#include <llvm/Target/TargetMachine.h>
|
||||||
|
@ -203,19 +204,27 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module)
|
||||||
Optional<PGOOptions> PGO = llvm::None;
|
Optional<PGOOptions> PGO = llvm::None;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO
|
|
||||||
#if LLVM_VERSION_MAJOR < 17
|
|
||||||
if (comp_ctx->enable_llvm_pgo) {
|
if (comp_ctx->enable_llvm_pgo) {
|
||||||
/* Disable static counter allocation for value profiler,
|
/* Disable static counter allocation for value profiler,
|
||||||
it will be allocated by runtime */
|
it will be allocated by runtime */
|
||||||
const char *argv[] = { "", "-vp-static-alloc=false" };
|
const char *argv[] = { "", "-vp-static-alloc=false" };
|
||||||
cl::ParseCommandLineOptions(2, argv);
|
cl::ParseCommandLineOptions(2, argv);
|
||||||
|
#if LLVM_VERSION_MAJOR < 17
|
||||||
PGO = PGOOptions("", "", "", PGOOptions::IRInstr);
|
PGO = PGOOptions("", "", "", PGOOptions::IRInstr);
|
||||||
|
#else
|
||||||
|
auto FS = vfs::getRealFileSystem();
|
||||||
|
PGO = PGOOptions("", "", "", "", FS, PGOOptions::IRInstr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (comp_ctx->use_prof_file) {
|
else if (comp_ctx->use_prof_file) {
|
||||||
|
#if LLVM_VERSION_MAJOR < 17
|
||||||
PGO = PGOOptions(comp_ctx->use_prof_file, "", "", PGOOptions::IRUse);
|
PGO = PGOOptions(comp_ctx->use_prof_file, "", "", PGOOptions::IRUse);
|
||||||
}
|
#else
|
||||||
|
auto FS = vfs::getRealFileSystem();
|
||||||
|
PGO = PGOOptions(comp_ctx->use_prof_file, "", "", "", FS,
|
||||||
|
PGOOptions::IRUse);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_PASS
|
#ifdef DEBUG_PASS
|
||||||
PassInstrumentationCallbacks PIC;
|
PassInstrumentationCallbacks PIC;
|
||||||
|
@ -343,7 +352,13 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module)
|
||||||
ExitOnErr(PB.parsePassPipeline(MPM, comp_ctx->llvm_passes));
|
ExitOnErr(PB.parsePassPipeline(MPM, comp_ctx->llvm_passes));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OptimizationLevel::O0 == OL) {
|
if (
|
||||||
|
#if LLVM_VERSION_MAJOR <= 13
|
||||||
|
PassBuilder::OptimizationLevel::O0 == OL
|
||||||
|
#else
|
||||||
|
OptimizationLevel::O0 == OL
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
MPM.addPass(PB.buildO0DefaultPipeline(OL));
|
MPM.addPass(PB.buildO0DefaultPipeline(OL));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user