[llvm] [Bazel] Match LLVM MSVC conformance flags (PR #218187)
Corentin Kerisit via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 14:52:03 PDT 2026
https://github.com/cerisier updated https://github.com/llvm/llvm-project/pull/218187
>From 704ca40d4e8d8bb5f8ff621cfdbf5b942cf580b0 Mon Sep 17 00:00:00 2001
From: Corentin Kerisit <corentin.kerisit at gmail.com>
Date: Sun, 23 Aug 2026 01:32:00 +0900
Subject: [PATCH] [Bazel] Match CMake MSVC conformance flags
---
utils/bazel/.bazelrc | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/utils/bazel/.bazelrc b/utils/bazel/.bazelrc
index d5c1352292e32..16930f636c763 100644
--- a/utils/bazel/.bazelrc
+++ b/utils/bazel/.bazelrc
@@ -158,6 +158,15 @@ build:windows --cxxopt=/bigobj --host_cxxopt=/bigobj
build:msvc --config=windows
+# Match LLVM's default MSVC conformance flags. Unlike the other flags here,
+# /Zc:__cplusplus only applies to C++ compilations.
+build:msvc --copt=/Zc:inline --host_copt=/Zc:inline
+build:msvc --cxxopt=/Zc:__cplusplus --host_cxxopt=/Zc:__cplusplus
+build:msvc --copt=/permissive- --host_copt=/permissive-
+
+# CMake enables the conforming preprocessor for cl.exe, but not clang-cl.
+build:msvc --copt=/Zc:preprocessor --host_copt=/Zc:preprocessor
+
build:msvc --copt=/WX --host_copt=/WX # Treat warnings as errors...
# ...but disable the ones that are violated
build:msvc --copt=/wd4141 --host_copt=/wd4141 # inline used more than once
@@ -184,6 +193,12 @@ build:clang-cl --config=windows
# Switch from MSVC to the `clang-cl` compiler.
build:clang-cl --compiler=clang-cl
+# Match the conformance flags CMake applies to clang-cl. /Zc:preprocessor is
+# intentionally only part of the MSVC configuration above.
+build:clang-cl --copt=/Zc:inline --host_copt=/Zc:inline
+build:clang-cl --cxxopt=/Zc:__cplusplus --host_cxxopt=/Zc:__cplusplus
+build:clang-cl --copt=/permissive- --host_copt=/permissive-
+
# Use Clang's internal warning flags instead of the ones that sometimes map
# through to MSVC's flags.
build:clang-cl --copt=/clang:-Wall --host_copt=/clang:-Wall
More information about the llvm-commits
mailing list