fix: make generated BPF toolchains analyzable on any CPU - #244
Merged
dzbarsky merged 1 commit intoSep 5, 2026
Merged
Conversation
The BPF toolchain's `linker` select had no default branch, so the target
cannot be analyzed for any CPU other than bpfeb/bpfel:
$ bazel cquery @default_rust_toolchains//rustc:all
ERROR: configurable attribute "linker" in
@@...//rustc:default_linux_x86_64_1_95_0_rust_toolchain_bpf
doesn't match this configuration. Would a default condition help?
That breaks any tool that analyzes a whole package rather than building
it -- target-determinator, `bazel cquery //...` -- and `tags = ["manual"]`
does not exempt a target from cquery.
Both branches of the select held the same label, so the select can be
dropped for the label itself. BPF targets stay gated by the toolchain's
`target_settings`, which is where the restriction belongs.
This was referenced Sep 3, 2026
dzbarsky
approved these changes
Sep 5, 2026
| # CPU -- which breaks `bazel cquery` over the generated | ||
| # package. BPF targets are already gated by the toolchain's | ||
| # target_settings. | ||
| "linker": bpf_linker_label, |
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
declare_rustc_toolchainsgives the generated BPF toolchain alinkerselect with no default branch, so the target cannot be analyzed for any CPU other thanbpfeb/bpfel. This reproduces against the stock generated repo, no custom setup:bazel buildis unaffected because the toolchains are taggedmanual, butmanualdoes not exempt a target from cquery. Anything that analyzes a package rather than building it hits this — in our case target-determinator, which made CI fail on a change that built fine locally.Fix
Both branches of the select held the same
bpf_linker_label, so the select can be dropped for the label itself. No behaviour change: BPF targets are already gated by the toolchain'starget_settings(@rules_rs//rs/toolchains:bpf_targets), which is the right place for that restriction."//conditions:default": Noneis not an option here —rust_toolchainrejects it with "Whenrust_toolchain.linker_preference == \"rust\", arust_toolchain.linkermust be provided".Verification
With this change,
bazel cquery @default_rust_toolchains//rustc:allcompletes successfully. Verified vialocal_path_overridefrom a workspace that registers the generated toolchains; its Rust targets build and its tests pass unchanged.I have no BPF targets to exercise, so the BPF path itself is only covered by your CI.
Related
Two other selects in the same macro have no default branch (
target_tripleon the non-BPF toolchain, and the{name}_rust_stdalias). Those only bite when the macro is called from a workspace package, and a naive default there would turn a loud analysis error into a silently wrong target triple, so I have left them alone — happy to file an issue with the details if that is useful.