<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Mar 15, 2013, at 4:33 PM, Jean-Daniel Dupas <<a href="mailto:devlists@shadowlab.org">devlists@shadowlab.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">Out of curiosity, what happen while compiling on Darwin without specifying an sdkroot as in such case, it uses headers from /System directly and will not be able to locate a SDKSettings.plist file.<br></div></blockquote><div><br></div>If there is no SDKSettings.plist file, then we won't add a dependency on it. The net effect is that modules will not automatically rebuild if you (say) hack your system headers.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div><div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><br><br>Le 15 mars 2013 à 23:15, Douglas Gregor <<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>> a écrit :<br><br><blockquote type="cite">Author: dgregor<br>Date: Fri Mar 15 17:15:07 2013<br>New Revision: 177194<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=177194&view=rev">http://llvm.org/viewvc/llvm-project?rev=177194&view=rev</a><br>Log:<br><<a href="rdar://problem/13426257">rdar://problem/13426257</a>> Introduce SDKSettings.plist as an input file dependency for PCH/modules.<br><br>When we're building a precompiled header or module against an SDK on<br>Darwin, there will be a file SDKSettings.plist in the sysroot. Since<br>stat()'ing every system header on which a module or PCH file depends<br>is performance suicide, we instead stat() just SDKSettings.plist. This<br>hack works well on Darwin; it's unclear how we want to handle this on<br>other platforms. If there is a canonical file, we should use it; if<br>not, we either have to take the performance hit of stat()'ing system<br>headers repeatedly or roll the dice by not checking anything.<br><br>Modified:<br>  cfe/trunk/include/clang/Serialization/ASTWriter.h<br>  cfe/trunk/lib/Serialization/ASTWriter.cpp<br><br>Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=177194&r1=177193&r2=177194&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=177194&r1=177193&r2=177194&view=diff</a><br>==============================================================================<br>--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)<br>+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Fri Mar 15 17:15:07 2013<br>@@ -48,6 +48,7 @@ class CXXCtorInitializer;<br>class FileEntry;<br>class FPOptions;<br>class HeaderSearch;<br>+class HeaderSearchOptions;<br>class IdentifierResolver;<br>class MacroDefinition;<br>class OpaqueValueExpr;<br>@@ -416,7 +417,9 @@ private:<br> void WriteBlockInfoBlock();<br> void WriteControlBlock(Preprocessor &PP, ASTContext &Context,<br>                        StringRef isysroot, const std::string &OutputFile);<br>-  void WriteInputFiles(SourceManager &SourceMgr, StringRef isysroot);<br>+  void WriteInputFiles(SourceManager &SourceMgr,<br>+                       HeaderSearchOptions &HSOpts,<br>+                       StringRef isysroot);<br> void WriteSourceManagerBlock(SourceManager &SourceMgr,<br>                              const Preprocessor &PP,<br>                              StringRef isysroot);<br><br>Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=177194&r1=177193&r2=177194&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=177194&r1=177193&r2=177194&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br>+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Mar 15 17:15:07 2013<br>@@ -1213,11 +1213,24 @@ void ASTWriter::WriteControlBlock(Prepro<br>   Stream.EmitRecordWithBlob(AbbrevCode, Record, origDir);<br> }<br><br>-  WriteInputFiles(Context.SourceMgr, isysroot);<br>+  WriteInputFiles(Context.SourceMgr,<br>+                  PP.getHeaderSearchInfo().getHeaderSearchOpts(),<br>+                  isysroot);<br> Stream.ExitBlock();<br>}<br><br>-void ASTWriter::WriteInputFiles(SourceManager &SourceMgr, StringRef isysroot) {<br>+namespace  {<br>+  /// \brief An input file.<br>+  struct InputFileEntry {<br>+    const FileEntry *File;<br>+    bool IsSystemFile;<br>+    bool BufferOverridden;<br>+  };<br>+}<br>+<br>+void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,<br>+                                HeaderSearchOptions &HSOpts,<br>+                                StringRef isysroot) {<br> using namespace llvm;<br> Stream.EnterSubblock(INPUT_FILES_BLOCK_ID, 4);<br> RecordData Record;<br>@@ -1234,7 +1247,7 @@ void ASTWriter::WriteInputFiles(SourceMa<br><br> // Get all ContentCache objects for files, sorted by whether the file is a<br> // system one or not. System files go at the back, users files at the front.<br>-  std::deque<const SrcMgr::ContentCache *> SortedFiles;<br>+  std::deque<InputFileEntry> SortedFiles;<br> for (unsigned I = 1, N = SourceMgr.local_sloc_entry_size(); I != N; ++I) {<br>   // Get this source location entry.<br>   const SrcMgr::SLocEntry *SLoc = &SourceMgr.getLocalSLocEntry(I);<br>@@ -1247,20 +1260,38 @@ void ASTWriter::WriteInputFiles(SourceMa<br>   if (!Cache->OrigEntry)<br>     continue;<br><br>+    InputFileEntry Entry;<br>+    Entry.File = Cache->OrigEntry;<br>+    Entry.IsSystemFile = Cache->IsSystemFile;<br>+    Entry.BufferOverridden = Cache->BufferOverridden;<br>   if (Cache->IsSystemFile)<br>-      SortedFiles.push_back(Cache);<br>+      SortedFiles.push_back(Entry);<br>   else<br>-      SortedFiles.push_front(Cache);<br>+      SortedFiles.push_front(Entry);<br>+  }<br>+<br>+  // If we have an isysroot for a Darwin SDK, include its SDKSettings.plist in<br>+  // the set of (non-system) input files. This is simple heuristic for<br>+  // detecting whether the system headers may have changed, because it is too<br>+  // expensive to stat() all of the system headers.<br>+  FileManager &FileMgr = SourceMgr.getFileManager();<br>+  if (!HSOpts.Sysroot.empty()) {<br>+    llvm::SmallString<128> SDKSettingsFileName(HSOpts.Sysroot);<br>+    llvm::sys::path::append(SDKSettingsFileName, "SDKSettings.plist");<br>+    if (const FileEntry *SDKSettingsFile = FileMgr.getFile(SDKSettingsFileName)) {<br>+      InputFileEntry Entry = { SDKSettingsFile, false, false };<br>+      SortedFiles.push_front(Entry);<br>+    }<br> }<br><br> unsigned UserFilesNum = 0;<br> // Write out all of the input files.<br> std::vector<uint32_t> InputFileOffsets;<br>-  for (std::deque<const SrcMgr::ContentCache *>::iterator<br>+  for (std::deque<InputFileEntry>::iterator<br>        I = SortedFiles.begin(), E = SortedFiles.end(); I != E; ++I) {<br>-    const SrcMgr::ContentCache *Cache = *I;<br>+    const InputFileEntry &Entry = *I;<br><br>-    uint32_t &InputFileID = InputFileIDs[Cache->OrigEntry];<br>+    uint32_t &InputFileID = InputFileIDs[Entry.File];<br>   if (InputFileID != 0)<br>     continue; // already recorded this file.<br><br>@@ -1269,7 +1300,7 @@ void ASTWriter::WriteInputFiles(SourceMa<br><br>   InputFileID = InputFileOffsets.size();<br><br>-    if (!Cache->IsSystemFile)<br>+    if (!Entry.IsSystemFile)<br>     ++UserFilesNum;<br><br>   Record.clear();<br>@@ -1277,19 +1308,19 @@ void ASTWriter::WriteInputFiles(SourceMa<br>   Record.push_back(InputFileOffsets.size());<br><br>   // Emit size/modification time for this file.<br>-    Record.push_back(Cache->OrigEntry->getSize());<br>-    Record.push_back(Cache->OrigEntry->getModificationTime());<br>+    Record.push_back(Entry.File->getSize());<br>+    Record.push_back(Entry.File->getModificationTime());<br><br>   // Whether this file was overridden.<br>-    Record.push_back(Cache->BufferOverridden);<br>+    Record.push_back(Entry.BufferOverridden);<br><br>   // Turn the file name into an absolute path, if it isn't already.<br>-    const char *Filename = Cache->OrigEntry->getName();<br>+    const char *Filename = Entry.File->getName();<br>   SmallString<128> FilePath(Filename);<br><br>   // Ask the file manager to fixup the relative path for us. This will<span class="Apple-converted-space"> </span><br>   // honor the working directory.<br>-    SourceMgr.getFileManager().FixupRelativePath(FilePath);<br>+    FileMgr.FixupRelativePath(FilePath);<br><br>   // FIXME: This call to make_absolute shouldn't be necessary, the<br>   // call to FixupRelativePath should always return an absolute path.<br>@@ -1300,7 +1331,7 @@ void ASTWriter::WriteInputFiles(SourceMa<br><br>   Stream.EmitRecordWithBlob(IFAbbrevCode, Record, Filename);<br> }  <br>-  <br>+<br> Stream.ExitBlock();<br><br> // Create input file offsets abbreviation.<br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits<br></blockquote><br>-- Jean-Daniel</div></blockquote></div><br></body></html>