-
Notifications
You must be signed in to change notification settings - Fork 159
Description
I want to compile using the C++20 standard. With the Linux GCC compiler, setting --action_env=BAZEL_CXXOPTS="-std=c++20" works fine (setting --cxxopt=-std=c++20 works as well).
However, there are problems and unexpected behavior with Windows msvc-cl:
--action_env=BAZEL_CXXOPTS="-std=c++20" seems to be completely ignored. I noticed this issue in both Bazel versions 8 and 9.
Therefore, the only solution is to set --cxxopt=-std:c++20. This workaround is effective as long as rules_cc has not been used. This was possible under Bazel 8.
However, the following problem arises as soon as you enter the line bazel_dep(name = "rules_cc", version = "0.2.16") (the same applies to version 0.2.14) in MODULE.bazel. In this case, cl is called with both /std:c++17 and /std:c++20. This results in the warning "cl : Command line warning D9025 : overriding '/std:c++17' with '/std:c++20'".
Ideally, action_env would work the same way on Windows as it does on Linux.
However, rules_cc should not pass /std:c++17 for no reason, regardless of the user-set standard. It is also unclear why there is a difference in behavior with or without rules_cc (at least at Bazel 8). Or did I use something incorrectly?
(Note: If anyone wants to suggest using / instead of -, know that it doesn't matter; the behavior is the same.)