我正在尝试通过这样的构建来使用未定义的行为清理器
gcc -fsanitize=undefined add.c -o add
还
clang -fsanitize=undefined -O add.c -o add
在这两种情况下,我都会收到未找到文件的错误:
ld: file not found: /Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib
这是我运行时得到的gcc -v
输出clang -v
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
根据这个新闻发布,它在 GCC 中可用,而且它的原始主页说它已被合并到 LLVM 中。链接到文章说 GCC 4.9 有它,我假设我有(至少 - 版本编号似乎不同,但这篇文章是几年前写的,我已经更新了我的系统几次)。
问题:如何构建可执行文件以使用 UBSan?