Skip to content

Use the proper main repo mapping where appropriate#15666

Closed
Wyverald wants to merge 4 commits intobazelbuild:masterfrom
Wyverald:main-repo-mapping
Closed

Use the proper main repo mapping where appropriate#15666
Wyverald wants to merge 4 commits intobazelbuild:masterfrom
Wyverald:main-repo-mapping

Conversation

@Wyverald
Copy link
Copy Markdown
Member

Use the main repo mapping (instead of ALWAYS_FALLBACK) to a) process .bzl load labels in the WORKSPACE file, and b) to process any labels passed to repo rules in either the WORKSPACE file or WORKSPACE-loaded macros.

This change only has a noticeable effect for when the workspace name (specified using the workspace directive in the WORKSPACE file) is used in labels as @workspace_name//some:thing. Before this change, such a label would actually point to @workspace_name//some:thing, which is a different target than @//some:thing, even though they're backed by the same source. This is because we insert an implicit local_repository(name='workspace_name',path='.') clause into the WORKSPACE file (see also #15657 for a similar issue when Bzlmod is enabled).

This quirk can cause many subtle bugs, including toolchains being missing because @workspace_name//:toolchain_type and @//:toolchain_type are in fact distinct toolchain types!

Use the main repo mapping (instead of ALWAYS_FALLBACK) to a) process .bzl load labels in the WORKSPACE file, and b) to process any labels passed to repo rules in either the WORKSPACE file or WORKSPACE-loaded macros.

This change only has a noticeable effect for when the workspace name (specified using the `workspace` directive in the WORKSPACE file) is used in labels as `@workspace_name//some:thing`. Before this change, such a label would actually point to `@workspace_name//some:thing`, which is a different target than `@//some:thing`, even though they're backed by the same source. This is because we insert an implicit `local_repository(name='workspace_name',path='.')` clause into the WORKSPACE file (see also bazelbuild#15657 for a similar issue when Bzlmod is enabled).

This quirk can cause many subtle bugs, including toolchains being missing because `@workspace_name//:toolchain_type` and `@//:toolchain_type` are in fact distinct toolchain types!
@Wyverald Wyverald deleted the main-repo-mapping branch June 13, 2022 17:35
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.

2 participants