[llvm] [bazel] Disable `-Wmicrosoft-include` for RISCVCodeGen under clang-cl (PR #227867)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 16:52:14 PDT 2026


https://github.com/UebelAndre updated https://github.com/llvm/llvm-project/pull/227867

>From c33cc234482afd134ae86867a53ab3683b482b87 Mon Sep 17 00:00:00 2001
From: UebelAndre <github at uebelandre.com>
Date: Wed, 30 Sep 2026 13:53:48 -0700
Subject: [PATCH] [bazel] Disable `-Wmicrosoft-include` for RISCVCodeGen under
 clang-cl

---
 utils/bazel/llvm-project-overlay/llvm/BUILD.bazel | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index 49f67afeb1057..b3e4f56f76b3c 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -3264,6 +3264,16 @@ llvm_target_lib_list = [lib for lib in [
     {
         "name": "RISCV",
         "short_name": "RISCV",
+        # MCTargetDesc/RISCVTargetStreamer.h does `#include "RISCV.h"` from
+        # the parent directory. From RISCVAsmPrinter.cpp, MSVC's include-stack
+        # rule finds the real file while the normal search hits a
+        # `_virtual_includes` copy first (copied, not symlinked, on Windows).
+        # clang-cl reports the mismatch under -Wmicrosoft-include, fatal with
+        # -Werror. Same header either way; CMake avoids it via -I<target dir>.
+        "codegen_copts": select({
+            ":is_windows_clang_cl": ["/clang:-Wno-microsoft-include"],
+            "//conditions:default": [],
+        }),
         "tbl_outs": [
             (
                 ["-gen-asm-matcher"],
@@ -4107,7 +4117,7 @@ gentbl_cc_library(
             ["lib/Target/" + target["name"] + "/*.def"],
             allow_empty = True,
         ),
-        copts = llvm_copts,
+        copts = llvm_copts + target.get("codegen_copts", []),
         features = [
             "-layering_check",
             "-parse_headers",



More information about the llvm-commits mailing list