我正在尝试使用MemorySanitizer工具构建libc ++,以便可以使用MemorySanitizer构建自己的项目。我正在Ubuntu 16.04上使用Clang 8.01。
我遵循了here的说明,但是构建最初因链接器错误而失败。我通过使用lld而不是默认链接器纠正了链接器错误。但是,由于MemorySanitizer警告,构建失败了:
[ 0%] Built target LLVMDemangle
[ 4%] Built target LLVMSupport
[ 4%] Built target LLVMTableGen
[ 5%] Built target obj.llvm-tblgen
[ 5%] Built target llvm-tblgen
[ 5%] Building AttributesCompatFunc.inc...
==6384==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x51ee14 in _M_lower_bound /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_tree.h:1940:7
#1 0x51ee14 in find /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_tree.h:2566
#2 0x51ee14 in find /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_map.h:1194
#3 0x51ee14 in llvm::RecordKeeper::getClass(llvm::StringRef) const /opt/llvm/llvm-801/include/llvm/TableGen/Record.h:1612
#4 0xa2ff5c in llvm::TGParser::ParseClass() /opt/llvm/llvm-801/lib/TableGen/TGParser.cpp:2648:28
#5 0xa2fceb in llvm::TGParser::ParseObject(llvm::MultiClass*) /opt/llvm/llvm-801/lib/TableGen/TGParser.cpp:3010:12
#6 0xa37c9a in ParseObjectList /opt/llvm/llvm-801/lib/TableGen/TGParser.cpp:3022:9
#7 0xa37c9a in llvm::TGParser::ParseFile() /opt/llvm/llvm-801/lib/TableGen/TGParser.cpp:3030
#8 0x99fa00 in llvm::TableGenMain(char*, bool (*)(llvm::raw_ostream&, llvm::RecordKeeper&)) /opt/llvm/llvm-801/lib/TableGen/Main.cpp:100:14
#9 0x8aa738 in main /opt/llvm/llvm-801/utils/TableGen/TableGen.cpp:253:10
#10 0x7f11477df82f in __libc_start_main /build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:291
#11 0x297028 in _start (/opt/llvm/llvm-801-msan/bin/llvm-tblgen+0x297028)
SUMMARY: MemorySanitizer: use-of-uninitialized-value /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_tree.h:1940:7 in _M_lower_bound
Exiting
lib/IR/CMakeFiles/AttributeCompatFuncTableGen.dir/build.make:93: recipe for target 'lib/IR/AttributesCompatFunc.inc' failed
make[2]: *** [lib/IR/AttributesCompatFunc.inc] Error 77
CMakeFiles/Makefile2:1628: recipe for target 'lib/IR/CMakeFiles/AttributeCompatFuncTableGen.dir/all' failed
make[1]: *** [lib/IR/CMakeFiles/AttributeCompatFuncTableGen.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2
由于说明建议构建中继,因此我尝试构建最新的发行版标签(8.01),但这会产生完全相同的警告。问题似乎出在GCC的标头中,所以也许我需要针对不同的标准库标头进行编译?
我也尝试按照基本步骤here进行操作,但是会发生相同的错误。