optimization - LLVm clang,错误:带有-fprofile-instr-use的无效文件格式(坏魔术)

标签 optimization instrumentation llvm-clang

标志“ -fprofile-instr-use”会产生以下错误。
即使我们使用cmake或configure生成llvm,clang和compile-rt,也会发生此问题。
请让我知道您的输入来解决此问题

错误:无法读取配置文件:无效的文件格式(坏魔术)

谢谢,

重现此问题的步骤:

$ 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

即使您只使用1个输出文件,也是必需的。 “将多个运行中的配置文件合并并将“原始”配置文件格式转换为clang期望的输入”听起来像只有在有多个配置文件的情况下才应该这样做,但您需要无条件地这样做。

关于optimization - LLVm clang,错误:带有-fprofile-instr-use的无效文件格式(坏魔术),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24692487/

相关文章:

php - 优化此查询,从具有 500.000 个用户和一个条件的 MySQL 数据库中检索用户

java - 是否可以转储 java ASM 检测的字节码?

c++ - 为什么我不能用 clang 编译这个程序?

c++ - 集成 LLVM passes

c - 如何高效定义一个128位常量?

javascript - html DOM 节点限制

mysql - 使用许多子选择优化 MySQL 查询

java - 实现选择性类加载器

java - 拦截构造函数导致 ClassNotFoundException

c++ - Clang VS VC++ :"error: declaration of ' T'阴影模板参数”