-
Notifications
You must be signed in to change notification settings - Fork 533
Add missing rustc binaries to rustc_lib filegroup #3727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
738871d to
b715cc7
Compare
Testing PR bazelbuild/rules_rust#3727 which adds wasm-component-ld.exe and rust-objcopy.exe to rustc_lib filegroup. This should fix Windows wasm32-wasip2 builds by ensuring the linker is copied into the Bazel sandbox. Issue: avrabe/rules_rust#8
Testing PR bazelbuild/rules_rust#3727 which adds wasm-component-ld.exe and rust-objcopy.exe to rustc_lib filegroup. This should fix Windows wasm32-wasip2 builds by ensuring the linker is copied into the Bazel sandbox. Issue: avrabe/rules_rust#8
b715cc7 to
030a4cf
Compare
illicitonion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
030a4cf to
2b63294
Compare
|
@illicitonion is there anything which prevents this to be merged? this change is useful for macos as well #3307 |
UebelAndre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's now a rust-lld target which has at least wasm-component-ld as a runfile. I think this is a better home for that but don't know exactly where objcopy should go. What about it's own filegroup and adding it as it's own optional attribute to rustc_toolchain?
I agree with you that it would be good to be a separate attribute of the toolchain for objcopy. It would simplify some parts as we have some custom rules for stripping targets. Unless @avrabe would do it. I could contribute that change. |
I'd be happy to review that from whoever wanted to put up the PR 😄 |
2b63294 to
3563a3d
Compare
|
Thanks for the feedback @UebelAndre - updated the approach:
@havasd thanks for the offer to contribute - I went ahead and made the changes. Hope this looks better now. |
Adds `rust-objcopy` as a separate filegroup and optional attribute on `rust_toolchain`, following the same pattern as `rust-lld`. The filegroup uses `allow_empty = True` for compatibility with Rust versions before 1.84.0 where the binary is not available.
3563a3d to
1720224
Compare
PR #3727 (bazelbuild/rules_rust#3727) is still open in upstream rules_rust. The previous commit incorrectly removed the fork override, breaking Windows builds. The fork at avrabe/rules_rust includes the fix that adds wasm-component-ld.exe to the rustc_lib filegroup, which is required for Windows WASM component builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Override rules_rust 0.68.1 with fork that fixes the bug where target_files parameter was ignored in _symlink_sysroot_tree. This ensures wasm-component-ld is symlinked into the sysroot, fixing Windows builds for wasm32-wasip2 targets. See: bazelbuild/rules_rust#3727 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use target_files parameter instead of target.files in loop
- Place linker at lib/rustlib/{triple}/bin/ so rustc's PATH includes it
Fixes wasm-component-ld failing to find rust-lld on Windows.
f34108f to
c30cafc
Compare
|
Updated with additional fixes for Commit 1: Add Commit 2: Fix sysroot construction for linker tools
These fixes enable |
PR #3727 (bazelbuild/rules_rust#3727) is still open in upstream rules_rust. The previous commit incorrectly removed the fork override, breaking Windows builds. The fork at avrabe/rules_rust includes the fix that adds wasm-component-ld.exe to the rustc_lib filegroup, which is required for Windows WASM component builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Override rules_rust 0.68.1 with fork that fixes the bug where target_files parameter was ignored in _symlink_sysroot_tree. This ensures wasm-component-ld is symlinked into the sysroot, fixing Windows builds for wasm32-wasip2 targets. See: bazelbuild/rules_rust#3727 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Add
rust-objcopyandwasm-component-ldto therustc_libfilegroup inrepository_utils.bzl. These binaries are present in recent rustc distributions (wasm-component-ld since 1.82.0, rust-objcopy since 1.84.0) but were not previously declared.Changes
rust-objcopy{binary_ext}andwasm-component-ld{binary_ext}to the rustc_lib filegroup glob patternsContext
On Windows, Bazel copies files into the sandbox rather than symlinking, so only explicitly listed files are available. This caused wasm32-wasip2 builds to fail with
linker 'wasm-component-ld.exe' not found.On Linux/macOS, the issue was masked by symlink-based sandboxing which allowed rustc to access unlisted files in the same directory.