Conversation
…mapping `cc_toolchain` resolved `%package(@repo//pkg)%` entries in `cxx_builtin_include_directories` with `Label.relative`, which uses the repository mapping of the .bzl file that calls it, i.e. that of rules_cc (or of the Bazel builtins before the rules moved here). Under Bzlmod, that mapping does not contain the apparent repository names used by the module that defines the toolchain, so such entries fail with: 'workspace_root' is not allowed on invalid Label @@[unknown repo 'x' requested from @@rules_cc+]//pkg:dummy_target Use `ctx.package_relative_label` instead, which resolves the package with the repository mapping of the package that defines the `cc_toolchain` target, so apparent repository names mean the same thing as in the BUILD file of the toolchain. This also drops the use of the deprecated `Label.relative` API, which is gated behind `--incompatible_enable_deprecated_label_apis`. Add a regression test that analyzes a `cc_toolchain` defined in a separate module (`test_repo`, known to rules_cc as `@cross_repo_test`) whose config refers to that module by its own name. The test only runs on Bazel 9+, where `cc_toolchain` is implemented in rules_cc; earlier Bazel versions implement it natively or in the builtins.
`cc_shared_library` resolved `exports_filter` entries with `Label.relative`, which uses the repository mapping of the .bzl file that calls it rather than that of the package defining the target. The rule's initializer worked around this by canonicalizing plain lists via `native.package_relative_label`, but a `select` in `exports_filter` bypasses it, so apparent repository names in a `select` fail with: 'workspace_name' is not allowed on invalid Label @@[unknown repo 'x' requested from @@rules_cc+]//:__pkg__ Use `ctx.package_relative_label` in the rule implementation instead and drop the initializer, which is now redundant. On Bazel versions that implement cc_shared_library in the builtins, rules_cc forwards to `native.cc_shared_library`, which has its own initializer. Add an exports test for a `cc_shared_library` in the separate `test_repo` module whose `exports_filter` is a `select` referring to that module by its own name.
fmeum
force-pushed
the
claude/package-paths-bzlmod-toolchain-w8lcdu
branch
from
September 17, 2026 07:33
8fcdcb9 to
0468ba0
Compare
fmeum
marked this pull request as ready for review
September 17, 2026 08:37
keith
approved these changes
Sep 17, 2026
Member
|
some stuff about %package() in #277 |
lilygorsheneva
approved these changes
Sep 17, 2026
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.
%package(...)%resolved relative to rules_cc itself, not the location where thecc_toolchainwas defined. Forcc_shared_library, the existing initializer did resolve labels correctly, but failed to do so forselectexpressions.