Skip to content

fix: scope Rust compiler toolchains to declared target triples - #260

Merged
dzbarsky merged 2 commits into
mainfrom
codex/scope-rustc-toolchains
Sep 18, 2026
Merged

dzbarsky merged 2 commits into
mainfrom
codex/scope-rustc-toolchains

Conversation

@dzbarsky

Copy link
Copy Markdown
Member

Calling declare_rustc_toolchains in a workspace package currently breaks wildcard cquery when the target platform is outside target_triples. Add one configurable alias matching the declared triples to every generated toolchain().target_settings, preserving the existing BPF, bootstrap, and channel restrictions. With unsupported platforms excluded from toolchain resolution, target_triple can default to the first declared triple and rust_std can default to empty_stdlib. The empty standard library avoids analyzing source-built standard libraries for unsupported platforms. Reject empty target_triples and document registration precedence.

Validation: all eight Bazel 9 analysis tests pass, covering both declared musl triples, GNU fallback, bootstrap and BPF selection, and unsupported-platform analysis of every generated target, including a source-only declaration. Wildcard cquery //rs/toolchains/tests/... passes on an excluded GNU platform with its execution platform registered. Confirmed the original code reproduces the reported select error; buildifier formatting/lint and git diff --check pass.

Fixes #246.

-zbarskybot

@dzbarsky
dzbarsky merged commit ac61212 into main Sep 18, 2026
10 checks passed
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.

declare_rustc_toolchains breaks bazel cquery //... when called from a workspace package

1 participant