[Compiler-rt] Fix InstrProfilingFile writing on Windows

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 18 09:16:49 PST 2015


On Mon, Dec 14, 2015 at 3:01 PM, Johan Engelen via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>   I recently started using compiler-rt/lib/profile for Instrumentation-based
> PGO in LDC (LLVM D Compiler), but ran into two issues with the code on
> Windows:
> (1) The code does not compile with MSVC because of "__attribute__"
> (2) The file written by InstrProfilingFile.c is in a corrupt format on
> Windows
>
>
> (1) is easily fixed, and I will submit a patch in a second email.
>
>
> (2) The file is corrupt because the file is opened in text mode with
> fopen(..., "a"), instead of in binary mode fopen(..., "ab"). With MSVC, this
> means that fwrite will silently add bytes to "fix" line-endings (i.e. 0x0A
> --> 0x0D 0x0A) !
> The bug fix is trivial: open the file explicitly in binary mode.
>
> I have attached a patch for the release_37 branch (I much appreciate it if
> it can be committed, because I currently use this version of /lib/profile
> successfully for PGO in LDC), and I have also attached a patch for trunk.
>
> (btw, thanks for the work on /lib/profile! It made it very easy to add PGO
> to LDC and worked flawlessly on OS X and Ubuntu!)

CC'ing Tom who manages the 3.7 branch. I believe we just finished
3.7.1, and I don't know if there's any plans to do a 3.7.2.

Thanks,
Hans


More information about the llvm-commits mailing list