[flang-commits] [flang] [llvm] [CMake] Enable warnings for PCH (PR #176566)

via flang-commits flang-commits at lists.llvm.org
Sat Jan 17 05:23:19 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-fir-hlfir

Author: Alexis Engelke (aengelke)

<details>
<summary>Changes</summary>

CMake unfortunately disables this by default...

---
Full diff: https://github.com/llvm/llvm-project/pull/176566.diff


2 Files Affected:

- (modified) flang/include/flang/Lower/DirectivesCommon.h (+2-2) 
- (modified) llvm/cmake/modules/HandleLLVMOptions.cmake (+7) 


``````````diff
diff --git a/flang/include/flang/Lower/DirectivesCommon.h b/flang/include/flang/Lower/DirectivesCommon.h
index 8d90b525aefce..195c2f6102066 100644
--- a/flang/include/flang/Lower/DirectivesCommon.h
+++ b/flang/include/flang/Lower/DirectivesCommon.h
@@ -527,8 +527,8 @@ fir::factory::AddrAndBoundsInfo gatherDataOperandAddrAndBounds(
             builder, operandLocation, dataExv, dataExvIsAssumedSize,
             strideIncludeLowerExtent);
       }
-      if (genDefaultBounds && fir::characterWithDynamicLen(
-                                  fir::unwrapRefType(info.addr.getType())) ||
+      if ((genDefaultBounds && fir::characterWithDynamicLen(
+                                   fir::unwrapRefType(info.addr.getType()))) ||
           mlir::isa<fir::BoxCharType>(
               fir::unwrapRefType(info.addr.getType()))) {
         bounds = {fir::factory::genBoundsOpFromBoxChar<BoundsOp, BoundsType>(
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 311123084bf58..8b7c8cd4028bd 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1304,6 +1304,13 @@ if (LLVM_BUILD_INSTRUMENTED AND LLVM_BUILD_INSTRUMENTED_COVERAGE)
   message(FATAL_ERROR "LLVM_BUILD_INSTRUMENTED and LLVM_BUILD_INSTRUMENTED_COVERAGE cannot both be specified")
 endif()
 
+if(NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
+  # CMake weirdly marks all PCH as system headers. This undocumented variable
+  # can be used to suppress the "#pragma clang system_header".
+  # See: https://gitlab.kitware.com/cmake/cmake/-/issues/21219
+  set(CMAKE_PCH_PROLOGUE "")
+endif()
+
 set(LLVM_THINLTO_CACHE_PATH "${PROJECT_BINARY_DIR}/lto.cache" CACHE STRING "Set ThinLTO cache path. This can be used when building LLVM from several different directiories.")
 
 if(LLVM_ENABLE_LTO AND WIN32 AND NOT LINKER_IS_LLD_LINK AND NOT MINGW)

``````````

</details>


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


More information about the flang-commits mailing list