我想用ASAN构建LLVM。文档说明使用LLVM_USE_SANITIZERS
。那没用我试过不同的组合旗,浪费了很多时间搜索,但一无所获。我尝试的最后一个是:
cmake -G Ninja ../llvm \
-DCMAKE_INSTALL_PREFIX=/home/mikadore/local/llvm15-debug \
-DCMAKE_BUILD_TYPE=Debug \
-DLLVM_ENABLE_PROJECTS='lld;clang;clang-tools-extra;compiler-rt' \
-DLLVM_USE_RUNTIMES='compiler-rt' \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_USE_SANITIZER='Address;Undefined' \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang
我还将compiler-rt
从llvm-project
复制到llvm
子文件夹中。但它们都失败了,都犯了同样的错误:
CMake Error at projects/compiler-rt/lib/gwp_asan/tests/CMakeLists.txt:61 (add_library):
Error evaluating generator expression:
$<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
Objects of target "RTSanitizerCommon.x86_64" referenced but no such target
exists.
CMake Error at projects/compiler-rt/lib/gwp_asan/tests/CMakeLists.txt:61 (add_library):
Error evaluating generator expression:
$<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
Objects of target "RTSanitizerCommon.x86_64" referenced but no such target
exists.
CMake Error at projects/compiler-rt/lib/gwp_asan/tests/CMakeLists.txt:61 (add_library):
Error evaluating generator expression:
$<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
Objects of target "RTSanitizerCommon.x86_64" referenced but no such target
exists.
CMake Error at projects/compiler-rt/lib/gwp_asan/tests/CMakeLists.txt:61 (add_library):
No SOURCES given to target: RTGwpAsanTest.x86_64
在启用ASAN的情况下构建LLVM的正确方法是什么?
1条答案
按热度按时间kdfy810k1#
消毒器,包括ASAN,实际上是compiler-rt项目的一部分,该项目包含消毒器库,包括在启用消毒器时在编译时插入到代码中的消毒器函数(在使用ASAN的情况下为
__asan_
函数)。我能够使用CMake构建启用ASAN的LLVM 16: