-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Allow rules to detect tool configuration #14444
Comments
Let me see if I can rephrase the goal so I understand better.
I can see the value in that - why would you need a timestamp on the tools. Perhaps we can do that with a constraint on the exec platform. You could select on the constraint. |
Correct. How do I select/detect the exec constraint? Or is that still a FR? |
Still an FR, but it is one for Bazel. It needs to be done for each organiations build environment. They need to add somethig to their platform definitions. |
Another case that select()'ing on the tool config would make easier: A feature we're looking to add to the Python rules is having a flag that specifies what debugger to include into the deps of a binary. For tools, this extra dependency isn't necessary (and can contribute to causing circular dependencies). If we could do select(tool_config: [], default: //foo:bar), that would largely solve the problem. |
We ended up working around this in an aspect by inspecting
(h/t @rickeylev ) |
I put it back on our team so we can see it in the next triage. |
Tony - do you think we could expose is_tool_configuration to non-builtins?
(That would help with the license aspect as well!)
…On Tue, Aug 16, 2022 at 7:09 PM aiuto ***@***.***> wrote:
I put it back on our team so we can see it in the next triage.
—
Reply to this email directly, view it on GitHub
<#14444 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAALCU7ZDAEG2E4WWUXA7HTVZRCXDANCNFSM5KHFYR4Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I'm not sure why we don't expost that. Perhaps, is_exec configuration would be more aligned with @katre Any thoughts? |
There has been some discussion about how to handle exec transitions with Starlark flags: this would handle the issue of However, So in an exec configuration, Was that simply an example, or are you actually having issues with tool binaries being stamped inappropriately? I am very reluctant to expose the |
@katre Whenever I thought I wanted |
@katre a small anecdote to illustrate my difficulty. is_tool_configuration (or something like it) is critical to understanding license compliance as it propagates through the graph. Dependencies can carry different license obligations depending on how they're used. For example, as a compiler versus a runtime library (most compilers do not impose their licenses onto artifacts they produce, but we need to be able to at least detect the relationship). |
@katre an aspect (the license-checking aspect in particular…Tony and I have discussed this also). I mean, ideally an aspect would be able to fully inspect a rule definition (eg inspect the properties of each of a rules attributes), this is just a proxy for that. |
+1 to what @teeler's point.
The ideal case is that we can tell a source dep from a data dep, from a
tool dep based on properties of the attribute declaration itself.
And, it's not just those 3, we would eventually want nuances like "this
data is for running the artifact, but that data is user-replaceable
configuration files"
Until that day, simply knowing of something is a tool vs a dep that gets
linked in is a good proxy.
…On Mon, Aug 29, 2022 at 11:07 AM Tyler ***@***.***> wrote:
@katre <https://github.com/katre> an aspect (the license-checking aspect
in particular…Tony and I have discussed this also).
I mean, ideally an aspect would be able to fully inspect a rule definition
(eg inspect the properties of each of a rules attributes), this is just a
proxy for that.
—
Reply to this email directly, view it on GitHub
<#14444 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXHHHCCTMRYHT4IR2DIVSDV3TGZ5ANCNFSM5KHFYR4Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thanks for all the feedback on this. I see the points raised, but unfortunately we aren't going to be able to prioritize this in the near future. If someone else wants to pick it up, I would like to see a design proposal before a PR, in order to ensure that the feature is cleanly implemented and interacts properly with other features (such as selects). |
#13048 is the closest I know. I don't think we have a specific issue for the generalized API idea? |
After thinking some more, I still think that the ability to select on "is tool configuration" is problematic: in general, if tools are being built with special logic and configuration, it becomes very difficult to test and debug them (since any testing has to be in the context of a full build that uses the tool). Ideally, it would be possible to build any tool directly just by building for the correct execution platform, thus making it uch easier to investigate misbehaving builds. |
@katre Here is another example of needing to know if we are building for the exex configuration or not: emulating flags like |
This is, I think, a better model I hope we can adapt. Since this comment we've fully starlarkized Bazel's exec transition (post-7.0), as part of standard exec configs. There's currently no user-visible difference. What this does is free us from Bazel's internal hard-coded Java logic, just like any other native -> Starlarkization work. That opens up a path toward new and creative APIs to model what exec configs look like for different users, different builds, etc. I'm hoping it makes We're currently on phase 2: limit which |
I notice that there are already a number of hacks out there looking for |
After discussion with the team, we've decided that (despite my misgivings in #14444 (comment)) we should prioritize getting a design and fixing this. From internal discussions (and my memory), there are actually a few points that need to be addressed, and may all be orthogonal to each other:
Any proposals should address at least one, and ideally all three of these, but as you can see, they probably all have different mechanisms. If anyone has any great ideas feel free to come forward, otherwise the Configurability team will try to prioritize this in Q4 or 2025 Q1. |
It would be very helpful to have a survey of potential (internal and external) use cases for this feature, especially those that aren't solved by allowing Starlark flags to specify how they should be propagated to the exec configuration. Maybe now is the time to create a GitHub discussion or doc to start collecting them? |
The thing I am looking for is that an aspect can look at it's inputs and see if any of them are in the tool configuration. That way something scanning on '*' attributes can prune tool trees from the rest. Essentially, being able to get the equivalent of |
Are there any cases in which one would reasonably want to do this for rules rather than aspects? I'm thinking that restricting this new functionality to aspects could give us the benefits without making ordinary rules more complex. |
@fmeum I recall some examples of rules behaving differently in the exec configuration. One example is that Rust has an |
Off the top of my head:
FWIW, this sort of already exists today: config_common.FeatureFlagInfo. It basically allows a rule to, at analysis time, decide the value that config_setting() receives when matched. Thus, one can do something like:
That said, ConfigMatchingInfo sounds nice -- makes this into more of a first-class feature (I think there are various things in the CC rules that do special things to allow config-matching of things that aren't necessarily just flags; might provide a way to more cleanly accomodate things like selects.config_setting_group or other "interesting" things rules do for config-state matching). |
Description of the problem / feature request:
Feature requests: what underlying problem are you trying to solve with this feature?
What operating system are you running Bazel on?
What's the output of
bazel info release
?Have you found anything relevant by searching the web?
Closest related I could find are:
Today, this can be worked around by looking at
ctx.bin_dir.path
. For host most, it'll contain/host/
, and exec mode will contain-exec-
, but both of these seem like fragile ways to detect the config.The text was updated successfully, but these errors were encountered: