LLVM,-fprofile instr generate,未定义对'__llvm\u配置文件\u寄存器\u函数

LLVM,-fprofile instr generate,未定义对'__llvm\u配置文件\u寄存器\u函数,llvm,compiler-optimization,instrumentation,Llvm,Compiler Optimization,Instrumentation,我在“-fprofile instr generate”中遇到以下错误。 感谢您为解决此错误提供的帮助 谢谢 错误: 叮当版本:叮当版本3.5.0 操作系统:Ubuntu 14.04 LD版本:GNU黄金(GNU比努蒂尔斯2.24.51.20140522)1.11 LLVM配置选项:配置--启用评测--启用优化--启用共享--禁用调试运行时--启用目标=all--前缀=/install--with binutils include=/gold\u linker/binutils/include

我在“-fprofile instr generate”中遇到以下错误。 感谢您为解决此错误提供的帮助

谢谢

错误:

叮当版本:叮当版本3.5.0

操作系统:Ubuntu 14.04

LD版本:GNU黄金(GNU比努蒂尔斯2.24.51.20140522)1.11

LLVM配置选项:配置--启用评测--启用优化--启用共享--禁用调试运行时--启用目标=all--前缀=/install--with binutils include=/gold\u linker/binutils/include

上面的错误是“使用-v”。-v的输出如下所示


如果使用cmake构建llvm和编译器-rt,则不会出现此问题。 但是,如果在构建llvm和编译器rt时使用configure,则会出现此问题

#Step-1) Build your LLVM compiler as follows
cd /home/user
git clone http://llvm.org/git/llvm.git
cd llvm/tools
git clone http://llvm.org/git/clang.git
cd ../../
mkdir build_folder
cd build_folder
cmake /home/user/llvm
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_INSTALL_PREFIX=/home/user/llvm_install /home/user/llvm
make 
make install

#Step-2) Build compiler-rt as follows. Use llvm-config from your llvm installation from above step-1
git clone http://llvm.org/git/compiler-rt.git
mkdir comp_rt_build_dir
cd comp_rt_build_dir
cmake ../compiler-rt -DLLVM_CONFIG_PATH=/path/to/llvm-config
make 
make install

我相信这是因为你也需要在链接器阶段通过这个标志。引述:

如果链接到clang驱动程序,请将-fprofile instr generate传递到链接阶段,以确保链接到必要的运行库


请尝试
-Wl,-fprofile instr generate

我遇到了同样的问题。我想知道这是否与这些函数在中被重命名有关。
 "/usr/local/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -L/home/LLVM_install/bin/../lib -L/lib -L/usr/lib /tmp/hello-c8552f.o /home/LLVM_install/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.profile-x86_64.a -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
/tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_runtime_user: error: undefined reference to '__llvm_profile_runtime'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
#Step-1) Build your LLVM compiler as follows
cd /home/user
git clone http://llvm.org/git/llvm.git
cd llvm/tools
git clone http://llvm.org/git/clang.git
cd ../../
mkdir build_folder
cd build_folder
cmake /home/user/llvm
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_INSTALL_PREFIX=/home/user/llvm_install /home/user/llvm
make 
make install

#Step-2) Build compiler-rt as follows. Use llvm-config from your llvm installation from above step-1
git clone http://llvm.org/git/compiler-rt.git
mkdir comp_rt_build_dir
cd comp_rt_build_dir
cmake ../compiler-rt -DLLVM_CONFIG_PATH=/path/to/llvm-config
make 
make install