<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 14, 2015 at 3:21 AM, Robinson, Paul <span dir="ltr"><<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><a name="14cb5bb98a3a80c4__MailEndCompose"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Re not producing nmake-style depfiles, it is more persuasive to me that no version of CL since 6.0 (obsolete for a decade or so) has
 supported producing them, so why should Clang.<u></u><u></u></span></a></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">But that's not the end of it!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">tl;dr:  We need to escape the backslashes too, regardless of platform.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">(The long version…)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">If backslashes are the escape character, they ought to be escaped…. leaving aside their semantic significance on Windows, that seems like an oversight in its
 own right.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I ran an experiment on Linux…<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ cat t.c<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">#include "foo\bar.h" /* C99 6.4.7, this is not a normal C string */<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">#include "bar#foo.h"<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">int I;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ touch foo\\bar.h<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ touch bar\#foo.h<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ # gcc accepts this<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ gcc -c -MD t.c<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ # but doesn't escape the backslash in the dependency file<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ cat t.d<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">t.o: t.c /usr/include/stdc-predef.h foo\bar.h bar\#foo.h<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ # make will accept the single-backslash dependency<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ make –f t.d t.o<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">make: `t.o' is up to date.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ touch foo\\bar.h<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ make –f t.d t.o<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">cc –c –o t.o t.c<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ # Will make tolerate an escaped backslash?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ cat t.d<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">t.o: t.c /usr/include/stdc-predef.h foo\\bar.h bar\#foo.h<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ make –f t.d t.o<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">make: `t.o' is up to date.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ touch foo\\bar.h<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">$ make –f t.d t.o<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">cc –c –o t.o t.c<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">So, gcc doesn't escape backslashes when writing the .d file, but make will tolerate this gcc bug and accept escaped or un-escaped backslashes.</span></p></div></div></blockquote><div><br></div><div>GCC does escape backslashes, using a very specific logic that matches that matches what gnu make accepts. See <a href="https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libcpp/mkdeps.c;h=78bbf09a0cc8c3ba0fe974b55e1ededf02c66665;hb=HEAD#l47">https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libcpp/mkdeps.c;h=78bbf09a0cc8c3ba0fe974b55e1ededf02c66665;hb=HEAD#l47</a></div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">In fact, further experiments (not shown here) show that make will *first* try to interpret the backslash as an escape character, and if that doesn't find a
 matching filename, it falls back to treating the backslash as a non-special character.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Therefore, I think it is always safe to escape backslashes, and that behavior doesn't have to be conditioned on Windows/non-Windows.</span></p></div></div></blockquote><div><br></div><div><div>Make's input format is extremely esoteric: <a href="http://git.savannah.gnu.org/cgit/make.git/tree/read.c">http://git.savannah.gnu.org/cgit/make.git/tree/read.c</a></div><div>It even varies by platform and build configuration. Unless we are confident that our testing has covered the build configurations and platforms that any user of clang's gcc-compatible driver is likely to encounter, I would hesitate to conclude something is "safe".</div></div><div><br></div><div>The bottom line is that unless we have a good reason, we should exactly match GCC's output format (see the source link above). A "good reason" should probably take the form of a bug report against GCC.</div><div><br></div><div>Shoring up our depfile output to match GCC's is probably the most immediate improvement to be made in clang's gcc-compatible depfile output. Our current behavior is close to GCC's but does not handle whitespace escaping in the same way, which causes our makefiles to be incompatible e.g. in the `#include "foo\ bar.h"` corner case, where our output is broken but GCC's works.<br></div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Yet even further experiments (not shown here) demonstrate that Windows doesn't mind having a directory name with a *leading* space or hash (because… Windows). 
 Therefore, on Windows we *must* escape any backslashes, so that <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">#include "foo\ bar.h"<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">(the file <space>bar.h in subdirectory foo) ends up correctly escaped in the .d file thusly:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:'Courier New';color:rgb(31,73,125)">t.o: foo\\\ bar.h</span></p></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">That is, the first two backslashes will be treated as a single backslash (& directory separator on Windows) while the third backslash escapes the space so that
 make won't treat the space as the end of the filespec.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">--paulr<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<div style="border-style:none none none solid;border-left-color:blue;border-left-width:1.5pt;padding:0in 0in 0in 4pt">
<div>
<div style="border-style:solid none none;border-top-color:rgb(181,196,223);border-top-width:1pt;padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> Sean Silva [mailto:<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>]
<br>
<b>Sent:</b> Monday, April 13, 2015 3:48 PM<br>
<b>To:</b> Yaron Keren<br>
<b>Cc:</b> Yung, Douglas; Robinson, Paul; <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a></span></p><div><div class="h5"><br>
<b>Subject:</b> Re: [PATCH] Fix Windows path formatting when using -MD<u></u><u></u></div></div><p></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Sat, Apr 11, 2015 at 9:32 AM, Yaron Keren <<a href="mailto:yaron.keren@gmail.com" target="_blank">yaron.keren@gmail.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">LLVM_ON_WIN32 is true for mingw and cygwin which always use gcc make.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">For nmake vs make issue Driver::IsCLMode() could be used.<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Why? No program I'm aware of passes -M* options to (clang-)cl.exe expecting nmake depfiles. If we want to add a new feature to support a new use case, we shouldn't add it as a weird implicit behavior. If we do want to add this as a feature
 to clang, we should just add a way to explicitly say "use nmake format for depfiles". Still, I don't know of any program that uses or would use nmake depfile output.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">-- Sean Silva<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">2015-04-11 2:46 GMT+03:00 Yung, Douglas <<a href="mailto:douglas_yung@playstation.sony.com" target="_blank">douglas_yung@playstation.sony.com</a>>:<u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I got the same results as Sean. I guess the question now is if we want to support generating nmake
 compatible output, and if so, should we do it using a switch similar to how Intel has done it at the link Sean provided.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Douglas Yung</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<div style="border-style:solid none none;border-top-color:rgb(181,196,223);border-top-width:1pt;padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> Sean Silva [mailto:<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>]
<br>
<b>Sent:</b> Friday, April 10, 2015 16:32<br>
<b>To:</b> Robinson, Paul<br>
<b>Cc:</b> Yung, Douglas; <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">
llvm-commits@cs.uiuc.edu</a></span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><br>
<b>Subject:</b> Re: [PATCH] Fix Windows path formatting when using -MD<u></u><u></u></p>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Fri, Apr 10, 2015 at 11:13 AM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Hi Sean,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Were you trying that on Windows?  My understanding is that Microsoft's NMAKE wants quoted filespecs
 and will think backslashes are directory delimiters.</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I'm seeing:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">foo: bar\ baz<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">NMAKE : fatal error U1073: don't know how to make 'bar\'<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">foo: "bar baz"<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">NMAKE : fatal error U1073: don't know how to make '"bar baz"'<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">(but note that '"bar baz"' is actually satisfied by a file called `bar baz`; so nmake is not interpreting the quotes as part of the file name)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I wasn't able to find a specific reference for the nmake syntax, but from these experiments, it is clear that nmake is incompatible and a gcc compatible driver that outputs nmake
 dependency files is broken. We obviously cannot change our gcc-compatible dependency files as that would break users (they may be using a unix make on windows).<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">It appears that when Intel implemented dependency file generation in their Fortran compiler, they needed to have two different modes for make and nmake. See the last two posts in <a href="https://software.intel.com/en-us/forums/topic/269853" target="_blank">https://software.intel.com/en-us/forums/topic/269853</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">-- Sean Silva<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">--paulr</span><u></u><u></u></p>
<p class="MsoNormal"><a name="14cb5bb98a3a80c4_14ca79c71ec9ff8f_14ca5bdbf8cb35da_14ca48"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span></a><u></u><u></u></p>
<div style="border-style:none none none solid;border-left-color:blue;border-left-width:1.5pt;padding:0in 0in 0in 4pt">
<div>
<div style="border-style:solid none none;border-top-color:rgb(181,196,223);border-top-width:1pt;padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif">
<a href="mailto:llvm-commits-bounces@cs.uiuc.edu" target="_blank">llvm-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvm-commits-bounces@cs.uiuc.edu" target="_blank">llvm-commits-bounces@cs.uiuc.edu</a>]
<b>On Behalf Of </b>Yung, Douglas<br>
<b>Sent:</b> Thursday, April 09, 2015 5:17 PM<br>
<b>To:</b> Sean Silva<br>
<b>Cc:</b> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> RE: [PATCH] Fix Windows path formatting when using -MD</span><u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Hi Sean, what you are saying does make sense, I’ll talk with the team that owns the tool to see.
 Thanks!</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Douglas Yung</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<div style="border-style:solid none none;border-top-color:rgb(181,196,223);border-top-width:1pt;padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> Sean Silva [<a href="mailto:chisophugis@gmail.com" target="_blank">mailto:chisophugis@gmail.com</a>]
<br>
<b>Sent:</b> Thursday, April 09, 2015 17:11<br>
<b>To:</b> Yung, Douglas<br>
<b>Cc:</b> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [PATCH] Fix Windows path formatting when using -MD</span><u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Actually, looking at this, I think that the root cause of your problem is that your tool is not interpreting the makefile properly. This patch will break every program that properly
 reads makefiles. Please verify that your tool interprets the attached file "Makefile" as a file "foo" depending on a file "bar baz". This is the output of BSD make and GNU make:<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">Sean:~/tmp/testmake % make<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">make: *** No rule to make target `bar baz', needed by `foo'.  Stop.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">zsh: exit 2     make<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Sean:~/tmp/testmake % gnumake<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">gnumake: *** No rule to make target `bar baz', needed by `foo'.  Stop.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">zsh: exit 2     gnumake<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">If instead of bar\ baz I write "bar baz" (see attached file "broken"), as your patch causes us to do, then this is the output:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">Sean:~/tmp/testmake % make -f broken<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">make: *** No rule to make target `"bar', needed by `foo'.  Stop.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">zsh: exit 2     make -f broken<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Sean:~/tmp/testmake % gnumake -f broken<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">gnumake: *** No rule to make target `"bar', needed by `foo'.  Stop.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">zsh: exit 2     gnumake -f broken<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Please verify that your tool inteprets the makefile in this way. i.e. `"bar baz"` is actually two files `"bar` and `baz"`.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">-- Sean Silva<u></u><u></u></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Thu, Apr 9, 2015 at 4:55 PM, Sean Silva <<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>> wrote:<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Thu, Apr 9, 2015 at 3:33 PM, Yung, Douglas <<a href="mailto:douglas_yung@playstation.sony.com" target="_blank">douglas_yung@playstation.sony.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Hi Sean,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">The program we are using that consumes the compiler’s –MD output is a tool that we produce which
 parses the output to provide integration with Visual Studio.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I agree that the example you gave of OpenFile(“\”foo.txt\””) would not be valid, although I’m not
 sure that the compiler would even generate that on Windows. According to the MSDN documentation (<a href="https://msdn.microsoft.com/en-us/library/aa365247" target="_blank">https://msdn.microsoft.com/en-us/library/aa365247</a>), a double quote is not a valid
 character for a filename, so the compiler should never even reach this point in the code because the compiler would have been unable to resolve the reference to begin with.</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">No, I mean that any tool that actually reads the makefiles produced by this patch would end up with paths like "\"foo.txt\"". That your tool is interpreting the output of this patch
 the way you want indicates that it is not actually correctly parsing the makefile syntax.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">E.g. a makefile like this:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">foo.o: "C:\Program Files\bar.h"<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">actually means that "foo.o" depends on "\"C:\Program Files\bar.h\"". If your tool does not interpret it like this, then your tool is not interpreting the makefile correctly.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">-- Sean Silva<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Douglas Yung</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<div style="border-style:solid none none;border-top-color:rgb(181,196,223);border-top-width:1pt;padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> Sean Silva [mailto:<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>]
<br>
<b>Sent:</b> Thursday, April 09, 2015 14:57<br>
<b>To:</b> Yung, Douglas<br>
<b>Cc:</b> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [PATCH] Fix Windows path formatting when using -MD</span><u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Thu, Apr 9, 2015 at 12:27 PM, Yung, Douglas <<a href="mailto:douglas_yung@playstation.sony.com" target="_blank">douglas_yung@playstation.sony.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">This patch fixes a problem on Windows when the compiler generates a dependency file using –MD or –MMD. The problem is that when emitting a path that contains spaces, the compiler
 emits it by escaping the spaces with a leading backspace character which is not valid in Windows. The proper fix for this is to just emit the path enclosed in double quotes which is accepted by Windows. This patch makes that change, and the compiler will then
 generate the double quoted paths only when the compiler is hosted on Windows. It also updates 3 tests that were affected by this change to accept this change on Windows as well as verify the change works as expected.<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">What program are you using that consumes makefiles and interprets quoted strings? Quoted strings are not part of Makefile syntax. This will result in programs making calls like
 OpenFile("\"foo.txt\"") which I don't think is valid.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">-- Sean Silva<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal"><span style="color:rgb(136,136,136)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(136,136,136)">Douglas Yung</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12pt"><br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12pt"><br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br></div></div>