Skip to content

Commit b6b1b15

Browse files
committed
fix(windows): explicitly specify wasm-component-ld.exe linker on Windows
The wasm32-wasip2 Rust target uses wasm-component-ld as its linker, but on Windows this executable is named wasm-component-ld.exe. The Rust compiler doesn't automatically append .exe when looking for the linker, causing builds to fail on Windows with 'linker not found' errors. This change adds a Windows-specific rustc flag using Bazel's select() to explicitly specify the .exe extension on Windows platforms while keeping the default behavior on other platforms. Fixes Windows BCR compatibility test failures.
1 parent 44887aa commit b6b1b15

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

rust/rust_wasm_component.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,15 @@ def rust_wasm_component(
311311

312312
profile_rustc_flags = rustc_flags + config["rustc_flags"]
313313

314+
# Add Windows-specific linker flag for wasm-component-ld.exe
315+
# On Windows, executables need .exe extension but Rust target spec doesn't add it
316+
# This is a workaround for https://github.com/rust-lang/rust/issues/...
317+
windows_linker_flag = select({
318+
"@platforms//os:windows": ["-C", "linker=wasm-component-ld.exe"],
319+
"//conditions:default": [],
320+
})
321+
profile_rustc_flags = profile_rustc_flags + windows_linker_flag
322+
314323
# Add wit-bindgen generated code if specified
315324
all_srcs = list(srcs)
316325

0 commit comments

Comments
 (0)