From f4dc4e1be32fcc98a37be48158d34a1b3d00f990 Mon Sep 17 00:00:00 2001 From: William Furr Date: Wed, 1 Oct 2025 20:44:29 +0000 Subject: [PATCH 1/2] 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. --- build-scripts/build_llvm.py | 4 ++-- core/iwasm/compilation/aot_llvm.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/build-scripts/build_llvm.py b/build-scripts/build_llvm.py index 3d241355b..28c815894 100755 --- a/build-scripts/build_llvm.py +++ b/build-scripts/build_llvm.py @@ -294,7 +294,7 @@ def main(): "arc": { "repo": "https://github.com/llvm/llvm-project.git", "repo_ssh": "git@github.com:llvm/llvm-project.git", - "branch": "release/18.x", + "branch": "release/21.x", }, "xtensa": { "repo": "https://github.com/espressif/llvm-project.git", @@ -304,7 +304,7 @@ def main(): "default": { "repo": "https://github.com/llvm/llvm-project.git", "repo_ssh": "git@github.com:llvm/llvm-project.git", - "branch": "release/18.x", + "branch": "release/21.x", }, } diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index ab351e6d4..1259930b4 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -2656,6 +2656,25 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) comp_ctx->comp_data = comp_data; /* Create LLVM context, module and builder */ +#if LLVM_VERSION_MAJOR >= 21 + /* Construct an LLVMContext directly, note: + different from non LAZY JIT mode, no need to dispose this context, if + will be disposed when the thread safe context is disposed */ + comp_ctx->context = LLVMContextCreate(); + if (!comp_ctx->context) { + aot_set_last_error("create LLVM Context failed."); + goto fail; + } + + /* Wrap the LLVM context in a thread safe context. */ + comp_ctx->orc_thread_safe_context = + LLVMOrcCreateNewThreadSafeContextFromLLVMContext(comp_ctx->context); + if (!comp_ctx->orc_thread_safe_context) { + aot_set_last_error( + "Create LLVM ThreadSafeContext from LLVMContext failed."); + goto fail; + } +#else // LLVM_VERSION_MAJOR < 21 comp_ctx->orc_thread_safe_context = LLVMOrcCreateNewThreadSafeContext(); if (!comp_ctx->orc_thread_safe_context) { 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) aot_set_last_error("get context from LLVM ThreadSafeContext failed."); goto fail; } +#endif if (!(comp_ctx->builder = LLVMCreateBuilderInContext(comp_ctx->context))) { aot_set_last_error("create LLVM builder failed."); From afdba12f9f99eb6608cad027f7467ef4cd60f35c Mon Sep 17 00:00:00 2001 From: William Furr Date: Mon, 6 Oct 2025 14:13:26 +0000 Subject: [PATCH 2/2] Free up space on Ubuntu runner for nuttx spec tests. LLVM 21 update uses more disk space and makes the standard runner fail with "No space left on device". Using the [free disk space action](https://github.com/marketplace/actions/free-disk-space-ubuntu) to delete the unused Android, Haskell, and .NET runtimes frees up space on the runner. --- .github/workflows/spec_test_on_nuttx.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/spec_test_on_nuttx.yml b/.github/workflows/spec_test_on_nuttx.yml index a65a03bf9..dc9d469b1 100644 --- a/.github/workflows/spec_test_on_nuttx.yml +++ b/.github/workflows/spec_test_on_nuttx.yml @@ -37,6 +37,19 @@ jobs: permissions: contents: read actions: write + uses: jlumbroso/free-disk-space@v1.3.1 + with: + # Deletes Android, Haskell, and .NET runtimes from the runner, freeing + # about 15 GB. + android: true + dotnet: true + haskell: true + # Keeps the tool cache, some large packages, docker images, and swap. + # Some of these could also be removed if more space is needed. + tool-cache: false + large-packages: false + docker-images: false + swap-storage: false uses: ./.github/workflows/build_llvm_libraries.yml with: os: "ubuntu-22.04"