我从源代码构建了 clang-4.0。当我尝试使用“未定义行为”清理程序时,我得到了以下输出。
$ clang -fsanitize=undefined parallel_big_loop.c
/usr/bin/ld: cannot find /home/user/Software/polly/llvm_build/bin/../lib/clang/4.0.0/lib/linux/libclang_rt.ubsan_standalone-x86_64.a: No such file or directory
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
使用 Ubuntu 14.04.5 amd64,linux 4.4.0-31-generic。
如何指示 CMake 在构建过程中包含它?
最佳答案
根据官方 Clang 指南:http://clang.llvm.org/get_started.html
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ../..
cd llvm/projects
# This repository is responsible for sanitizers
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
cd ../..
# in-tree build is not supported
mkdir build
cd build
cmake -G"Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/clang/ ../llvm/
ninja
您当然可以使用 make
代替 ninja
,如果您不喜欢 svn
,您可以使用此 Github 存储库 https://github.com/llvm-mirror
关于c - 在 clang 上启用 Sanitizers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39336193/