-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
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.