Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runnable_binary: use package_relative_label #1253

Merged

Conversation

lamcw
Copy link
Contributor

@lamcw lamcw commented Aug 8, 2024

With --enable_bzlmod, native.repository_name returns the apparent repo name (e.g. @foo~) instead of the canonical repo name. This can be a problem in the runnable_binary macro (esp. genrule targets) as rlocationpath may not be able to "see" srcs that are already listed, when some other modules depend on the runnable_binary target.

label '@@[unknown repo 'foo~' requested from @@foo~]//:foo_exe_fg' in $(location) expression is not a declared prerequisite of this rule. Since this rule was created by the macro 'runnable_binary', the error might have been caused by the macro implementation

Instead, package_relative_label should be used in the runnable_binary macro such that Bazel correctly converts the filegroup label in the context of the package currently being initialized.

@lamcw
Copy link
Contributor Author

lamcw commented Aug 8, 2024

@jsharpe is there any plan to drop support for Bazel 5.4.0? package_relative_label is not supported until 6.1.0 bazelbuild/bazel#17435

@jsharpe
Copy link
Member

jsharpe commented Aug 8, 2024

As per the LTS schedule - https://bazel.build/release we'll continue to support 5.4.1 until Jan 2025.
Are you able to use bazel-contrib/bazel_features to detect support for package_relative_label and conditionally use it?

@lamcw
Copy link
Contributor Author

lamcw commented Aug 9, 2024

Are you able to use bazel-contrib/bazel_features to detect support for package_relative_label and conditionally use it?

bazel_features does not support detecting package_relative_label -- instead I am using a hasattr guard to make sure it exists before invoking on it. Please take a look 🙏

Copy link
Member

@jsharpe jsharpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jsharpe jsharpe enabled auto-merge (squash) August 12, 2024 15:33
@jsharpe jsharpe merged commit 06e6964 into bazel-contrib:main Aug 12, 2024
2 checks passed
@lamcw lamcw deleted the runnable-binary-use-package-relative-label branch August 13, 2024 00:37
jsharpe added a commit to jsharpe/rules_foreign_cc that referenced this pull request Aug 23, 2024
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