Commit 85007f4
authored
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 parent eb280fa commit 85007f4
1 file changed
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
| 216 | + | |
| 217 | + | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
| |||
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| 232 | + | |
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
| |||
300 | 302 | | |
301 | 303 | | |
302 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
303 | 317 | | |
304 | 318 | | |
305 | 319 | | |
| |||
425 | 439 | | |
426 | 440 | | |
427 | 441 | | |
| 442 | + | |
428 | 443 | | |
429 | 444 | | |
430 | 445 | | |
| |||
0 commit comments