Wire rust_objcopy into the generated sysroot action inputs (#3972)

## Summary

#3727 added a `rust_objcopy` attribute to `rust_toolchain`, a separate
`rust-objcopy` filegroup, and automatic opt-in for Rust 1.84+/recent
nightlies. But the glue to turn that attribute into a real action input
is missing: `ctx.file.rust_objcopy` is stashed on `ToolchainInfo` and
never used again. It never flows through `_generate_sysroot` into
`direct_files`, so it doesn't join `toolchain.all_files` and isn't
declared as an input to the Rustc action.

On Linux/macOS with symlink-based sandboxing this is masked — rustc
happens to see the neighboring file in the unsandboxed `rules_rust`
external repo. Under remote execution, Windows (file-copy sandbox), or
stricter local sandboxes, rustc invokes `rust-objcopy` and fails:

```
error: unable to run `rust-objcopy`: No such file or directory (os error 2)
```

Tracking: #3307.

## Fix

Mirror the `linker` handling in `_generate_sysroot`: symlink
`rust_objcopy` into the sysroot at
`lib/rustlib/<triple>/bin/rust-objcopy` (where rustc looks) and append
it to `direct_files` so it becomes a declared Rustc action input.

## Verification

Patched `rules_rust` via `local_path_override` in a minimal smoke
workspace using rustc 1.93.0 on aarch64-apple-darwin:

- `bazel build -c opt //:hello` succeeds (opt-mode `process_wrapper`
uses `-Cstrip=debuginfo`, which invokes rust-objcopy).
- `bazel aquery 'mnemonic("Rustc", //:hello)'` now lists the sysroot
`rust-objcopy` symlink as a declared input — it was absent before.

Before: no `rust-objcopy` entry in the Rustc action inputs.
After:
`bazel-out/.../rust_toolchain/lib/rustlib/aarch64-apple-darwin/bin/rust-objcopy`.
1 file changed
tree: 87974f2fd6d41e447b96f0b990d38f409b01553f
  1. .bazelci/
  2. .bcr/
  3. .github/
  4. cargo/
  5. crate_universe/
  6. docs/
  7. examples/
  8. extensions/
  9. ffi/
  10. nix/
  11. rust/
  12. test/
  13. tools/
  14. util/
  15. .bazelignore
  16. .bazelrc
  17. .clang-format
  18. .clippy.toml
  19. .envrc
  20. .gitattributes
  21. .gitignore
  22. .pre-commit-config.yaml
  23. .prettierrc.toml
  24. .rustfmt.toml
  25. .typos.toml
  26. ARCHITECTURE.md
  27. AUTHORS
  28. BUILD.bazel
  29. CODEOWNERS
  30. COMPATIBILITY.md
  31. CONTRIBUTING.md
  32. CONTRIBUTORS
  33. LICENSE.txt
  34. MODULE.bazel
  35. README.md
  36. version.bzl
  37. WORKSPACE.bazel
  38. WORKSPACE.bzlmod
README.md

Rust Rules

  • Postsubmit Build status

Overview

This repository provides rules for building Rust projects with Bazel.

Starter repo

The fastest way to try this in an empty project is to click the green “Use this template” button on https://github.com/bazel-starters/rust.

Community

General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.

Documentation

Please refer to the full documentation.