-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
Windows builds targeting wasm32-wasip2 fail with error: linker 'wasm-component-ld.exe' not found because the rustc filegroup patterns in rust/private/repository_utils.bzl don't include wasm-component-ld{binary_ext}.
Root Cause
The rustc_lib filegroup in repository_utils.bzl currently declares:
"lib/rustlib/{target_triple}/bin/gcc-ld/*",
"lib/rustlib/{target_triple}/bin/rust-lld{binary_ext}",However, the actual Windows rustc distribution (rustc-1.90.0-x86_64-pc-windows-msvc.tar.xz) contains additional binaries in that directory:
What's in lib/rustlib/x86_64-pc-windows-msvc/bin/:
- ✅
rust-lld.exe(95MB) - Declared in filegroup - ❌
wasm-component-ld.exe(5.1MB) - Missing from filegroup - ❌
rust-objcopy.exe(4.2MB) - Missing from filegroup - ❌
*.pdbdebug symbols - Missing from filegroup
What's in gcc-ld/ subdirectory (all included via wildcard):
- ✅
wasm-ld.exe,ld.lld.exe,ld64.lld.exe,lld-link.exe+.pdbfiles
Impact
When Bazel creates the sandbox on Windows:
- It copies only files declared in the filegroup
wasm-component-ld.exeis excluded because it's not in the pattern- rustc tries to find the linker at
{sysroot}/lib/rustlib/{target}/bin/wasm-component-ld.exe - File doesn't exist in sandbox → Error
This blocks all Rust wasm32-wasip2 component builds on Windows.
Evidence
Test Case
BCR Compatibility Testing for rules_wasm_component:
- Linux/macOS: ✅ All tests passing
- Windows: ❌ Fails with
linker 'wasm-component-ld.exe' not found
CI logs: https://github.com/pulseengine/rules_wasm_component/actions
Verified Tool Exists
Downloaded and extracted rustc-1.90.0-x86_64-pc-windows-msvc.tar.xz:
$ ls -lh rustc/lib/rustlib/x86_64-pc-windows-msvc/bin/
total 243328
-rwxr-xr-x 1 r wheel 95M Sep 14 17:05 rust-lld.exe
-rwxr-xr-x 1 r wheel 4.2M Sep 14 17:05 rust-objcopy.exe
-rwxr-xr-x 1 r wheel 5.1M Sep 14 17:05 wasm-component-ld.exe ← EXISTS!
-rw-r--r-- 1 r wheel 5.7M Sep 14 17:05 wasm-component-ld.pdbTool is present in official distribution but excluded from Bazel sandbox.
Proposed Fix
Option 1: Add Explicit Declarations (Conservative)
"lib/rustlib/{target_triple}/bin/wasm-component-ld{binary_ext}",
"lib/rustlib/{target_triple}/bin/rust-objcopy{binary_ext}",Option 2: Use Wildcard (Future-Proof)
"lib/rustlib/{target_triple}/bin/*{binary_ext}",Wildcard ensures any future tools added to this directory are automatically included.
Why Linux/macOS Might Not Be Affected
Need to verify if:
- Linux/macOS sandboxing is less strict
- Different linker discovery mechanisms on Unix
- Pattern matching differs with/without
.exeextension
But Windows is definitely broken without this fix.
Related Work
- ✅ Issue Add support for WASI Preview 2 and 3 platform selection bazelbuild/rules_rust#3502 - Added WASI Preview 2 platform support (merged, works on Linux/macOS)
- ❌ Windows wasm32-wasip2 support blocked by this missing filegroup entry
Environment
- rules_rust version: 0.65.0 (from BCR)
- Bazel version: 8.x
- Platform: Windows (windows-latest CI runner)
- Rust version: 1.90.0
- Target: wasm32-wasip2
Additional Context
Investigation documented in:
- https://github.com/pulseengine/rules_wasm_component (see
docs/WINDOWS_SUPPORT.md) - Downloaded Windows rustc distribution to verify tool existence
- Created debug infrastructure to inspect Bazel sandbox on Windows
The tool definitely exists - it's just not being copied into the sandbox due to incomplete filegroup patterns.