Skip to content

Commit 841c962

Browse files
Switch pipelining metadata action to hollow rlib (-Zno-codegen)
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).
1 parent 90a19fa commit 841c962

10 files changed

Lines changed: 473 additions & 84 deletions

File tree

cargo/Cargo.lock

Lines changed: 64 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/private/rust.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,15 @@ def _rust_library_common(ctx, crate_type):
205205
crate_type,
206206
disable_pipelining = getattr(ctx.attr, "disable_pipelining", False),
207207
):
208+
# The hollow rlib uses .rlib extension (not .rmeta) so rustc reads it as an
209+
# rlib archive containing lib.rmeta with optimized MIR. It is placed in a
210+
# "_hollow/" subdirectory so the full rlib and hollow rlib never appear in the
211+
# same -Ldependency= search directory (which would cause E0463).
208212
rust_metadata = ctx.actions.declare_file(
209-
paths.replace_extension(rust_lib_name, ".rmeta"),
210-
sibling = rust_lib,
213+
"_hollow/" + rust_lib_name[:-len(".rlib")] + "-hollow.rlib",
211214
)
212215
rustc_rmeta_output = generate_output_diagnostics(ctx, rust_metadata)
216+
213217
metadata_supports_pipelining = (
214218
can_use_metadata_for_pipelining(toolchain, crate_type) and
215219
not ctx.attr.disable_pipelining

0 commit comments

Comments
 (0)