我试图通过这样的构建来使用未定义的行为消毒器
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?
发布于 2017-05-28 21:59:12
你知道为什么苹果公司不支持
-fsanitize=undefined吗? 当我尝试的时候,我得到: clang -fsanitize=undefined ub.c .ld:文件未找到: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/ bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib Spencer at 2016-12-21 01:23:59: 如果您使用-fsanitize=address,undefined,它可以工作。希望这能帮助其他人找到这篇文章中的错误,就像我做的那样。
这对我们来说不是一个理想的解决方案,因为它们是独立的组件,而且我们对环境和工具的控制有限。我们不得不暂停一些地址杀菌剂测试,因为Asan产生了不正确的结果,GCC内联组装和使用ebp/rbp作为通用寄存器。这里,环境和工具是由特拉维斯CI提供的。
在第33201期,与Xcode 8捆绑在一起的Apple不拒绝-fsanitize=undefined向LLVM提交了一个错误报告。它可能会被关闭,因为它是一个(我们没有一个iTunes帐户来向苹果提交这个bug )。
发布于 2017-04-24 14:19:48
为了使用未定义的行为清除器,我必须安装并构建带有clang以及libcxx和libcxxabi的LLVM,尽管我的MacOS已经附带了一个版本的clang。(结果,我现在在电脑上安装了两个版本的clang )。来自llvm入门页面
cd where-you-want-llvm-to-live
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd where-you-want-llvm-to-live
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd where-you-want-llvm-to-live
svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi现在,我可以通过运行
/usr/local/bin/clang -fsanitize=undefined -O add.c -o addhttps://stackoverflow.com/questions/42893831
复制相似问题