Skip to content

Commit 3063624

Browse files
committed
fix: resolve C++ header resolution for wasm32-wasip2 target
- Add C++ standard library include paths for wasm32-wasip2 target - Fix component metadata to correctly report wasm32-wasip2 target - Add missing toolchain field in component metadata - Ensure C++ components can find <cmath> and other standard headers Fixes CI build failures related to WASI-SDK C++ component compilation.
1 parent b9364f8 commit 3063624

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

MODULE.bazel.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cpp/defs.bzl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ def _cpp_component_impl(ctx):
109109

110110
# Include directories
111111
compile_args.add("-I" + work_dir.path)
112+
113+
# Add C++ standard library paths for wasm32-wasip2 target
114+
if ctx.attr.language == "cpp":
115+
compile_args.add("-I" + sysroot + "/include/wasm32-wasip2/c++/v1")
116+
compile_args.add("-I" + sysroot + "/include/c++/v1")
117+
112118
for include in ctx.attr.includes:
113119
compile_args.add("-I" + include)
114120

@@ -179,8 +185,9 @@ def _cpp_component_impl(ctx):
179185
metadata = {
180186
"name": ctx.label.name,
181187
"language": "cpp",
182-
"target": "wasm32-wasi",
188+
"target": "wasm32-wasip2",
183189
"wasi_sdk": True,
190+
"toolchain": "wasi-sdk",
184191
},
185192
profile = ctx.attr.optimization if hasattr(ctx.attr, "optimization") else "release",
186193
profile_variants = {},
@@ -424,6 +431,12 @@ def _cc_component_library_impl(ctx):
424431
# Include directories
425432
for hdr in ctx.files.hdrs:
426433
compile_args.add("-I" + hdr.dirname)
434+
435+
# Add C++ standard library paths for wasm32-wasip2 target
436+
if ctx.attr.language == "cpp":
437+
compile_args.add("-I" + sysroot + "/include/wasm32-wasip2/c++/v1")
438+
compile_args.add("-I" + sysroot + "/include/c++/v1")
439+
427440
for include in ctx.attr.includes:
428441
compile_args.add("-I" + include)
429442

0 commit comments

Comments
 (0)