-
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
Skylark support for custom configuration transitions #5574
Comments
@gregestren just checking in after bazelcon: is this the right issue to track for split transitions from starlark? |
For splits specifically, #5575 is probably a closer match. I intended #5574 to capture just 1 -> 1 transitions, which is a prerequisite step. It's ultimately up to @juliexxia. But to be safe, track both? :) |
Ah excellent. Tracking both, and for good measure scanning things under the configurability category. |
Commit: "Introduce the transitions() function and "transition" type in Starlark" (e0efc14, @c-parsons) |
inputs affect the settings parameter to the transition implementation function; only declared inputs are included in that map. outputs constrain the settings which may be returned by the transition implementation function; the returned setting keys must exactly match the declared outputs. Progress toward #5574 and #6237. RELNOTES: None. PiperOrigin-RevId: 220111780
…h attributes which use for_analysis_testing transitions. Any cases exceeding this limit will result in a rule error being thrown on the analysis_test rule. The limit is configurable via new flag --analysis_testing_deps_limit with a default limit of 500. The feature itself is still guarded behind --experimental_analysis_testing_improvements, so the former flag has no non-experimental meaning. Progress toward #5574 and #6237. RELNOTES: None. PiperOrigin-RevId: 220144957
" -- " signifies that all remaining arguments are not options. Split the residue into two lists, one for pre-double dash residue and one for post-double dash residue. In most cases, " -- " isn't used and the entire residue will be in pre-double dash residue. This is helpful for starlark build configurations which currently does starlark options using the residue of native options parsing. With this change, starlark build configurations will know not to try to parse residue after " -- ". Work towards issue #5574 PiperOrigin-RevId: 221336089
Discussion context for parameterized transitions (transitions that change a flag on dependencies but read some attribute on the attached rule to determine what to change to): https://groups.google.com/d/msg/bazel-dev/Lvmz6f_p9jY/XlzyT3T8AwAJ |
This includes the the following features available to native options parsing: * --(no)boolean_flag syntax * --flag=value syntax * --flag value syntax * single-dash syntax * for multiple values of same option, last option wins * internal-only options are treated like they don't exist There is potential here to combine some of the code in StarlarkOptionsParser.java with OptionsParserImpl.java since they support the same formats of flags. This is complicated by the fact that for native flags, you have a lot of information (type, internal vs external) before parsing whereas for starlark flags, you need to parse out the name first and load it to get this information. So I haven't done the combining in this CL. This brings up an interesting point that now all commands that use starlark flags will need to do loading. For now we limit starlark parsing to commands that already do building (which is possibly all the commands we care about). This behavior is still guarded behind --experimental_build_setting_api Work towards #5574 and #5577 PiperOrigin-RevId: 223600443
Give each starlark transition a stored event handler. After starlark transitions are applied (after top level transitions and inside configuration resolver), replay and then clear events. Declare a new abstract class for starlark transitions to consolidate fields/behavior. Add behavior to ComposingTransitions to allow decomposition. This is helpful here but will also be helpful in future work where we'll need to post-process starlark transitions after they've been applied (e.g. output type verification). #5574 RELNOTES: None. PiperOrigin-RevId: 229417148
… application/validation. Most of this change is just exception propagation immediately after configuration resolution since we usually wait and realize we've made a mistake later on. #5574 RELNOTES: None. PiperOrigin-RevId: 229555753
2018 EOY update: This feature is partially done.
|
Give each starlark transition a stored event handler. After starlark transitions are applied (after top level transitions and inside configuration resolver), replay and then clear events. Declare a new abstract class for starlark transitions to consolidate fields/behavior. Add behavior to ComposingTransitions to allow decomposition. This is helpful here but will also be helpful in future work where we'll need to post-process starlark transitions after they've been applied (e.g. output type verification). bazelbuild#5574 RELNOTES: None. PiperOrigin-RevId: 229417148
… application/validation. Most of this change is just exception propagation immediately after configuration resolution since we usually wait and realize we've made a mistake later on. bazelbuild#5574 RELNOTES: None. PiperOrigin-RevId: 229555753
Calculate and supply defaults for all read starlark options before transitions are applied. Future work includes: - combining skyfunction calls for inputs and outputs of starlark transitions - enforcing that BuildOptions.starlarkOptions will never hold default values (opposite of native options which always hold default values) in order to make BuildConfigurationWithDefault == BuildConfigurationWithNoValue - Making sure BuildConfiguration properly reflects StarlarkOptions Work towards #5574, #5577, #5578 RELNOTES: None. PiperOrigin-RevId: 242681946
Specifically helpful for --define. Work towards #5574 RELNOTES: None. PiperOrigin-RevId: 242736849
*** Reason for rollback *** Accidentally added some pending changes from a different client right before submission. Partial rollback to get rid of those. *** Original change description *** Allow *allowMultiple* options to be *set* by Starlark transitions. Specifically helpful for --define. Work towards #5574 RELNOTES: None. PiperOrigin-RevId: 242759162
*** Reason for rollback *** re-evaluation that --define should probably not be exposed as a native option *** Original change description *** Allow *allowMultiple* options to be *set* by Starlark transitions. Specifically helpful for --define. Work towards #5574 RELNOTES: None. PiperOrigin-RevId: 244357629
April '19 update:
@juliexxia is at the cutting edge of all this and can correct any parts I got wrong. |
hey @gregestren, is there a reason the whitelist ( |
Hi @steeve - those are somewhat orthogonal. Non-experimental means the API is stable and functional, and basically usable for production code. But the performance challenges remain real. "Unskilled" use of transitions could blow up build graphs and make builds way more sluggish than expected. We want to give people the power to evaluate this impact for their own projects, vs. blocking the feature outright until all theoretical scale problems are solved. But since these risks remain we kept the whitelist requirement in case project owners feel the need to lock things down. In other words, the whitelist defaults to everything:
but project owners can further restrict that if they feel that's safer. It looks like external dependencies may still need whitelist support FYI. Also, I don't think this is documented anywhere. That should be a TODO. |
Regarding:
Starting documentation available at https://docs.bazel.build/versions/master/skylark/config.html. |
That is a very nice and detailed explanation, thank you! |
May '20 update:
Closing this issue as done! 🎉 |
The documentation for "configurable build attributes" should be updated now that this is implemented. It currently still says that "config_setting currently only supports built-in Bazel flags". Overall the docs on configurability are in a bit of a confusing state at the moment, leaving me to wonder on what the best practices are and how to use all these new features. |
@oehme - can you elaborate more on general docs confusion? Feedback would be enormously helpful. We'd love to clarify best practices where not clear. |
What @oehme writes seems right. The statement "config_setting currently only supports built-in Bazel flags" is not true: rule Use of flag
Examples using |
My main feedback is that On a more general note, I don't like documentation that says "this will be possible in the future", "this will be added in this PR" (which has since been closed, but without updating the docs) or which presents incomplete new APIs mixed in with the existing ones. I'd much rather have the docs reflect the current best practices and then be updated when new best practices are fully ready. At that point the old practices can be moved to their own "outdated" chapter, so newcomers don't run straight into them. For context, I'm the kind of person who read's a tool's user guide back-to-back to get an overview of everything that is possible and on what the current best practices are. This is to avoid cargo-culting by just copying what older projects have done. But right now the configurability chapter is a mix of old and new APIs that makes it hard for me to figure out what to do and what to avoid in a new project. |
@oehme I asked about
|
Just reading this section about platforms and config_settings makes me wonder why everything is specified twice. I.e. why do I create a Edit: I've finally found the chapter on the new config system much later in the user guide. However, it is still unclear to me how these new |
I've scheduled some time to chat with the main devs of these features this Friday. This is great feedback. There are definitely some steps we can take to address some of these points. In the meantime, some random thoughts:
Anyway, again this is all really helpful. And really happy to hear you're not a cargo culter! Cargo culting indeed makes more problems for everyone, and it's such a common pattern to slip into. |
I understand, it's hard to make both new and existing users happy. I think a major problem for me was that the information about these different configuration aspects is spread over several chapters, some of them quite recent, others dated. This makes it hard to get an overview of everything that is there and what each concept is used for. I'd definitely appreciate clarification on the way that |
FYI @oehme and others, we have some changes coming through the pipeline to address your doc comments (in #11967). We probably won't address everything perfectly, but can at least get a few good steps up from the status quo. I'm still torn on how decisive we should be about discouraging Thanks again for your input. |
Part of the Skylark build configuration project.
This is a tracking issue for the ability of Skylark writers to trigger configuration transitions, which essentially means having a dependency use different flags than its parent. One common example is building a dep with a different
--cpu
.Practically, we may limit (via code restrictions or best practice guidance) initial usage to platform transitions. This is because the platform effort is a complementary project aimed at consolidating
--cpu
,--crosstool_top
, etc. into a a single platform entity. And most configuration transitions in practice trigger those kinds of settings. So we want to be careful about fragmenting the transition space too widely too early.This complements the Bazel Configurability Roadmap. Write questions / comments / status updates here. See there for the bigger picture.
The text was updated successfully, but these errors were encountered: