LLVm clang,错误:无效的文件格式(坏魔术)使用-fprofile- instrument -use



标志"-fprofile- instrument -use"产生如下错误。即使我们使用cmake或configure构建llvm、clang和compiler-rt,也会出现这个问题。请让我知道你的意见来解决这个问题

错误:Could not read profile: Invalid file format (bad magic)

谢谢,

重现此问题的步骤:

$ 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 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 

结果是这里列出的步骤3:http://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation

即使只有一个正在使用的输出文件,也需要

。"合并多次运行的配置文件,并将"原始"配置文件格式转换为clang所期望的输入",这听起来像是只有在您有多个配置文件时才应该这样做,但您需要无条件地这样做。

相关内容

最新更新