`@bazel_tools//tools/cpp/...` or `@rules_cc//cc/compiler/...` ?
I work on a project that is a dependency of several other projects. I've been able to get this project successfully building on windows with bazel, using @rules_cc//cc/compiler:clang-cl as a condition to select on.
However, one of our dependencies appears to make a custom toolchain, with @bazel_tools//tools/cpp:clang-cl as its constraint. I tried to simply select on either one: https://github.com/google/XNNPACK/commit/dc05a09f076534ce56c6f5b82a0327850c66bf3c But that doesn't seem to be working either. (The dependency's build is hard for me to reproduce, so it's difficult to troubleshoot exactly what the problem is.)
Maybe @rules_cc//cc/compiler:x being true should also cause @bazel_tools//tools/cpp:x to be true? Or is that already the case, and my problem is elsewhere?
Is one of these deprecated, or will be deprecated at some point?
As far as I understand the situation, @rules_cc//cc/compiler:clang-cl and friends are what you should use if you want to select on the current compiler.
@bazel_tools//tools/cpp:clang-cl offers a way to influence which compiler is used by Bazel's auto-configured toolchain, but I think that only works on Windows and only if you model compilers as platform constraints (questionable). Nowadays these are aliases into rules_cc internals that will probably be deleted at some point.
Nowadays these are aliases into rules_cc internals that will probably be deleted at some point.
Can you please help me confirm something: here is the toolchain configured by the project that depends on us: https://github.com/openxla/xla/blob/2b8cdafa2671bff70fe63a9a40f70f84b81a88c9/tools/toolchains/win2022/BUILD#L17
If I use select("@rules_cc//cc/compiler:clang-cl", x), is that supposed to resolve to x in our dependency being built with this toolchain? Or do I need to use select("@bazel_tools//tools/cpp:clang-cl", x)? FWIW, neither appear to work right now, so either something else is wrong, or I'm using the wrong one of these, and it would be very helpful for me to narrow down which is the case.
The former should work since the Bazel-configured C++ Windows toolchains (assuming you use those) do set the correct compiler name here: https://github.com/bazelbuild/rules_cc/blob/506289b872e76e0e1b42e131dc8e4dfc2cef17d9/cc/private/toolchain/BUILD.windows.tpl#L578