-
Notifications
You must be signed in to change notification settings - Fork 98
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
Remove cc toolchain registration from rules_cc in MODULE.bazel #199
Conversation
The same toolchain is registered by `@bazel_tools` already, we should not register it again to prevent competing with the apple cc toolchain from `apple_support`.
In principle: I'd say the toolchain falls naturally into rules_cc and not bazel_tools. I think the registration should be remove from bazel_tools instead. Is this a temporary solution? Or will Bazel users when bazel_tools are gone, register C++ toolchain in their repos? |
I think in long term, yes, we should move the toolchain registration to rules_cc and remove the ones in bazel_tools. But until we figure out a better way to specify toolchain registration priority, I believe it's safer to keep it in bazel_tools. Because we can make sure bazel_tools is always appended at the end of the root modules' MODULE.bazel file, but have no control on the order of |
Wait. Don't apple users have complete control? MODULE.bazel is the last. Anybody using @rules_apple, just need to put it after @rules_cc. |
That's true! But with this change, they don't need to do that at all. I don't feel super strongly with this change, as there is a workaround, @keith @brentleyjones |
@keith @brentleyjones Is there a case that the end user would actually prefer the vanilla cc toolchain over the apple one? If so, keeping the toolchain registration in rules_cc might actually be better since they can easily control that by adjusting to order of |
The toolchain in rules_cc is problematic in any case as it diverged from the one in Bazel itself and may no longer work well with more recent versions of Bazel. I even tried to remove it at some point to prevent confusion. I would thus recommend:
|
For |
Is it possible to copy Bazel's toolchain over rules_cc? |
Yes, but probably not in time for Bazel 6.4.0. :-) |
could we remove the bazel_tools toolchain registration before bazel 7.x? so that way we'd end up in the good final state here sooner rather than later |
I'd personally lean towards removing the cc toolchain registration from bazel_tools (and keeping this one in rules_cc) too. It's conceptually cleaner and removes mental burden.
I wouldn't say that. Declarative =/= order-insensitive. It's not perfect that we don't yet have a more explicit way to choose from registered toolchains, but the BFS order was a conscious design decision from day 1. |
Sorry, I didn't mean to say that this is somehow not working as designed. In the absence of any domain-specific information, BFS is a great default and much better than WORKSPACE's "first come, first serve" semantics. I just think that BFS works much better between different graph depths (e.g. my direct deps' toolchains win over my transitive deps's toolchains) than on the same depth (reorder |
@keith I can try to move cc toolchains to rules_cc before Bazel 7 cut, but that means we do need to depend on rules_cc and apple_support order. Can you help document this somewhere for apple users until we figure out a better solution to control the toolchain registration order? Since we are heading to the final state anyway, I'll give up on this PR. |
is the ordering issue only if the user directly depends on both? vs bazel depending on rules_cc but not apple_support, and even apple_support depending on rules_cc (which we could add for this if it would help) |
yes -- if the user only directly depends on apple_support, everything's fine. The other two cases you mentioned aren't affected. |
Thanks for updating the doc! |
The same toolchain is registered by
@bazel_tools
already, we should not register it again to prevent competing with the apple cc toolchain fromapple_support
.Context: bazelbuild/rules_swift#1115 (comment)