From 455babbacbe25fc3e203ca54d93a79e93b110e54 Mon Sep 17 00:00:00 2001 From: Muhammad Omair Javaid Date: Tue, 8 Apr 2025 01:30:10 +0500 Subject: [PATCH] [Flang][Windows] Disable PCH on Windows for flangFrontend This patch fixes PCH staleness errors (fatal error: ... mtime changed) for flangFrontend during incremental Windows builds. The error occurs because the automatic CMake re-run during incremental builds updates the timestamp of the PCH source file (cmake_pch.cxx) relative to the existing PCH artifact (.pch). This happens even without direct modifications to the headers listed for precompilation. Apparently, flangFrontend is the only known LLVM target which uses target_precompile_headers, and this mechanism fails to reliably force a PCH rebuild after the CMake re-run in this Windows environment. --- flang/lib/Frontend/CMakeLists.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt index e8a098613e26f..576d09f7f364c 100644 --- a/flang/lib/Frontend/CMakeLists.txt +++ b/flang/lib/Frontend/CMakeLists.txt @@ -73,10 +73,16 @@ add_flang_library(flangFrontend clangDriver ) -target_precompile_headers(flangFrontend PRIVATE - [["flang/Parser/parsing.h"]] - [["flang/Parser/parse-tree.h"]] - [["flang/Parser/dump-parse-tree.h"]] - [["flang/Lower/PFTBuilder.h"]] - [["flang/Lower/Bridge.h"]] -) +# Precompiled Headers for flangFrontend +# Only enable PCH on non-Windows platforms, as the current usage of +# target_precompile_headers appears fragile during incremental builds +# involving CMake regeneration specifically on Windows. +if(NOT WIN32) + target_precompile_headers(flangFrontend PRIVATE + [["flang/Parser/parsing.h"]] + [["flang/Parser/parse-tree.h"]] + [["flang/Parser/dump-parse-tree.h"]] + [["flang/Lower/PFTBuilder.h"]] + [["flang/Lower/Bridge.h"]] + ) +endif()