<div dir="ltr">I found the the reason behind the odd behaviour, It's actually normal in my case as my <br>
<span class=""><b>hsOpts</b>.</span><span class=""><b>ResourceDir</b></span> path keeps on changing on every run during Debug build/run process under Xcode.<div><br></div><div><span class=""><b>hsOpts</b>.</span><span class=""><b>ResourceDir </b>path refers to a bundle inside my app. This is the reason why I observe normal as odd </span>behaviour.<br><div><br></div><div>It behaves normally, if I run the app directly on the simulator/device irrespective of build configuration[<b>Debug</b>/<b>Release</b>].</div></div><div><br></div><div>Thanks Daniel for point to the commandline swiftc. I was able to find this only by running swiftc with lldb & my app in Xcode simultaneously, and keeping a Breakpoint at <b>Clang</b>::<span class=""><b>CompilerInvocation</b></span><span class="">::<b>getModuleHash</b>() method.</span></div><div><span class=""><br></span></div><div>cheers</div><div>RK</div>
</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 30, 2016 at 3:02 PM, Ramakrishna Mallireddy <span dir="ltr"><<a href="mailto:ramakrishna.malli@gmail.com" target="_blank">ramakrishna.malli@gmail.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">
<p>No, it doesn't happen. The same flags works fine with swiftc when using from command line. </p><p>swiftc xcode project generated from Ninja have the same issue as I have i.e hash value is different for each run.</p><p>LLVMTest.app is my application that is linked with swift-clang, swift-llvm & swift-2.2.release libraries.</p><p>Following are the commandline arguments that I am using.</p><p><span>const</span><span> </span><span>char</span><span> *argv[] = {sourceFilePath, </span><span>"-target"</span><span>, </span><span>"arm64-apple-ios8.0"</span><span>, </span><span>"-module-cache-path"</span><span>, [moduleCache </span><span>cStringUsingEncoding</span><span>:</span><span>NSUTF8StringEncoding</span><span>], </span><span>"-sdk"</span><span>, sdkpath, </span><span>"-emit-ir"</span><span>, </span><span>"-parse-as-library"</span><span>, </span><span>"-Onone"</span><span>, </span><span>"-o"</span><span>, [destFilePath </span><span>cStringUsingEncoding</span><span>:</span><span>NSUTF8StringEncoding</span><span>]};</span><br></p>
<p><span>The swift front-end entry call.</span></p><p><span>frontend_main</span><span>(</span><span>llvm</span><span>::</span><span>ArrayRef</span><span><</span><span>const</span><span> </span><span>char</span><span> *>(argv, </span><span>13</span><span>), </span><span>"LLVMTest"</span><span>, (</span><span>void</span><span> *)(</span><span>intptr_t</span><span>)</span><span>""</span><span>);</span></p></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 30, 2016 at 9:35 AM, Daniel Dunbar <span dir="ltr"><<a href="mailto:daniel_dunbar@apple.com" target="_blank">daniel_dunbar@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">If the hash value of the module is different then most likely something else is going on -- are you passing any special flags or defines as part of the compiler command? If you run the same command from swiftc on the command line do you see the same behavior?<span><font color="#888888"><div><br></div><div> - Daniel</div></font></span><div><div><div><div><div><br><blockquote type="cite"><div>On Apr 29, 2016, at 2:08 PM, Ramakrishna Mallireddy <<a href="mailto:ramakrishna.malli@gmail.com" target="_blank">ramakrishna.malli@gmail.com</a>> wrote:</div><br><div><div dir="ltr">Every-time I run swift frontend the clang creates a new cachedir with modulecache path hash(on every run the hash value is different for the same input string) as the name of the dir and generates default cocoa framework pcm files inside it.<div><br></div><div>I am using the swift front-end c++ api's to compile a simple swift file.</div><div>If I set the -fdisable-module-hash, then pcm files are generated without the hash as required under the ModuleCache Dir.</div><div>so problem is solved as clang now see the existing pcm files, but now I hit the next hurdle.</div><div><br></div><div>Now the pcm files are there in the cache, when I run the frontend again, I assume clang will load the AST from the pcm files but clang <b>ReadAST </b>returns with<b> </b><b>ASTReader::OutOfDate </b>and as usual it calls<b> </b><b>compileAndLoadModule </b>which I want to avoid in the first place<b>.</b></div><div><br></div><div><span>Call to <b>CLang</b>::</span><b>CompilerInstance</b>::<span><b>ModuleManager</b></span><span>-></span><span><b>ReadAST</b></span><span>(ModuleFileName,</span></div>
<div><p><span> </span><span>serialization</span><span>::</span><span>MK_ImplicitModule</span><span>,</span></p><p><span> ImportLoc, ARRFlags) </span><span>return with </span><b>ASTReader::OutOfDate</b></p><p><span>as </span><span><b>ReadASTCore</b>(FileName, Type, ImportLoc, </span><span> </span><span>/*ImportedBy=*/</span><span>nullptr</span><span>, Loaded, </span><span>0</span><span>, </span><span>0</span><span>, </span><span>0</span><span>, </span>ClientLoadCapabilities) returns with <b>OutOfDate.</b></p><p>These files are generated just few minutes ago, how can it be OutOfDate I don't have any idea.</p><p>File<b> modules.timestamp</b> under the ModuleCache Dir is 0 bytes.</p><p>Thanks</p><p>Ramakrishna</p>
</div>
</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 29, 2016 at 9:15 PM, Daniel Dunbar <span dir="ltr"><<a href="mailto:daniel_dunbar@apple.com" target="_blank">daniel_dunbar@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Clang will cache these automatically, can you give more details on exactly what you are seeing?<br>
<br>
- Daniel<br>
<div><div><br>
> On Apr 28, 2016, at 10:50 PM, Ramakrishna Mallireddy via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:<br>
><br>
> I have these precompiled module files generated every-time I run the swift compiler.<br>
><br>
> _Builtin_stddef_max_align_t-1LMTETLX3WNFT.pcm<br>
> CFNetwork-1UTIO6DPB9R5P.pcm<br>
> CoreFoundation-CF8BGN41VJ11.pcm<br>
> CoreGraphics-3SDFP08OX46EF.pcm<br>
> CoreImage-3SDFP08OX46EF.pcm<br>
> Darwin-4F8STAM1KXDF.pcm<br>
> Foundation-2LQ7EQYFLQOP.pcm<br>
> ...etc<br>
><br>
> How can I make the swift compiler to use these cache rather than compiling the libraries again.<br>
><br>
> Thanks<br>
> Ramakrishna<br>
</div></div>> _______________________________________________<br>
> swift-users mailing list<br>
> <a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
<br>
</blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>