Skip to content

Commit 1f190b0

Browse files
committed
add wasmedg-aot engine
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent 45475c9 commit 1f190b0

6 files changed

Lines changed: 76 additions & 13 deletions

File tree

.github/workflows/test.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,22 @@ jobs:
214214
arch: x86_64
215215
action: test
216216
flags: --config=hermetic-llvm
217+
- name: 'WasmEdge AOT on Linux/x86_64'
218+
engine: 'wasmedge-aot'
219+
repo: 'com_github_wasmedge_wasmedge'
220+
os: ubuntu-24.04-16core
221+
arch: x86_64
222+
action: test
223+
flags: --config=hermetic-llvm
224+
cache: true
225+
- name: 'WasmEdge AOT on macOS/x86_64'
226+
engine: 'wasmedge-aot'
227+
repo: 'com_github_wasmedge_wasmedge'
228+
os: macos-15
229+
arch: x86_64
230+
action: test
231+
flags: --config=hermetic-llvm
232+
cache: true
217233
- name: 'Wasmtime on Linux/x86_64'
218234
engine: 'wasmtime'
219235
repo: 'com_github_bytecodealliance_wasmtime'
@@ -339,4 +355,3 @@ jobs:
339355
${{ matrix.flags }}
340356
--per_file_copt=src/signature_util.cc,test/signature_util_test.cc@-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -c3- | tr -d '\n')\"
341357
//test:signature_util_test
342-

bazel/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ config_setting(
4242
values = {"define": "engine=wasmedge"},
4343
)
4444

45+
config_setting(
46+
name = "engine_wasmedge_aot",
47+
values = {"define": "engine=wasmedge-aot"},
48+
)
49+
4550
config_setting(
4651
name = "engine_wasmtime",
4752
values = {"define": "engine=wasmtime"},
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ licenses(["notice"]) # Apache 2
1818

1919
package(default_visibility = ["//visibility:public"])
2020

21-
# LLVM libraries needed by WAMR JIT - built with native Bazel.
21+
# LLVM libraries for JIT/AOT compilation - built with native Bazel.
2222
# This replaces the foreign_cc cmake build of LLVM with native Bazel builds.
23-
# These libraries are linked into the final binary, while WAMR's CMake build
24-
# uses the hermetic LLVM toolchain's CMake configs for configuration only.
23+
# These libraries are linked into the final binary for WAMR JIT and WasmEdge AOT.
24+
# Shared by both WAMR and WasmEdge for consistency.
2525
# Uses select() for CPU-specific libraries only.
2626
cc_library(
27-
name = "llvm_wamr_lib",
27+
name = "llvm_lib",
2828
deps = [
2929
"@llvm-project//llvm:Analysis",
3030
"@llvm-project//llvm:BitReader",

bazel/external/wamr.BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ cc_library(
107107
}),
108108
deps = [":wamr_lib_cmake"] + select({
109109
"@proxy_wasm_cpp_host//bazel:engine_wamr_jit": [
110-
"@llvm-raw//:llvm_wamr_lib",
110+
"@llvm-raw//:llvm_lib",
111111
],
112112
"//conditions:default": [],
113113
}),

bazel/external/wasmedge.BUILD

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@rules_cc//cc:defs.bzl", "cc_library")
1516
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
1617

1718
licenses(["notice"]) # Apache 2
@@ -24,19 +25,46 @@ filegroup(
2425
)
2526

2627
cmake(
27-
name = "wasmedge_lib",
28+
name = "wasmedge_lib_cmake",
2829
cache_entries = {
29-
"WASMEDGE_USE_LLVM": "Off",
3030
"WASMEDGE_BUILD_SHARED_LIB": "Off",
3131
"WASMEDGE_BUILD_STATIC_LIB": "On",
3232
"WASMEDGE_BUILD_TOOLS": "Off",
3333
"WASMEDGE_FORCE_DISABLE_LTO": "On",
3434
# Provide spdlog and fmt as external dependencies via Bazel (not CMake FetchContent)
3535
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS$$/spdlog;$$EXT_BUILD_DEPS$$/fmt",
36-
},
37-
env = {
38-
"CXXFLAGS": "-Wno-error=dangling-reference -Wno-error=maybe-uninitialized -Wno-error=array-bounds= -Wno-error=deprecated-declarations -std=c++20",
39-
},
36+
} | select({
37+
"@proxy_wasm_cpp_host//bazel:engine_wasmedge_aot": {
38+
"WASMEDGE_USE_LLVM": "On",
39+
"BAZEL_BUILD": "ON",
40+
# Set LLVM_INCLUDE_DIR for the build to use
41+
"LLVM_INCLUDE_DIR": "$$EXT_BUILD_ROOT/external/llvm_toolchain_llvm/include",
42+
},
43+
"//conditions:default": {
44+
"WASMEDGE_USE_LLVM": "Off",
45+
},
46+
}),
47+
# LLVM dependencies for AOT are provided via Bazel, not CMake
48+
# LLVM headers from hermetic toolchain (bzlmod-compatible via data attribute)
49+
# LLVM libraries are linked via cc_library deps (see wasmedge_lib below)
50+
data = select({
51+
"@proxy_wasm_cpp_host//bazel:engine_wasmedge_aot": [
52+
"@llvm_toolchain_llvm//:all_includes",
53+
],
54+
"//conditions:default": [],
55+
}),
56+
env = select({
57+
"@proxy_wasm_cpp_host//bazel:engine_wasmedge_aot": {
58+
# Reference LLVM headers in sandbox via EXT_BUILD_ROOT
59+
# The data attribute ensures llvm_toolchain_llvm is mounted in sandbox
60+
# This path works with both WORKSPACE and bzlmod
61+
"CFLAGS": "-isystem $$EXT_BUILD_ROOT/external/llvm_toolchain_llvm/include",
62+
"CXXFLAGS": "-isystem $$EXT_BUILD_ROOT/external/llvm_toolchain_llvm/include -Wno-error=dangling-reference -Wno-error=maybe-uninitialized -Wno-error=array-bounds= -Wno-error=deprecated-declarations -std=c++20",
63+
},
64+
"//conditions:default": {
65+
"CXXFLAGS": "-Wno-error=dangling-reference -Wno-error=maybe-uninitialized -Wno-error=array-bounds= -Wno-error=deprecated-declarations -std=c++20",
66+
},
67+
}),
4068
generate_args = ["-GNinja"],
4169
lib_source = ":srcs",
4270
out_static_libs = ["libwasmedge.a"],
@@ -45,3 +73,18 @@ cmake(
4573
"@com_github_gabime_spdlog//:spdlog",
4674
],
4775
)
76+
77+
# Wrapper library that adds LLVM dependencies for linking
78+
cc_library(
79+
name = "wasmedge_lib",
80+
linkopts = select({
81+
"@proxy_wasm_cpp_host//bazel:engine_wasmedge_aot": ["-ldl"],
82+
"//conditions:default": [],
83+
}),
84+
deps = [":wasmedge_lib_cmake"] + select({
85+
"@proxy_wasm_cpp_host//bazel:engine_wasmedge_aot": [
86+
"@llvm-raw//:llvm_lib",
87+
],
88+
"//conditions:default": [],
89+
}),
90+
)

bazel/repositories.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def proxy_wasm_cpp_host_repositories():
309309
maybe(
310310
http_archive,
311311
name = "llvm-raw",
312-
build_file = "@proxy_wasm_cpp_host//bazel/external:wamr_llvm.BUILD",
312+
build_file = "@proxy_wasm_cpp_host//bazel/external:llvm.BUILD",
313313
sha256 = "5042522b49945bc560ff9206f25fb87980a9b89b914193ca00d961511ff0673c",
314314
strip_prefix = "llvm-project-19.1.0.src",
315315
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/llvm-project-19.1.0.src.tar.xz",

0 commit comments

Comments
 (0)