rustc: include proc-macro dep transitive rlibs in proc-macro link inputs#29
Open
walter-zeromatter wants to merge 2 commits into
Open
Conversation
When building a proc-macro, rustc passes all transitively-reachable rlibs to the linker (clang++). This includes rlibs that come through proc-macro dependency chains, even though those rlibs are already embedded in their parent proc-macro .so files. Under --remote_download_outputs=minimal, Bazel only downloads declared action inputs. The missing rlibs cause clang++ to fail with "no such file or directory" because they weren't declared as action inputs. Add a new `transitive_proc_macro_dep_outputs` field to DepInfo. Populate it with the transitive_crate_outputs of proc-macro deps (the ones skipped by the existing `if not is_proc_macro` guard). In collect_inputs, include this depset in the action inputs when building a proc-macro target.
|
Pushed follow-up Validated with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When building a proc-macro target, rustc passes all transitively-reachable rlibs to the linker (clang++). This includes rlibs that arrive through proc-macro dependency chains — for example, if proc-macro
Adepends on proc-macroBwhich depends on rlibchrono, rustc's linker invocation forA.soincludeschrono.rlib.collect_depsinrustc.bzlskipsdep_info.transitive_crate_outputsfor proc-macro deps (theif not is_proc_macroguard at line 258). This is correct for non-proc-macro callers — they don't need those rlibs. But it means proc-macro targets don't declare those rlibs as Bazel action inputs.Under
--remote_download_outputs=minimal(remote execution with minimal downloads), Bazel only downloads declared action inputs. Undeclared rlibs are absent from the sandbox, causing:Fix
Add a
transitive_proc_macro_dep_outputsfield toDepInfothat captures the transitive rlib outputs of proc-macro deps (exactly what theif not is_proc_macroguard was skipping). Incollect_inputs, when the target being built is itself a proc-macro, merge this depset into the action inputs.This is targeted: non-proc-macro callers are unaffected (no change to
transitive_crate_outputssemantics for them), and the new inputs are only added for proc-macro link actions where they're actually needed.Changes
rust/private/providers.bzl: newtransitive_proc_macro_dep_outputsfield onDepInforust/private/rustc.bzl(collect_deps): for proc-macro deps, accumulate theirtransitive_crate_outputsinto the new fieldrust/private/rustc.bzl(collect_inputs): for proc-macro targets, includetransitive_proc_macro_dep_outputsin the action inputs depset🤖 Generated with Claude Code