[Mlir-commits] [clang] [flang] [lldb] [llvm] [mlir] [cmake] Fix clang-cl PCH mismatches in static builds (PR #191552)

Alexandre Ganea llvmlistbot at llvm.org
Tue Apr 14 06:36:05 PDT 2026


================
@@ -106,7 +106,14 @@ macro(add_clang_library name)
     endif()
     set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
   endif()
-  llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
+  # CLANG_BUILD_STATIC is added after llvm_add_library, but it changes the
+  # expansion of CLANG_ABI visibility macros, causing a PCH mismatch with
+  # libraries that were built without it. Disable PCH reuse in that case.
+  set(clang_pch_reuse)
+  if((WIN32 AND NOT MINGW) AND NOT CLANG_LINK_CLANG_DYLIB)
+    set(clang_pch_reuse DISABLE_PCH_REUSE)
+  endif()
----------------
aganea wrote:

The was too board, I fixed in the second commit by defining `CLANG_BUILD_STATIC` in HandleLLVMOptions.cmake. I know this is not ideal but it seems the simplest thing to do for now, unless there is better suggestions?

https://github.com/llvm/llvm-project/pull/191552


More information about the Mlir-commits mailing list