[cfe-dev] Error: Invalid file format (bad magic) with -fprofile-instr-use

Justin Bogner mail at justinbogner.com
Fri Jul 11 09:26:37 PDT 2014


The .profraw file needs to be transformed into a .profdata file before use.
See step 3 here:


http://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation

On Thursday, July 10, 2014, p2282 <ganesh.faq at gmail.com> wrote:

> Hi all,
>
> Flag "-fprofile-instr-use" generates error given below.
> This issue occurs even if we build llvm,clang and compiler-rt using cmake
> or
> configure.
> Please let me know your inputs to resolve this issue
>
> Error:error: Could not read profile: Invalid file format (bad magic)
>
> Thanks,
>
> *Steps to reproduce this issue:*
> $ clang -O2 -fprofile-instr-generate hello.c -o c1.out
>
> $ ls -rlt
> -rw-r--r-- 1 root root       70 Jul 11 10:10 hello.c
> -rwxr-xr-x 1 root root    15793 Jul 11 10:10 c1.out
> -rw-r--r-- 1 root root 12203204 Jul 11 10:10 *gmon.out*
>
> $ ./c1.out
> Hello world
>
> $ ls -rlt
> -rw-r--r-- 1 root root       70 Jul 11 10:10 hello.c
> -rwxr-xr-x 1 root root    15793 Jul 11 10:10 c1.out
> -rw-r--r-- 1 root root 12203204 Jul 11 10:10 *gmon.out*
> -rw-r--r-- 1 root root      104 Jul 11 10:10 *default.profraw*
>
> $ clang -O2 -fprofile-instr-use=default.profraw hello.c -o c2.out
> error: Could not read profile: Invalid file format (bad magic)
> 1 error generated.
>
> *Clang version (July 10th-2014 build from stage): *
> $ clang -v
> clang -v
> clang version 3.5.0 (llvm.org/git/clang.git
> 5f9d646cba20f309bb69c6c358996d71912c54cd) (llvm.org/git/llvm.git
> dc90a3ab8ffc841a442888940635306de6131d2f)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.0
> Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
> Candidate multilib: .;@m64
> Candidate multilib: 32;@m32
> Selected multilib: .;@m64
>
> *OS:*  Ubuntu 14.04
>
> *LLVM configure:* ../llvm/configure --enable-profiling --enable-optimized
> --enable-shared --disable-debug-runtime --enable-targets=x86
>
>
>
> --
> View this message in context:
> http://clang-developers.42468.n3.nabble.com/Error-Invalid-file-format-bad-magic-with-fprofile-instr-use-tp4040477.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu <javascript:;>
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140711/fca39fa3/attachment.html>


More information about the cfe-dev mailing list