Skip to content

Commit b816b8d

Browse files
author
Rules WASM Component
committed
fix: use rust_shared_library for WASM component builds
Replace rust_library with rust_shared_library to properly generate cdylib crates for WebAssembly components. Changes: - Switch from rust_library to rust_shared_library in rust_wasm_component - Remove unsupported crate_type attribute - Update platforms dependency to 0.0.11 to match resolved version - Update documentation references The rust_shared_library rule automatically creates cdylib crates which are required for WebAssembly component generation, resolving build errors in CI environments.
1 parent fbad7a2 commit b816b8d

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module(
99
# Dependencies for WebAssembly tooling
1010
bazel_dep(name = "rules_rust", version = "0.46.0")
1111
bazel_dep(name = "bazel_skylib", version = "1.7.1")
12-
bazel_dep(name = "platforms", version = "0.0.10")
12+
bazel_dep(name = "platforms", version = "0.0.11")
1313

1414
# Development dependencies
1515
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)

rust/rust_wasm_component.bzl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Rust WASM component rule implementation"""
22

3-
load("@rules_rust//rust:defs.bzl", "rust_library")
3+
load("@rules_rust//rust:defs.bzl", "rust_shared_library")
44
load("//providers:providers.bzl", "WasmComponentInfo", "WitInfo")
55
load("//common:common.bzl", "WASM_TARGET_TRIPLE")
66

@@ -109,7 +109,7 @@ def rust_wasm_component(
109109
"""
110110
Builds a Rust WebAssembly component.
111111
112-
This macro combines rust_library with WASM component conversion.
112+
This macro combines rust_shared_library with WASM component conversion.
113113
114114
Args:
115115
name: Target name
@@ -121,7 +121,7 @@ def rust_wasm_component(
121121
rustc_flags: Additional rustc flags
122122
profiles: List of build profiles to create ["debug", "release", "custom"]
123123
visibility: Target visibility
124-
**kwargs: Additional arguments passed to rust_library
124+
**kwargs: Additional arguments passed to rust_shared_library
125125
126126
Example:
127127
rust_wasm_component(
@@ -169,11 +169,10 @@ def rust_wasm_component(
169169
"--target=" + WASM_TARGET_TRIPLE,
170170
]
171171

172-
rust_library(
172+
rust_shared_library(
173173
name = rust_library_name,
174174
srcs = srcs,
175175
deps = deps,
176-
crate_type = "cdylib",
177176
edition = "2021",
178177
crate_features = crate_features,
179178
rustc_flags = profile_rustc_flags,

0 commit comments

Comments
 (0)