-
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
Optional toolchains #3601
Comments
Another use case for this would be tools for various languages. E.g. rules_java use a tool called If we had support for optional toolchains, we could in theory use the knowledge that C++ toolchain is available to use the C++ tool, and in case it's not available, fallback to the Java tool. </fairy_tale> |
I think that automatically choosing a Java singlejar implementation would be actively harmful, because it would open the way towards accidental slowdowns that are hard to track down. Better be explicit than implicit. |
Placing this in the icebox since we have no plans to take on this work. |
Recent discussions (see #12897) have brought back the idea of optional toolchains. One possibility is to make all toolchains optional, and then rule implementations can provide a more-appropriate error message if they cannot continue without a toolchain of a specific type. The main issue with this is migration: all existing uses of toolchains would need to add checks and error messages. I may take some time to consider alternatives or ways to ease this migration and bring this back to the forefront. |
Implementation tracked in #14726. |
This is now implemented and will be in the next LTS release. |
There are reasons to write rules where the exact toolchains used might vary depending on information available at analysis time.
The specific example here is that linking a go_binary needs a cc toolchain only if there was cgo in any of it's transitive dependencies.
At the moment to get the cc toolchain you have to say you need it in the rule, and then it is an error if one is not available, even if the go_binary rule was not really going to use it.
If we defer the error to the point of first access, then pure go builds will ask for a cc toolchain, but not get it, and go ahead to compile without error, whereas builds with cgo would complain if there was no cc toolchain but compile if there was.
There may be use cases where it would be nice to test whether the toolchain was available, but that's not strictly needed for this case.
The text was updated successfully, but these errors were encountered: