<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">(Apologies for the long delay).</div><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 8, 2015, at 6:30 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 13, 2014 at 8:07 PM, Argyrios Kyrtzidis <span dir="ltr" class=""><<a href="mailto:akyrtzi@gmail.com" target="_blank" class="">akyrtzi@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: akirtzidis<br class="">
Date: Thu Mar 13 22:07:38 2014<br class="">
New Revision: 203885<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=203885&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=203885&view=rev</a><br class="">
Log:<br class="">
[Modules] Emit the module file paths as dependencies of the PCH when we are building one.<br class="">
<br class="">
This is because the PCH is tied to the module files, if one of the module files changes or gets removed<br class="">
the build system should re-build the PCH file.<br class=""></blockquote><div class=""><br class=""></div><div class=""><div class="">Is there any reason this has its own -cc1 flag instead of being tied to -emit-pch?</div></div></div></div></div></div></blockquote><div><br class=""></div><div>Offers a bit of flexibility and separation of concerns between dependency file generation and output file generation.</div><div>But I don’t have a strong preference, if it simplifies things to not have a separate option I’m fine with removing it.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<a href="rdar://16321245" class="">rdar://16321245</a><br class="">
<br class="">
Added:<br class="">
cfe/trunk/test/Driver/pch-deps.c<br class="">
cfe/trunk/test/Modules/dependency-gen-pch.m<br class="">
Modified:<br class="">
cfe/trunk/include/clang/Driver/CC1Options.td<br class="">
cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h<br class="">
cfe/trunk/include/clang/Serialization/ASTReader.h<br class="">
cfe/trunk/lib/Driver/Tools.cpp<br class="">
cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br class="">
cfe/trunk/lib/Frontend/DependencyFile.cpp<br class="">
cfe/trunk/lib/Serialization/ASTReader.cpp<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Driver/CC1Options.td<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=203885&r1=203884&r2=203885&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=203885&r1=203884&r2=203885&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)<br class="">
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Mar 13 22:07:38 2014<br class="">
@@ -223,6 +223,8 @@ def dependent_lib : Joined<["--"], "depe<br class="">
<br class="">
def sys_header_deps : Flag<["-"], "sys-header-deps">,<br class="">
HelpText<"Include system headers in dependency output">;<br class="">
+def module_file_deps : Flag<["-"], "module-file-deps">,<br class="">
+ HelpText<"Include module files in dependency output">;<br class="">
def header_include_file : Separate<["-"], "header-include-file">,<br class="">
HelpText<"Filename (or -) to write header include output to">;<br class="">
def show_includes : Flag<["--"], "show-includes">,<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=203885&r1=203884&r2=203885&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=203885&r1=203884&r2=203885&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)<br class="">
+++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Thu Mar 13 22:07:38 2014<br class="">
@@ -26,6 +26,7 @@ public:<br class="">
/// problems.<br class="">
unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list<br class="">
unsigned PrintShowIncludes : 1; ///< Print cl.exe style /showIncludes info.<br class="">
+ unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.<br class="">
<br class="">
/// The file to write dependency output to.<br class="">
std::string OutputFile;<br class="">
@@ -50,6 +51,7 @@ public:<br class="">
UsePhonyTargets = 0;<br class="">
AddMissingHeaderDeps = 0;<br class="">
PrintShowIncludes = 0;<br class="">
+ IncludeModuleFiles = 0;<br class="">
}<br class="">
};<br class="">
<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=203885&r1=203884&r2=203885&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=203885&r1=203884&r2=203885&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)<br class="">
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Mar 13 22:07:38 2014<br class="">
@@ -171,6 +171,9 @@ public:<br class="">
virtual void ReadCounter(const serialization::ModuleFile &M,<br class="">
unsigned Value) {}<br class="">
<br class="">
+ /// This is called for each AST file loaded.<br class="">
+ virtual void visitModuleFile(StringRef Filename) {}<br class="">
+<br class="">
/// \brief Returns true if this \c ASTReaderListener wants to receive the<br class="">
/// input files of the AST file via \c visitInputFile, false otherwise.<br class="">
virtual bool needsInputFileVisitation() { return false; }<br class="">
@@ -217,6 +220,7 @@ public:<br class="">
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;<br class="">
bool needsInputFileVisitation() override;<br class="">
bool needsSystemInputFileVisitation() override;<br class="">
+ void visitModuleFile(StringRef Filename) override;<br class="">
bool visitInputFile(StringRef Filename, bool isSystem,<br class="">
bool isOverridden) override;<br class="">
};<br class="">
<br class="">
Modified: cfe/trunk/lib/Driver/Tools.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=203885&r1=203884&r2=203885&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=203885&r1=203884&r2=203885&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br class="">
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Mar 13 22:07:38 2014<br class="">
@@ -295,6 +295,9 @@ void Clang::AddPreprocessingOptions(Comp<br class="">
if (A->getOption().matches(options::OPT_M) ||<br class="">
A->getOption().matches(options::OPT_MD))<br class="">
CmdArgs.push_back("-sys-header-deps");<br class="">
+<br class="">
+ if (isa<PrecompileJobAction>(JA))<br class="">
+ CmdArgs.push_back("-module-file-deps");<br class="">
}<br class="">
<br class="">
if (Args.hasArg(options::OPT_MG)) {<br class="">
<br class="">
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=203885&r1=203884&r2=203885&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=203885&r1=203884&r2=203885&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)<br class="">
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Mar 13 22:07:38 2014<br class="">
@@ -528,6 +528,7 @@ static void ParseDependencyOutputArgs(De<br class="">
Opts.OutputFile = Args.getLastArgValue(OPT_dependency_file);<br class="">
Opts.Targets = Args.getAllArgValues(OPT_MT);<br class="">
Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps);<br class="">
+ Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps);<br class="">
Opts.UsePhonyTargets = Args.hasArg(OPT_MP);<br class="">
Opts.ShowHeaderIncludes = Args.hasArg(OPT_H);<br class="">
Opts.HeaderIncludeOutputFile = Args.getLastArgValue(OPT_header_include_file);<br class="">
<br class="">
Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=203885&r1=203884&r2=203885&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=203885&r1=203884&r2=203885&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)<br class="">
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Thu Mar 13 22:07:38 2014<br class="">
@@ -40,6 +40,7 @@ class DFGImpl : public PPCallbacks {<br class="">
bool PhonyTarget;<br class="">
bool AddMissingHeaderDeps;<br class="">
bool SeenMissingHeader;<br class="">
+ bool IncludeModuleFiles;<br class="">
private:<br class="">
bool FileMatchesDepCriteria(const char *Filename,<br class="">
SrcMgr::CharacteristicKind FileType);<br class="">
@@ -51,7 +52,8 @@ public:<br class="">
IncludeSystemHeaders(Opts.IncludeSystemHeaders),<br class="">
PhonyTarget(Opts.UsePhonyTargets),<br class="">
AddMissingHeaderDeps(Opts.AddMissingHeaderDeps),<br class="">
- SeenMissingHeader(false) {}<br class="">
+ SeenMissingHeader(false),<br class="">
+ IncludeModuleFiles(Opts.IncludeModuleFiles) {}<br class="">
<br class="">
void FileChanged(SourceLocation Loc, FileChangeReason Reason,<br class="">
SrcMgr::CharacteristicKind FileType,<br class="">
@@ -68,6 +70,7 @@ public:<br class="">
<br class="">
void AddFilename(StringRef Filename);<br class="">
bool includeSystemHeaders() const { return IncludeSystemHeaders; }<br class="">
+ bool includeModuleFiles() const { return IncludeModuleFiles; }<br class="">
};<br class="">
<br class="">
class DFGASTReaderListener : public ASTReaderListener {<br class="">
@@ -79,6 +82,7 @@ public:<br class="">
bool needsSystemInputFileVisitation() override {<br class="">
return Parent.includeSystemHeaders();<br class="">
}<br class="">
+ void visitModuleFile(StringRef Filename) override;<br class="">
bool visitInputFile(StringRef Filename, bool isSystem,<br class="">
bool isOverridden) override;<br class="">
};<br class="">
@@ -268,3 +272,7 @@ bool DFGASTReaderListener::visitInputFil<br class="">
return true;<br class="">
}<br class="">
<br class="">
+void DFGASTReaderListener::visitModuleFile(llvm::StringRef Filename) {<br class="">
+ if (Parent.includeModuleFiles())<br class="">
+ Parent.AddFilename(Filename);<br class="">
+}<br class="">
<br class="">
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=203885&r1=203884&r2=203885&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=203885&r1=203884&r2=203885&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br class="">
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Mar 13 22:07:38 2014<br class="">
@@ -118,6 +118,10 @@ bool ChainedASTReaderListener::needsSyst<br class="">
return First->needsSystemInputFileVisitation() ||<br class="">
Second->needsSystemInputFileVisitation();<br class="">
}<br class="">
+void ChainedASTReaderListener::visitModuleFile(StringRef Filename) {<br class="">
+ First->visitModuleFile(Filename);<br class="">
+ Second->visitModuleFile(Filename);<br class="">
+}<br class="">
bool ChainedASTReaderListener::visitInputFile(StringRef Filename,<br class="">
bool isSystem,<br class="">
bool isOverridden) {<br class="">
@@ -2118,6 +2122,9 @@ ASTReader::ReadControlBlock(ModuleFile &<br class="">
}<br class="">
}<br class="">
<br class="">
+ if (Listener)<br class="">
+ Listener->visitModuleFile(F.FileName);<br class="">
+<br class="">
if (Listener && Listener->needsInputFileVisitation()) {<br class="">
unsigned N = Listener->needsSystemInputFileVisitation() ? NumInputs<br class="">
: NumUserInputs;<br class="">
<br class="">
Added: cfe/trunk/test/Driver/pch-deps.c<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/pch-deps.c?rev=203885&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/pch-deps.c?rev=203885&view=auto</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/test/Driver/pch-deps.c (added)<br class="">
+++ cfe/trunk/test/Driver/pch-deps.c Thu Mar 13 22:07:38 2014<br class="">
@@ -0,0 +1,10 @@<br class="">
+// RUN: %clang -x c-header %s -o %t.pch -MMD -MT dependencies -MF %t.d -### 2> %t<br class="">
+// RUN: FileCheck %s -input-file=%t<br class="">
+// CHECK: -emit-pch<br class="">
+// CHECK: -dependency-file<br class="">
+// CHECK: -module-file-deps<br class="">
+<br class="">
+// RUN: %clang -c %s -o %t -MMD -MT dependencies -MF %t.d -### 2> %t<br class="">
+// RUN: FileCheck %s -check-prefix=CHECK-NOPCH -input-file=%t<br class="">
+// CHECK-NOPCH: -dependency-file<br class="">
+// CHECK-NOPCH-NOT: -module-file-deps<br class="">
<br class="">
Added: cfe/trunk/test/Modules/dependency-gen-pch.m<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen-pch.m?rev=203885&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen-pch.m?rev=203885&view=auto</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/test/Modules/dependency-gen-pch.m (added)<br class="">
+++ cfe/trunk/test/Modules/dependency-gen-pch.m Thu Mar 13 22:07:38 2014<br class="">
@@ -0,0 +1,12 @@<br class="">
+// RUN: rm -rf %t-mcp<br class="">
+// RUN: mkdir -p %t-mcp<br class="">
+<br class="">
+// RUN: %clang_cc1 -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -module-file-deps -dependency-file %t.d -MT %s.o -I %S/Inputs -fmodules -fmodules-cache-path=%t-mcp -emit-pch -o %t.pch %s<br class="">
+// RUN: FileCheck %s < %t.d<br class="">
+// CHECK: dependency-gen-pch.m.o<br class="">
+// CHECK-NEXT: dependency-gen-pch.m<br class="">
+// CHECK-NEXT: diamond_top.pcm<br class="">
+// CHECK-NEXT: Inputs{{.}}diamond_top.h<br class="">
+// CHECK-NEXT: Inputs{{.}}module.map<br class="">
+<br class="">
+#import "diamond_top.h"<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
cfe-commits mailing list<br class="">
<a href="mailto:cfe-commits@cs.uiuc.edu" class="">cfe-commits@cs.uiuc.edu</a><br class="">
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br class="">
</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>