Skip to content

Commit 45475c9

Browse files
authored
chore: update WasmEdge from proxy-wasm/0.13.1 to 0.16.1 (#485)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent 44cb35f commit 45475c9

6 files changed

Lines changed: 254 additions & 44 deletions

File tree

bazel/external/fmt.BUILD

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Based on Bazel Central Registry fmt module BUILD file
16+
# https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/fmt/11.0.2
17+
18+
load("@rules_cc//cc:defs.bzl", "cc_library")
19+
20+
package(default_visibility = ["//visibility:public"])
21+
22+
licenses(["notice"]) # MIT
23+
24+
cc_library(
25+
name = "fmt",
26+
srcs = [
27+
"src/format.cc",
28+
"src/os.cc",
29+
],
30+
hdrs = glob([
31+
"include/fmt/*.h",
32+
]),
33+
copts = select({
34+
"@platforms//os:windows": ["-utf-8"],
35+
"//conditions:default": [],
36+
}),
37+
includes = ["include"],
38+
strip_include_prefix = "include",
39+
)

bazel/external/spdlog.BUILD

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Based on Bazel Central Registry spdlog module BUILD file
16+
# https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/spdlog/1.13.0
17+
18+
load("@rules_cc//cc:defs.bzl", "cc_library")
19+
20+
package(default_visibility = ["//visibility:public"])
21+
22+
licenses(["notice"]) # MIT
23+
24+
cc_library(
25+
name = "spdlog",
26+
hdrs = glob([
27+
"include/**/*.h",
28+
]),
29+
defines = ["SPDLOG_FMT_EXTERNAL"],
30+
includes = ["include"],
31+
deps = ["@com_github_fmtlib_fmt//:fmt"],
32+
)

bazel/external/wasmedge.BUILD

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,22 @@ filegroup(
2626
cmake(
2727
name = "wasmedge_lib",
2828
cache_entries = {
29-
"WASMEDGE_BUILD_AOT_RUNTIME": "Off",
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",
34+
# Provide spdlog and fmt as external dependencies via Bazel (not CMake FetchContent)
35+
"CMAKE_PREFIX_PATH": "$$EXT_BUILD_DEPS$$/spdlog;$$EXT_BUILD_DEPS$$/fmt",
3436
},
3537
env = {
3638
"CXXFLAGS": "-Wno-error=dangling-reference -Wno-error=maybe-uninitialized -Wno-error=array-bounds= -Wno-error=deprecated-declarations -std=c++20",
3739
},
3840
generate_args = ["-GNinja"],
3941
lib_source = ":srcs",
4042
out_static_libs = ["libwasmedge.a"],
43+
deps = [
44+
"@com_github_fmtlib_fmt//:fmt",
45+
"@com_github_gabime_spdlog//:spdlog",
46+
],
4147
)

bazel/external/wasmedge.patch

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 1111111..2222222 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -186,6 +186,59 @@ endif()
6+
include(Helper)
7+
include(GNUInstallDirs)
8+
9+
+# When building under Bazel with rules_foreign_cc, dependencies are provided via EXT_BUILD_DEPS
10+
+# EXT_BUILD_DEPS environment variable contains the path to the merged dependency directory
11+
+# created by rules_foreign_cc, with headers in include/ and libraries in lib/
12+
+# All dependencies listed in the cmake() rule's deps attribute are merged into a single directory structure
13+
+# Create IMPORTED targets for fmt and spdlog to prevent CMake FetchContent from trying to download them
14+
+if(DEFINED ENV{EXT_BUILD_DEPS})
15+
+ set(BAZEL_EXT_BUILD_DEPS "$ENV{EXT_BUILD_DEPS}")
16+
+ message(STATUS "Bazel build detected, using dependencies from: ${BAZEL_EXT_BUILD_DEPS}")
17+
+
18+
+ # Create fmt::fmt IMPORTED target
19+
+ # fmt is a library with compiled sources (not header-only)
20+
+ if(NOT TARGET fmt::fmt AND EXISTS "${BAZEL_EXT_BUILD_DEPS}/include/fmt")
21+
+ # Look for the fmt library file
22+
+ find_library(FMT_LIBRARY
23+
+ NAMES fmt libfmt
24+
+ PATHS "${BAZEL_EXT_BUILD_DEPS}/lib"
25+
+ NO_DEFAULT_PATH
26+
+ )
27+
+
28+
+ if(FMT_LIBRARY)
29+
+ # Create STATIC IMPORTED library
30+
+ add_library(fmt::fmt STATIC IMPORTED)
31+
+ set_target_properties(fmt::fmt PROPERTIES
32+
+ IMPORTED_LOCATION "${FMT_LIBRARY}"
33+
+ INTERFACE_INCLUDE_DIRECTORIES "${BAZEL_EXT_BUILD_DEPS}/include"
34+
+ )
35+
+ message(STATUS "Created fmt::fmt IMPORTED target from Bazel deps: ${FMT_LIBRARY}")
36+
+ else()
37+
+ message(WARNING "fmt headers found at ${BAZEL_EXT_BUILD_DEPS}/include/fmt but compiled library not found in ${BAZEL_EXT_BUILD_DEPS}/lib. Check that fmt dependency is properly configured in Bazel BUILD file.")
38+
+ endif()
39+
+
40+
+ # Create non-namespaced alias for backward compatibility with code that references fmt without the namespace
41+
+ if(TARGET fmt::fmt)
42+
+ add_library(fmt ALIAS fmt::fmt)
43+
+ endif()
44+
+ endif()
45+
+
46+
+ # Create spdlog::spdlog IMPORTED target
47+
+ # spdlog is header-only when using external fmt
48+
+ if(NOT TARGET spdlog::spdlog AND EXISTS "${BAZEL_EXT_BUILD_DEPS}/include/spdlog")
49+
+ add_library(spdlog::spdlog INTERFACE IMPORTED)
50+
+ set_target_properties(spdlog::spdlog PROPERTIES
51+
+ INTERFACE_INCLUDE_DIRECTORIES "${BAZEL_EXT_BUILD_DEPS}/include"
52+
+ INTERFACE_COMPILE_DEFINITIONS "SPDLOG_FMT_EXTERNAL"
53+
+ )
54+
+ # spdlog depends on fmt
55+
+ if(TARGET fmt::fmt)
56+
+ set_property(TARGET spdlog::spdlog APPEND PROPERTY INTERFACE_LINK_LIBRARIES fmt::fmt)
57+
+ endif()
58+
+ message(STATUS "Created spdlog::spdlog IMPORTED target from Bazel deps")
59+
+ endif()
60+
+endif()
61+
+
62+
set(CPACK_PACKAGE_VENDOR Second State LLC)
63+
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}")
64+
set(CPACK_STRIP_FILES ON)
65+
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
66+
index 1111111..2222222 100644
67+
--- a/include/CMakeLists.txt
68+
+++ b/include/CMakeLists.txt
69+
@@ -39,6 +39,8 @@ configure_file(common/enum_configure.h api/wasmedge/enum_configure.h COPYONLY)
70+
configure_file(common/enum_errcode.h api/wasmedge/enum_errcode.h COPYONLY)
71+
configure_file(common/enum_types.h api/wasmedge/enum_types.h COPYONLY)
72+
configure_file(common/version.h.in common/version.h)
73+
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/api/wasmedge
74+
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
75+
unset(WASMEDGE_VERSION_STRING)
76+
unset(WASMEDGE_VERSION_LIST)
77+
unset(WASMEDGE_VERSION_MAJOR)
78+
diff --git a/lib/api/CMakeLists.txt b/lib/api/CMakeLists.txt
79+
index 1111111..2222222 100644
80+
--- a/lib/api/CMakeLists.txt
81+
+++ b/lib/api/CMakeLists.txt
82+
@@ -151,8 +151,15 @@ if(WASMEDGE_BUILD_SHARED_LIB)
83+
endif()
84+
85+
if(WASMEDGE_BUILD_STATIC_LIB)
86+
- wasmedge_add_static_lib_component_command(fmt::fmt)
87+
- wasmedge_add_static_lib_component_command(spdlog::spdlog)
88+
+ # When using Bazel, skip packaging fmt/spdlog into libwasmedge.a
89+
+ # Bazel will handle linking these dependencies directly from the deps attribute
90+
+ # This allows fmt to be either static or shared, and avoids the need to extract
91+
+ # object files from libraries (which fails for shared libraries)
92+
+ if(NOT DEFINED ENV{EXT_BUILD_DEPS})
93+
+ # In non-Bazel builds, package fmt and spdlog into the static library
94+
+ wasmedge_add_static_lib_component_command(fmt::fmt)
95+
+ wasmedge_add_static_lib_component_command(spdlog::spdlog)
96+
+ endif()
97+
wasmedge_add_static_lib_component_command(wasmedgeSystem)
98+
wasmedge_add_static_lib_component_command(wasmedgeCommon)
99+
wasmedge_add_static_lib_component_command(wasmedgePO)

bazel/repositories.bzl

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,40 @@ def proxy_wasm_cpp_host_repositories():
339339
)
340340

341341
# WasmEdge with dependencies.
342+
# Using native Bazel cc_library rules based on Bazel Central Registry (BCR) definitions
343+
# to avoid CMake FetchContent network access during build.
344+
345+
# fmt dependency for spdlog (version 11.0.2, based on BCR)
346+
# https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/fmt/11.0.2
347+
maybe(
348+
http_archive,
349+
name = "com_github_fmtlib_fmt",
350+
sha256 = "6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f",
351+
strip_prefix = "fmt-11.0.2",
352+
urls = ["https://github.com/fmtlib/fmt/archive/refs/tags/11.0.2.tar.gz"],
353+
build_file = "@proxy_wasm_cpp_host//bazel/external:fmt.BUILD",
354+
)
355+
356+
# spdlog dependency for WasmEdge (version 1.13.0, based on BCR)
357+
# https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/spdlog/1.13.0
358+
maybe(
359+
http_archive,
360+
name = "com_github_gabime_spdlog",
361+
sha256 = "534f2ee1a4dcbeb22249856edfb2be76a1cf4f708a20b0ac2ed090ee24cfdbc9",
362+
strip_prefix = "spdlog-1.13.0",
363+
urls = ["https://github.com/gabime/spdlog/archive/refs/tags/v1.13.0.tar.gz"],
364+
build_file = "@proxy_wasm_cpp_host//bazel/external:spdlog.BUILD",
365+
)
342366

343367
maybe(
344368
http_archive,
345369
name = "com_github_wasmedge_wasmedge",
346370
build_file = "@proxy_wasm_cpp_host//bazel/external:wasmedge.BUILD",
347-
sha256 = "7ab8a0df37c8d282ecff72d0f0bff8db63fd92df1645d5a014a9dbed4b7f9025",
348-
strip_prefix = "WasmEdge-proxy-wasm-0.13.1",
349-
url = "https://github.com/WasmEdge/WasmEdge/archive/refs/tags/proxy-wasm/0.13.1.tar.gz",
371+
sha256 = "2354d90a67e3eb396179663bdc0b457abbbc70dca967ec4528f211599a49f62a",
372+
strip_prefix = "WasmEdge-0.16.1",
373+
url = "https://github.com/WasmEdge/WasmEdge/archive/refs/tags/0.16.1.tar.gz",
374+
patches = ["@proxy_wasm_cpp_host//bazel/external:wasmedge.patch"],
375+
patch_args = ["-p1"],
350376
)
351377

352378
# Wasmtime with dependencies.

0 commit comments

Comments
 (0)