Skip to content

Commit 034dd5f

Browse files
committed
docs: update Windows root cause with specific filegroup pattern issue
After downloading and analyzing the Windows rustc distribution, discovered that wasm-component-ld.exe exists but is missing from rules_rust's rustc_lib filegroup patterns in repository_utils.bzl. Key findings: - Tool exists: rustc/lib/rustlib/x86_64-pc-windows-msvc/bin/wasm-component-ld.exe (5.1MB) - Only rust-lld.exe and gcc-ld/* are declared in filegroup patterns - wasm-component-ld.exe and rust-objcopy.exe are excluded from sandbox - This prevents rustc from finding the linker during builds Filed issue: avrabe/rules_rust#8 The fix is simple: add wasm-component-ld{binary_ext} to the filegroup pattern.
1 parent 61f6104 commit 034dd5f

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

docs/WINDOWS_SUPPORT.md

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,21 @@ Size: 5.1MB
3434
Status: Present in official Rust distribution
3535
```
3636

37-
**The real problem**: rustc can't access its own `lib/rustlib/{target}/bin/` directory in the Bazel sandbox on Windows.
37+
**The real problem**: rules_rust's `rustc_lib` filegroup has incomplete glob patterns.
3838

39-
This is a **rules_rust/Bazel integration issue**, not a Rust toolchain issue.
39+
In `rust/private/repository_utils.bzl`, the filegroup only declares:
40+
```starlark
41+
"lib/rustlib/{target_triple}/bin/gcc-ld/*" # Includes subdirectory
42+
"lib/rustlib/{target_triple}/bin/rust-lld{binary_ext}" # Includes rust-lld.exe
43+
```
44+
45+
But the Windows rustc distribution also contains:
46+
-`wasm-component-ld.exe` (5.1MB) - **NOT DECLARED** → Excluded from sandbox!
47+
-`rust-objcopy.exe` (4.2MB) - **NOT DECLARED** → Excluded from sandbox!
48+
49+
When Bazel creates the sandbox, it only copies files declared in filegroups. Since `wasm-component-ld.exe` is missing from the pattern, it's excluded from the sandbox, causing rustc's linker lookup to fail.
50+
51+
This is a **rules_rust filegroup pattern issue**, not a Rust toolchain issue.
4052

4153
### What We Fixed
4254

@@ -101,16 +113,32 @@ Track these Rust issues:
101113

102114
This will be resolved when:
103115
1. ~~Rust officially distributes `wasm-component-ld.exe` with Windows rustc~~ ✅ Already done!
104-
2. **rules_rust exposes the rustlib directory properly on Windows** (file issue with bazelbuild/rules_rust)
105-
3. Or a workaround is implemented to explicitly pass the full path to the linker
116+
2. **rules_rust adds wasm-component-ld to rustc_lib filegroup patterns****The Fix**
117+
118+
### The Required Fix
119+
120+
In `rust/private/repository_utils.bzl`, add to the `rustc_lib` filegroup:
121+
122+
**Option 1: Explicit declarations (conservative)**
123+
```starlark
124+
"lib/rustlib/{target_triple}/bin/wasm-component-ld{binary_ext}",
125+
"lib/rustlib/{target_triple}/bin/rust-objcopy{binary_ext}",
126+
```
127+
128+
**Option 2: Wildcard (future-proof)**
129+
```starlark
130+
"lib/rustlib/{target_triple}/bin/*{binary_ext}",
131+
```
132+
133+
This ensures all tools in the `bin/` directory are copied into the Bazel sandbox.
106134

107-
### Recommended Action
135+
### Issue Filed
108136

109-
File an issue with `bazelbuild/rules_rust` including:
110-
- Title: "Windows: rustc can't access lib/rustlib/{target}/bin/ in Bazel sandbox for wasm32-wasip2"
111-
- Details: Tool exists at `rustc/lib/rustlib/x86_64-pc-windows-msvc/bin/wasm-component-ld.exe` but rustc reports "not found"
112-
- Test case: rules_wasm_component Windows BCR test failure
113-
- Request: Investigation of Windows-specific sandbox configuration
137+
✅ Issue filed: https://github.com/avrabe/rules_rust/issues/8
138+
- Detailed root cause analysis
139+
- Evidence from Windows rustc distribution
140+
- Proposed fixes
141+
- Test case from rules_wasm_component BCR tests
114142

115143
## Testing on Windows
116144

@@ -151,8 +179,8 @@ bazel build //examples/basic:hello_component_release
151179

152180
## Recommendation
153181

154-
**For production use**: Document that Windows Rust wasm32-wasip2 support is experimental/unsupported until the Rust ecosystem provides the required tooling.
182+
**For production use**: Document that Windows Rust wasm32-wasip2 support is blocked by upstream rules_rust filegroup patterns. All other Windows toolchains work correctly.
155183

156-
**For contributors**: All Windows compatibility work is complete on the rules_wasm_component side. The blocker is upstream in Rust's Windows distribution.
184+
**For contributors**: All Windows compatibility work is complete on the rules_wasm_component side. The blocker is a missing filegroup pattern in rules_rust (issue filed: https://github.com/avrabe/rules_rust/issues/8).
157185

158-
**For users**: Use Linux or macOS for Rust WASM component development, or use wasm32-wasip1 (Preview 1) on Windows as a temporary workaround.
186+
**For users**: Use Linux or macOS for Rust WASM component development, or use wasm32-wasip1 (Preview 1) on Windows as a temporary workaround. Once rules_rust #8 is fixed, Windows wasm32-wasip2 will work without any changes to rules_wasm_component.

0 commit comments

Comments
 (0)