Index: lib/Frontend/FrontendActions.cpp =================================================================== --- lib/Frontend/FrontendActions.cpp +++ lib/Frontend/FrontendActions.cpp @@ -90,9 +90,15 @@ auto Buffer = std::make_shared(); std::vector> Consumers; + // FIXME: There is a known issue with timestamps appearing to be inconsistent + // on Windows (c.f. ASTReader::getInputFile) so we disable timestamps checks + // on Windows for now. + llvm::Triple HostTriple(LLVM_HOST_TRIPLE); Consumers.push_back(llvm::make_unique( CI.getPreprocessor(), OutputFile, nullptr, Sysroot, - Buffer, CI.getFrontendOpts().ModuleFileExtensions)); + Buffer, CI.getFrontendOpts().ModuleFileExtensions, + /*AllowASTWithErrors*/false, + /*IncludeTimestamps*/!HostTriple.isOSWindows())); Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator( CI, InFile, OutputFile, OS, Buffer)); Index: lib/Serialization/ASTReader.cpp =================================================================== --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -2013,6 +2013,8 @@ // In our regression testing, the Windows file system seems to // have inconsistent modification times that sometimes // erroneously trigger this error-handling path. + // For now timestamps are disabled for pch files on Windows (c.f + // GeneratePCHAction::CreateASTConsumer). // // FIXME: This probably also breaks HeaderFileInfo lookups on Windows. (StoredTime && StoredTime != File->getModificationTime() && Index: test/PCH/Inputs/pragma-once2-pch.h =================================================================== --- /dev/null +++ test/PCH/Inputs/pragma-once2-pch.h @@ -0,0 +1 @@ +#include "pragma-once2.h" \ No newline at end of file Index: test/PCH/Inputs/pragma-once2.h =================================================================== --- /dev/null +++ test/PCH/Inputs/pragma-once2.h @@ -0,0 +1,3 @@ +#pragma once + +inline void f() {} \ No newline at end of file Index: test/PCH/touch-pragma-once.cpp =================================================================== --- /dev/null +++ test/PCH/touch-pragma-once.cpp @@ -0,0 +1,23 @@ +// On Windows, timestamps for pch are not handled correctly. +// This would cause pragma once to be ignored on distributed builds. +// pragma-once2-pch.h includes pragma-once2.h which has a pragma once directive. +// pragma-once2.h is then touched before using the generated pch. +// On Linux this will cause an expected error, but on Windows we want to +// ignore the timestamp as the timestamp handling on Windows is +// inconsistent at the moment. + +// Test this without pch. +// RUN: %clang_cc1 -include %S/Inputs/pragma-once2-pch.h -fsyntax-only -verify %s + +// Test with pch. +// RUN: %clang_cc1 -emit-pch -o %t -x c++-header %S/Inputs/pragma-once2-pch.h +// RUN: touch %S/Inputs/pragma-once2.h +// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s + +// REQUIRES: system-windows + +// expected-no-diagnostics + +#include "Inputs/pragma-once2.h" + +void g() { f(); } \ No newline at end of file