-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Transitions in csharp_ rules causes code generators to run multiple times #415
Comments
It's on my list to see if I can optimize the transitions a bit since I'm encountering some double building as well. Can't say when I will have the time though. |
Hi Daniel, this is becoming more critical for us; we have a tree of around 100 C++ libraries, and one near the top of this tree is referenced by a rules_dotnet import_library rule. This is causing these 100 libraries to be configured twice by bazel; once with default configuration, once with dotnet configuration. I note that rules_go have addressed this issue by maintaining a map of flags to allow a transition to be 'undone', and then they set this on their rule attributes that may reference outside the 'go' ecosystem: non_go_transition: https://github.com/bazelbuild/rules_go/blob/6e20cc2602796471bc4208c6d2e4565bfd4da66b/go/private/rules/transition.bzl#L63 Could something similar be done in rules_dotnet? |
I think you could add the default_transition to srcs and achieve the same: |
I'm doing some rules_dotnet work. Will see if I can get this in as well |
@peakschris Are you using the latest version of rules_dotnet? I already have the default_transition applied to all attributes that should not be part of the .Net build graph. If you are on latest then I'll take a closer look. |
Yes, we are on the latest commit. I see default_transition applied to most rules, but it doesn't seem to be applied to import_library: |
@peakschris I merged #453. Could you try it out on your repo? Using the reproduction you linked it seems like this fix did the trick. |
Thank you! I updated to latest and did a paket repin but am seeing a new error on subsequent build: ERROR: D:/b/rxhgxvk5/external/+net8_extension+paket.net8/microsoft.aspnetcore.app.ref/8.0.1/BUILD.bazel:5:15: configurable attribute "deps" in @@+net8_extension+paket.net8//microsoft.aspnetcore.app.ref/8.0.1:8.0.1 doesn't match this configuration. Would a default condition help? The build file it is complaining about looks like:
Full log: |
How is the top level target configured? Any chance you have a repro? |
My bad, I had some paket dependencies in a data block. I removed them and the build is working. I'm validating the transition behaviour now. |
Two rules, csharp_binary and cc_binary both depend on a single code generation rule. However, because csharp_binary uses transitions, the code generation rule runs multiple times, once for cc_binary, and another time for each csharp_binary target framework.
Here is a minimal worked example: https://github.com/peakschris/bazel-cs-gen-transitions
I've found an unpleasant workaround to use rules_dotnet's 'default_transition' as cfg= in the custom codegen rule, but this causes all code generations to run in a directory with ST-hash, rather than the actual default configuration. And it only works if rules_dotnet is the only ruleset using transitions.
Possible solutions
The text was updated successfully, but these errors were encountered: