From: Steven Wu Date: Wed, 1 Feb 2023 18:34:05 +0000 (-0800) Subject: [Module] Respect `-fno-pch-timestamps` when building modules X-Git-Tag: upstream/17.0.6~18914 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5cff68fca0bc21ccad20cc7c8fb9845e32b4c925;p=platform%2Fupstream%2Fllvm.git [Module] Respect `-fno-pch-timestamps` when building modules Always respect the FrontendOption to not include timestamps in PCH or Modules when `-fno-pch-timestamps` is specified. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D141632 --- diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 2d81178..b5e868f 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -202,7 +202,8 @@ GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI, /*AllowASTWithErrors=*/ +CI.getFrontendOpts().AllowPCMWithCompilerErrors, /*IncludeTimestamps=*/ - +CI.getFrontendOpts().BuildingImplicitModule, + +CI.getFrontendOpts().BuildingImplicitModule && + +CI.getFrontendOpts().IncludeTimestamps, /*ShouldCacheASTInMemory=*/ +CI.getFrontendOpts().BuildingImplicitModule)); Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator( diff --git a/clang/test/Modules/timestamps.c b/clang/test/Modules/timestamps.c new file mode 100644 index 0000000..5315750 --- /dev/null +++ b/clang/test/Modules/timestamps.c @@ -0,0 +1,30 @@ +/// Verify timestamps that gets embedded in the module +#include + +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash \ +// RUN: -fmodules-cache-path=%t -I %S/Inputs %s +// RUN: cp %t/c_library.pcm %t1.pcm +// RUN: llvm-bcanalyzer --dump --disable-histogram %t1.pcm > %t1.dump +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=TIMESTAMP --input-file %t1.dump +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash \ +// RUN: -fmodules-cache-path=%t -I %S/Inputs -fno-pch-timestamp %s +// RUN: cp %t/c_library.pcm %t2.pcm +// RUN: llvm-bcanalyzer --dump --disable-histogram %t2.pcm > %t2.dump +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=NOTIMESTAMP --input-file %t2.dump +// RUN: not diff %t1.dump %t2.dump + + +// CHECK: +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: