Skip to content

Commit c11c325

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 c11c325

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

build-scripts/build_llvm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,17 @@ 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",
301301
"repo_ssh": "[email protected]:espressif/llvm-project.git",
302-
"branch": "xtensa_release_18.1.2",
302+
"branch": "xtensa_release_21.1.2",
303303
},
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: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,18 +2656,21 @@ 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-
comp_ctx->orc_thread_safe_context = LLVMOrcCreateNewThreadSafeContext();
2660-
if (!comp_ctx->orc_thread_safe_context) {
2661-
aot_set_last_error("create LLVM ThreadSafeContext failed.");
2659+
/* Construct an LLVMContext directly, note:
2660+
different from non LAZY JIT mode, no need to dispose this context, if
2661+
will be disposed when the thread safe context is disposed */
2662+
comp_ctx->context = LLVMContextCreate();
2663+
if (!comp_ctx->context) {
2664+
aot_set_last_error("create LLVM Context failed.");
26622665
goto fail;
26632666
}
26642667

2665-
/* Get a reference to the underlying LLVMContext, note:
2666-
different from non LAZY JIT mode, no need to dispose this context,
2667-
if will be disposed when the thread safe context is disposed */
2668-
if (!(comp_ctx->context = LLVMOrcThreadSafeContextGetContext(
2669-
comp_ctx->orc_thread_safe_context))) {
2670-
aot_set_last_error("get context from LLVM ThreadSafeContext failed.");
2668+
/* Wrap the LLVM context in a thread safe context. */
2669+
comp_ctx->orc_thread_safe_context =
2670+
LLVMOrcCreateNewThreadSafeContextFromLLVMContext(comp_ctx->context);
2671+
if (!comp_ctx->orc_thread_safe_context) {
2672+
aot_set_last_error(
2673+
"Create LLVM ThreadSafeContext from LLVMContext failed.");
26712674
goto fail;
26722675
}
26732676

0 commit comments

Comments
 (0)