<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Aug 11, 2015 at 8:38 PM Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Those files were parsed as part of building the output, and are legitimate dependencies of the compilation process; why do you want to suppress them from the .d file? (I think adding a whole bunch of -fno-*-deps flags is going in the wrong direction, and would like to understand if there's some higher-level notion that we should instead be capturing here.)</div></blockquote><div><br></div><div>You're right, that makes sense. We'll just need to adapt our build system to work with that.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 11, 2015 at 11:27 AM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Ah, so we need a flag -fno-module-map-file-deps, I assume...</div><div><div><br><div class="gmail_quote"><div dir="ltr">On Tue, Aug 11, 2015 at 8:12 PM Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 11, 2015 at 4:57 AM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I believe this breaks -fno-module-file-deps.</div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>I don't think so; this affects which module map files end up in the .d file, not which .pcm files do.</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div class="gmail_quote"><div dir="ltr">On Sun, Aug 9, 2015 at 6:47 AM Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Sat Aug 8 23:46:57 2015<br>
New Revision: 244413<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244413&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244413&view=rev</a><br>
Log:<br>
[modules] When building a dependency file, include module maps parsed in the<br>
current compilation, not just those from imported modules.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Lex/ModuleMap.h<br>
cfe/trunk/lib/Frontend/DependencyFile.cpp<br>
cfe/trunk/lib/Lex/ModuleMap.cpp<br>
cfe/trunk/test/Modules/dependency-gen-pch.m<br>
cfe/trunk/test/Modules/dependency-gen.m<br>
cfe/trunk/test/Modules/dependency-gen.modulemap<br>
cfe/trunk/test/Modules/relative-dep-gen.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Lex/ModuleMap.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=244413&r1=244412&r2=244413&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=244413&r1=244412&r2=244413&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)<br>
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Sat Aug 8 23:46:57 2015<br>
@@ -35,6 +35,22 @@ class DiagnosticConsumer;<br>
class DiagnosticsEngine;<br>
class HeaderSearch;<br>
class ModuleMapParser;<br>
+<br>
+/// \brief A mechanism to observe the actions of the module map parser as it<br>
+/// reads module map files.<br>
+class ModuleMapCallbacks {<br>
+public:<br>
+ virtual ~ModuleMapCallbacks() {}<br>
+<br>
+ /// \brief Called when a module map file has been read.<br>
+ ///<br>
+ /// \param FileStart A SourceLocation referring to the start of the file's<br>
+ /// contents.<br>
+ /// \param File The file itself.<br>
+ /// \param IsSystem Whether this is a module map from a system include path.<br>
+ virtual void moduleMapFileRead(SourceLocation FileStart,<br>
+ const FileEntry &File, bool IsSystem) {}<br>
+};<br>
<br>
class ModuleMap {<br>
SourceManager &SourceMgr;<br>
@@ -42,6 +58,8 @@ class ModuleMap {<br>
const LangOptions &LangOpts;<br>
const TargetInfo *Target;<br>
HeaderSearch &HeaderInfo;<br>
+<br>
+ llvm::SmallVector<std::unique_ptr<ModuleMapCallbacks>, 1> Callbacks;<br>
<br>
/// \brief The directory used for Clang-supplied, builtin include headers,<br>
/// such as "stdint.h".<br>
@@ -263,6 +281,11 @@ public:<br>
BuiltinIncludeDir = Dir;<br>
}<br>
<br>
+ /// \brief Add a module map callback.<br>
+ void addModuleMapCallbacks(std::unique_ptr<ModuleMapCallbacks> Callback) {<br>
+ Callbacks.push_back(std::move(Callback));<br>
+ }<br>
+<br>
/// \brief Retrieve the module that owns the given header file, if any.<br>
///<br>
/// \param File The header file that is likely to be included.<br>
<br>
Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=244413&r1=244412&r2=244413&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=244413&r1=244412&r2=244413&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Sat Aug 8 23:46:57 2015<br>
@@ -18,6 +18,7 @@<br>
#include "clang/Frontend/FrontendDiagnostic.h"<br>
#include "clang/Lex/DirectoryLookup.h"<br>
#include "clang/Lex/LexDiagnostic.h"<br>
+#include "clang/Lex/ModuleMap.h"<br>
#include "clang/Lex/PPCallbacks.h"<br>
#include "clang/Lex/Preprocessor.h"<br>
#include "clang/Serialization/ASTReader.h"<br>
@@ -82,6 +83,20 @@ struct DepCollectorPPCallbacks : public<br>
}<br>
};<br>
<br>
+struct DepCollectorMMCallbacks : public ModuleMapCallbacks {<br>
+ DependencyCollector &DepCollector;<br>
+ DepCollectorMMCallbacks(DependencyCollector &DC) : DepCollector(DC) {}<br>
+<br>
+ void moduleMapFileRead(SourceLocation Loc, const FileEntry &Entry,<br>
+ bool IsSystem) override {<br>
+ StringRef Filename = Entry.getName();<br>
+ DepCollector.maybeAddDependency(Filename, /*FromModule*/false,<br>
+ /*IsSystem*/IsSystem,<br>
+ /*IsModuleFile*/false,<br>
+ /*IsMissing*/false);<br>
+ }<br>
+};<br>
+<br>
struct DepCollectorASTListener : public ASTReaderListener {<br>
DependencyCollector &DepCollector;<br>
DepCollectorASTListener(DependencyCollector &L) : DepCollector(L) { }<br>
@@ -132,6 +147,8 @@ DependencyCollector::~DependencyCollecto<br>
void DependencyCollector::attachToPreprocessor(Preprocessor &PP) {<br>
PP.addPPCallbacks(<br>
llvm::make_unique<DepCollectorPPCallbacks>(*this, PP.getSourceManager()));<br>
+ PP.getHeaderSearchInfo().getModuleMap().addModuleMapCallbacks(<br>
+ llvm::make_unique<DepCollectorMMCallbacks>(*this));<br>
}<br>
void DependencyCollector::attachToASTReader(ASTReader &R) {<br>
R.addListener(llvm::make_unique<DepCollectorASTListener>(*this));<br>
@@ -185,6 +202,17 @@ public:<br>
bool includeModuleFiles() const { return IncludeModuleFiles; }<br>
};<br>
<br>
+class DFGMMCallback : public ModuleMapCallbacks {<br>
+ DFGImpl &Parent;<br>
+public:<br>
+ DFGMMCallback(DFGImpl &Parent) : Parent(Parent) {}<br>
+ void moduleMapFileRead(SourceLocation Loc, const FileEntry &Entry,<br>
+ bool IsSystem) override {<br>
+ if (!IsSystem || Parent.includeSystemHeaders())<br>
+ Parent.AddFilename(Entry.getName());<br>
+ }<br>
+};<br>
+<br>
class DFGASTReaderListener : public ASTReaderListener {<br>
DFGImpl &Parent;<br>
public:<br>
@@ -217,6 +245,8 @@ DependencyFileGenerator *DependencyFileG<br>
<br>
DFGImpl *Callback = new DFGImpl(&PP, Opts);<br>
PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(Callback));<br>
+ PP.getHeaderSearchInfo().getModuleMap().addModuleMapCallbacks(<br>
+ llvm::make_unique<DFGMMCallback>(*Callback));<br>
return new DependencyFileGenerator(Callback);<br>
}<br>
<br>
<br>
Modified: cfe/trunk/lib/Lex/ModuleMap.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=244413&r1=244412&r2=244413&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=244413&r1=244412&r2=244413&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)<br>
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Sat Aug 8 23:46:57 2015<br>
@@ -2335,9 +2335,14 @@ bool ModuleMap::parseModuleMapFile(const<br>
<br>
// Parse this module map file.<br>
Lexer L(ID, SourceMgr.getBuffer(ID), SourceMgr, MMapLangOpts);<br>
+ SourceLocation Start = L.getSourceLocation();<br>
ModuleMapParser Parser(L, SourceMgr, Target, Diags, *this, File, Dir,<br>
BuiltinIncludeDir, IsSystem);<br>
bool Result = Parser.parseModuleMapFile();<br>
ParsedModuleMap[File] = Result;<br>
+<br>
+ // Notify callbacks that we parsed it.<br>
+ for (const auto &Cb : Callbacks)<br>
+ Cb->moduleMapFileRead(Start, *File, IsSystem);<br>
return Result;<br>
}<br>
<br>
Modified: cfe/trunk/test/Modules/dependency-gen-pch.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen-pch.m?rev=244413&r1=244412&r2=244413&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen-pch.m?rev=244413&r1=244412&r2=244413&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/dependency-gen-pch.m (original)<br>
+++ cfe/trunk/test/Modules/dependency-gen-pch.m Sat Aug 8 23:46:57 2015<br>
@@ -6,8 +6,8 @@<br>
// RUN: FileCheck %s < %t.d<br>
// CHECK: dependency-gen-pch.m.o<br>
// CHECK-NEXT: dependency-gen-pch.m<br>
+// CHECK-NEXT: Inputs{{.}}module.map<br>
// CHECK-NEXT: diamond_top.pcm<br>
// CHECK-NEXT: Inputs{{.}}diamond_top.h<br>
-// CHECK-NEXT: Inputs{{.}}module.map<br>
<br>
#import "diamond_top.h"<br>
<br>
Modified: cfe/trunk/test/Modules/dependency-gen.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen.m?rev=244413&r1=244412&r2=244413&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen.m?rev=244413&r1=244412&r2=244413&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/dependency-gen.m (original)<br>
+++ cfe/trunk/test/Modules/dependency-gen.m Sat Aug 8 23:46:57 2015<br>
@@ -4,8 +4,8 @@<br>
// RUN: %clang_cc1 -x objective-c -isystem %S/Inputs/System/usr/include -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-mcp %s<br>
// RUN: FileCheck %s < %t.d.1<br>
// CHECK: dependency-gen.m<br>
-// CHECK: Inputs{{.}}diamond_top.h<br>
// CHECK: Inputs{{.}}module.map<br>
+// CHECK: Inputs{{.}}diamond_top.h<br>
// CHECK-NOT: usr{{.}}include{{.}}module.map<br>
// CHECK-NOT: stdint.h<br>
<br>
@@ -13,8 +13,8 @@<br>
// RUN: %clang_cc1 -x objective-c -isystem %S/Inputs/System/usr/include -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-mcp %s<br>
// RUN: FileCheck %s -check-prefix=CHECK-SYS < %t.d.2<br>
// CHECK-SYS: dependency-gen.m<br>
-// CHECK-SYS: Inputs{{.}}diamond_top.h<br>
// CHECK-SYS: Inputs{{.}}module.map<br>
+// CHECK-SYS: Inputs{{.}}diamond_top.h<br>
// CHECK-SYS: usr{{.}}include{{.}}module.map<br>
// CHECK-SYS: stdint.h<br>
<br>
<br>
Modified: cfe/trunk/test/Modules/dependency-gen.modulemap<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen.modulemap?rev=244413&r1=244412&r2=244413&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen.modulemap?rev=244413&r1=244412&r2=244413&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/dependency-gen.modulemap (original)<br>
+++ cfe/trunk/test/Modules/dependency-gen.modulemap Sat Aug 8 23:46:57 2015<br>
@@ -15,5 +15,10 @@ module "test" {<br>
extern module "test-base2" "Inputs/dependency-gen-base2.modulemap"<br>
extern module "test-base" "Inputs/dependency-gen-base.modulemap"<br>
<br>
-// CHECK: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included2.h<br>
-// CHECK: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base.modulemap<br>
+// CHECK-DAG: {{[/\\]}}dependency-gen.modulemap<br>
+// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base.modulemap<br>
+// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base2.modulemap<br>
+<br>
+// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h<br>
+// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included.h<br>
+// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included2.h<br>
<br>
Modified: cfe/trunk/test/Modules/relative-dep-gen.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/relative-dep-gen.cpp?rev=244413&r1=244412&r2=244413&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/relative-dep-gen.cpp?rev=244413&r1=244412&r2=244413&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/relative-dep-gen.cpp (original)<br>
+++ cfe/trunk/test/Modules/relative-dep-gen.cpp Sat Aug 8 23:46:57 2015<br>
@@ -20,5 +20,11 @@<br>
<br>
#include "Inputs/relative-dep-gen-1.h"<br>
<br>
-// CHECK-BUILD: mod.pcm: Inputs/relative-dep-gen-1.h Inputs/relative-dep-gen-2.h<br>
-// CHECK-USE: use.o: relative-dep-gen.cpp Inputs/relative-dep-gen-1.h<br>
+// CHECK-BUILD: mod.pcm:<br>
+// CHECK-BUILD: Inputs/relative-dep-gen{{(-cwd)?}}.modulemap<br>
+// CHECK-BUILD: Inputs/relative-dep-gen-1.h<br>
+// CHECK-BUILD: Inputs/relative-dep-gen-2.h<br>
+// CHECK-USE: use.o:<br>
+// CHECK-USE: Inputs/relative-dep-gen{{(-cwd)?}}.modulemap<br>
+// CHECK-USE: relative-dep-gen.cpp<br>
+// CHECK-USE: Inputs/relative-dep-gen-1.h<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</div></div></blockquote></div></div></div></blockquote></div>
</div></div></blockquote></div><br></div></div></blockquote></div></div>