Skip to content

Commit f4dc4e1

Browse files
committed
Update LLVM to 21.1.2.
Wraps the LLVMContext construction in LLVM 21 version check; LLVM 21 makes a breaking change in LLVMContext construction, but WAMR still needs to support older LLVM versions, e.g. for xtensa/esp32 support which is only available in at most LLVM 19.
1 parent 3f4145e commit f4dc4e1

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

build-scripts/build_llvm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def main():
294294
"arc": {
295295
"repo": "https://github.com/llvm/llvm-project.git",
296296
"repo_ssh": "[email protected]:llvm/llvm-project.git",
297-
"branch": "release/18.x",
297+
"branch": "release/21.x",
298298
},
299299
"xtensa": {
300300
"repo": "https://github.com/espressif/llvm-project.git",
@@ -304,7 +304,7 @@ def main():
304304
"default": {
305305
"repo": "https://github.com/llvm/llvm-project.git",
306306
"repo_ssh": "[email protected]:llvm/llvm-project.git",
307-
"branch": "release/18.x",
307+
"branch": "release/21.x",
308308
},
309309
}
310310

core/iwasm/compilation/aot_llvm.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,6 +2656,25 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
26562656
comp_ctx->comp_data = comp_data;
26572657

26582658
/* Create LLVM context, module and builder */
2659+
#if LLVM_VERSION_MAJOR >= 21
2660+
/* Construct an LLVMContext directly, note:
2661+
different from non LAZY JIT mode, no need to dispose this context, if
2662+
will be disposed when the thread safe context is disposed */
2663+
comp_ctx->context = LLVMContextCreate();
2664+
if (!comp_ctx->context) {
2665+
aot_set_last_error("create LLVM Context failed.");
2666+
goto fail;
2667+
}
2668+
2669+
/* Wrap the LLVM context in a thread safe context. */
2670+
comp_ctx->orc_thread_safe_context =
2671+
LLVMOrcCreateNewThreadSafeContextFromLLVMContext(comp_ctx->context);
2672+
if (!comp_ctx->orc_thread_safe_context) {
2673+
aot_set_last_error(
2674+
"Create LLVM ThreadSafeContext from LLVMContext failed.");
2675+
goto fail;
2676+
}
2677+
#else // LLVM_VERSION_MAJOR < 21
26592678
comp_ctx->orc_thread_safe_context = LLVMOrcCreateNewThreadSafeContext();
26602679
if (!comp_ctx->orc_thread_safe_context) {
26612680
aot_set_last_error("create LLVM ThreadSafeContext failed.");
@@ -2670,6 +2689,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
26702689
aot_set_last_error("get context from LLVM ThreadSafeContext failed.");
26712690
goto fail;
26722691
}
2692+
#endif
26732693

26742694
if (!(comp_ctx->builder = LLVMCreateBuilderInContext(comp_ctx->context))) {
26752695
aot_set_last_error("create LLVM builder failed.");

0 commit comments

Comments
 (0)