<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 9 July 2013 00:10, Magnus Reftel <span dir="ltr"><<a href="mailto:magnus.reftel@gmail.com" target="_blank">magnus.reftel@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 class="HOEnZb"><div class="h5">On 8 July 2013 22:44, Nick Lewycky <<a href="mailto:nlewycky@google.com">nlewycky@google.com</a>> wrote:<br>


> On 8 July 2013 00:24, mbm_kalpesh <<a href="mailto:mbm_kalpesh@yahoo.co.in">mbm_kalpesh@yahoo.co.in</a>> wrote:<br>
>><br>
>> Hi,<br>
>> I know how to use GCOV and LCOV to get code coverage on GCC.<br>
>> But This time i need to use clang and get instrumented binaries and code<br>
>> coverage.<br>
>><br>
>> Please help (not able to find much info yet). Tried using -fprofile-arcs<br>
>> and<br>
>> -ftest-coverage. code is compiling fine but giving link errors.<br>
><br>
><br>
> The profiling library in gcc is called "libgcov", but clang has its own<br>
> named "libprofile_rt" and you need to link against that. The --coverage flag<br>
> implies -lprofile_rt when linking, or you can pass -lprofile_rt yourself.<br>
><br>
> The code for libprofile_rt is part of compiler-rt:<br>
> <a href="http://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/profile/" target="_blank">http://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/profile/</a> . If you<br>
> don't have libprofile_rt, you'll need to build it.<br>
<br>
</div></div>Note that the default coverage information format is for llvm-cov. If<br>
you want to use gcov for some reason, you'll need to specify the<br>
options "-Xclang -coverage-cfg-checksum -Xclang<br>
-coverage-no-function-names-in-data -Xclang -coverage-version='407*'"<br>
(see <a href="http://llvm.org/bugs/show_bug.cgi?id=16568" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=16568</a>).<br></blockquote><div><br></div><div>gcov doesn't have a single fixed format. If you're using the gcov from gcc-4.7 then yes you use those flags mentioned. The default that clang emits should be gcc-4.2 compatible, which is supposed to work with llvm-cov or with a gcov binary from gcc 4.2<br>

</div></div><br></div><div class="gmail_extra">Nick<br><br></div></div>