英文:
clang -fsanitize=address can't find libclang_rt.asan
问题
这是代码部分,不需要翻译。
英文:
It was my first time building clang
from source, so maybe I messed it up, but if I try to compile a "hello world" with -fsanitize=address
, I get an error:
$ clang -fsanitize=address hello.c
/usr/bin/ld: cannot find /usr/local/lib/clang/15.0.7/lib/linux/libclang_rt.asan_static-x86_64.a: No such file or directory
/usr/bin/ld: cannot find /usr/local/lib/clang/15.0.7/lib/linux/libclang_rt.asan-x86_64.a: No such file or directory
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
In fact, /usr/local/lib/clang/15.0.7/lib
doesn't exist at all (only include/
there). Did I build clang
incorrectly? These are the commands I used, on Debian Stable:
wget "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/llvm-project-15.0.7.src.tar.xz"
tar xvf llvm-project-15.0.7.src.tar.xz
cd llvm-project-15.0.7.src
cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DCMAKE_BUILD_TYPE=Release
ninja -C build check-llvm
sudo ninja -C build install
答案1
得分: 0
注释很有帮助。我将留下答案,以防其他人遇到此问题并通过谷歌找到这篇帖子。
解决方法是在 `cmake` 命令中添加 `-DLLVM_ENABLE_RUNTIMES=all`。例如,完整的构建说明可以是
tar xvf llvm-project-15.0.7.src.tar.xz
cd llvm-project-15.0.7.src
cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES=all
ninja -C build check-llvm
sudo ninja -C build install
英文:
The comments helped. I'm going to leave an answer in case someone else has this problem and finds this post by googling.
The solution is to add -DLLVM_ENABLE_RUNTIMES=all
to the cmake
command. For example, the complete build instructions can be
tar xvf llvm-project-15.0.7.src.tar.xz
cd llvm-project-15.0.7.src
cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES=all
ninja -C build check-llvm
sudo ninja -C build install
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论