Unfortunately, the dummy toolchain in any form does not work in the presence of multiple execution platforms, due mostly to the simplistic notion of "priority" that toolchain resolution uses (and discussed
here).
The core motivation of this is to remove the dummy CC toolchain, which is causing us some pain inside Google.
Imagine this scenario:
1. You have two pools of remote workers, one linux-based and one not (we'll say darwin for convenience).
a. You have to register them in some order: either ":linux_worker, :darwin_worker", or ":darwin_worker, :linux_worker"
2. You have three toolchains: linux, darwin, and dummy.
a. The ordering here is easier, let's assume the order is ":linux_toolchain, :darwin_toolchain, :dummy_toolchain".
b. The linux and darwin toolchains have exec compatibility set to match the linux and darwin execution platforms.
c. The dummy toolchain has an empty execution compatibility, and is therefore compatible with anything.
d. The dummy toolchain is still needed, because some users are building for a different target architecture that hasn't yet updated to toolchains.
3. No cross-compilation is set up: all linux builds target linux and all darwin builds target darwin.
a. This is a simplification but the issue still arises if this isn't true.
When you attempt to build a linux binary, Bazel tries to find the best set of execution platform and toolchains:
1. Execution platform :linux_worker would use toolchain :linux_toolchain
2. Execution platform :darwin_worker would use toolchain :dummy_toolchain, because :darwin_toolchain isn't appropriate.
Since :linux_worker is higher priority, it is selected, no problem.
When you attempt to build a darwin binary, however:
1. Execution platform :linux_worker would use toolchain :dummy_toolchain, because :linux_toolchain isn't appropriate
2. Execution platform :darwin_worker would use toolchain :darwin_toolchain.
Since :linux_worker is higher priority, it is chosen, and then your build cannot continue (with a hard crash currently, and an error using your proposal).
If you swap the priority of :linux_worker and :darwin_worker, you swap the analysis and one case still cannot select a valid toolchain, even though one exists.
This would be solved with mandatory toolchains if you could remove the dummy toolchain entirely: then the incorrect execution platform would be rejected as inappropriate, and the correct one would be used. Unfortunately, because there are still cases where toolchains can't be used (Apple rules and Android rules both use CC toolchains, and are currently not completely ready for toolchain resolution), we need the dummy toolchain to prevent errors in (unused) toolchain resolution from stopping builds.