<div dir="ltr">Hi David,<div><br></div><div>On Tue, Dec 15, 2015 at 12:06 AM, Xinliang David Li <span dir="ltr"><<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.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">For the second one, I suggest adding one portability macro for the<br>mode strings in InstrProfilingPort.h.<br></blockquote><div> </div><div>Because the instrprof file is a binary file, isn't it better on any platform to fopen with mode string "ab"?</div><div>I don't see the benefit of making the mode-string "portable", but perhaps I am missing something.</div><div><br></div><div>regards,</div><div> Johan</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 15, 2015 at 12:06 AM, Xinliang David Li <span dir="ltr"><<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.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">Can you submit both fixes to trunk?<br>
<br>
For the second one, I suggest adding one portability macro for the<br>
mode strings in InstrProfilingPort.h.<br>
<br>
thanks,<br>
<br>
David<br>
<div class=""><div class="h5"><br>
On Mon, Dec 14, 2015 at 3:01 PM, Johan Engelen <<a href="mailto:jbc.engelen@gmail.com">jbc.engelen@gmail.com</a>> wrote:<br>
> Hello,<br>
> I recently started using compiler-rt/lib/profile for Instrumentation-based<br>
> PGO in LDC (LLVM D Compiler), but ran into two issues with the code on<br>
> Windows:<br>
> (1) The code does not compile with MSVC because of "__attribute__"<br>
> (2) The file written by InstrProfilingFile.c is in a corrupt format on<br>
> Windows<br>
><br>
><br>
> (1) is easily fixed, and I will submit a patch in a second email.<br>
><br>
><br>
> (2) The file is corrupt because the file is opened in text mode with<br>
> fopen(..., "a"), instead of in binary mode fopen(..., "ab"). With MSVC, this<br>
> means that fwrite will silently add bytes to "fix" line-endings (i.e. 0x0A<br>
> --> 0x0D 0x0A) !<br>
> The bug fix is trivial: open the file explicitly in binary mode.<br>
><br>
> I have attached a patch for the release_37 branch (I much appreciate it if<br>
> it can be committed, because I currently use this version of /lib/profile<br>
> successfully for PGO in LDC), and I have also attached a patch for trunk.<br>
><br>
> (btw, thanks for the work on /lib/profile! It made it very easy to add PGO<br>
> to LDC and worked flawlessly on OS X and Ubuntu!)<br>
><br>
> Cheers,<br>
> Johan<br>
><br>
</div></div></blockquote></div><br></div></div></div></div>