Skip to content

Windows: wasm-component-ld.exe missing from rustc_lib filegroup causes wasm32-wasip2 builds to fail #8

@avrabe

Description

@avrabe

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
  • *.pdb debug 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 + .pdb files

Impact

When Bazel creates the sandbox on Windows:

  1. It copies only files declared in the filegroup
  2. wasm-component-ld.exe is excluded because it's not in the pattern
  3. rustc tries to find the linker at {sysroot}/lib/rustlib/{target}/bin/wasm-component-ld.exe
  4. 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.pdb

Tool 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 .exe extension

But Windows is definitely broken without this fix.

Related Work

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:

The tool definitely exists - it's just not being copied into the sandbox due to incomplete filegroup patterns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions