Skip to content

Pass File objects for PathMapper compatibility#6

Open
walter-zeromatter wants to merge 23 commits intohermeticbuild:mainfrom
walter-zeromatter:pr/pathmapper-compat
Open

Pass File objects for PathMapper compatibility#6
walter-zeromatter wants to merge 23 commits intohermeticbuild:mainfrom
walter-zeromatter:pr/pathmapper-compat

Conversation

@walter-zeromatter
Copy link
Copy Markdown

@walter-zeromatter walter-zeromatter commented Mar 20, 2026

Summary

  • Pass File objects instead of .path/.short_path strings for tool_path in clippy, rustdoc, unpretty, and rust_analyzer rules
  • Add sysroot_anchor to toolchain provider for --sysroot path mapping
  • Enables --experimental_output_paths=strip to work correctly with Rust rules

dzbarsky and others added 23 commits March 13, 2026 12:43
Replace the --rustc-quit-on-rmeta / .rmeta approach with Buck2-style
hollow rlibs: the RustcMetadata action runs rustc to completion with
-Zno-codegen, emitting a .rlib archive (named -hollow.rlib) that
contains only metadata and optimized MIR.

Key fixes:
- Main Rustc action uses full rlib --extern deps so the SVH embedded
  in the full rlib matches what downstream binaries expect (avoiding
  E0460 with non-deterministic proc macros).
- RUSTC_BOOTSTRAP=1 is set on both actions: it changes the crate hash,
  so inconsistent use would cause SVH mismatch even for deterministic
  crates.
- -Ldependency= points to the _hollow/ subdirectory so the full rlib
  and hollow rlib never appear in the same search path (avoids E0463).
- transitive_metadata_outputs are always included in the sandbox so
  rustc can resolve transitive -Ldependency= references.

Adds an SVH mismatch test that demonstrates the problem with
non-deterministic proc macros (uses a HashMap-based derive macro whose
output varies by OS-seeded random seed).
Changes tool_path arguments in clippy, rustdoc, unpretty, and
rust_analyzer to pass File objects rather than .path/.short_path
strings. This allows Bazel's PathMapper to correctly rewrite paths
when --experimental_output_paths=strip is enabled.

Also adds sysroot_anchor to the toolchain provider, used by rustc.bzl
to emit --sysroot via map_each for PathMapper compatibility.
@walter-zeromatter walter-zeromatter marked this pull request as ready for review March 20, 2026 23:07
@dzbarsky dzbarsky force-pushed the main branch 2 times, most recently from d97ab75 to e1ed0e4 Compare April 1, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants