xcode - ld : file not found:/Library/Developer/. ../libclang_rt.ubsan_osx_dynamic.dylib

标签 xcode macos clang ubsan

我正在尝试通过这样的构建来使用 Undefined Behavior Sanitizer

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

根据 this news release ,它在 GCC 和 original homepage 中可用因为它说它已合并到 LLVM 中。文章链接说 GCC 4.9 有它,我想我有(至少——版本编号似乎不同,但这篇文章是几年前写的,我已经更新了几次系统)。

问题:如何构建可执行文件以使用 UBSan?

最佳答案

据博客 Friday Q&A 2015-07-03: Address Sanitizer by Mike Ash :

Any idea why Apple clang doesn't support -fsanitize=undefined?

When I try that I get:

clang -fsanitize=undefined ub.c
...
ld: file not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/
bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib


斯宾塞 在 2016-12-21 01:23:59 :

如果您使用 -fsanitize=address,undefined有用。希望这
帮助发现这篇文章的其他人像我一样搜索那个错误。

这对我们来说不是一个理想的解决方案,因为它们是独立的组件,我们对环境和工具的控制有限。我们不得不暂停一些 Address Sanitizer 测试,因为 Asan 使用 GCC 内联汇编和使用 ebp/rbp 作为通用寄存器会产生不正确的结果。而这里的环境和工具由Travis CI提供.

错误报告已提交给 LLVM,地址为 Issue 33201, Apple Clang bundled with Xcode 8 does not reject -fsanitize=undefined when it should .由于它是 Apple Clang 错误(我们没有 iTunes 帐户可以向 Apple 提交错误),因此它可能会被关闭为题外话。

关于xcode - ld : file not found:/Library/Developer/. ../libclang_rt.ubsan_osx_dynamic.dylib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42893831/

相关文章:

c++ - GCC 和 Clang 不在 C++17 中编译 std::hash<std::nullptr_t>

iphone - AVCapture追加SampleBuffer

macos - 苹果操作系统 : how to cd to the folder with a name which the first character is "-"?

ios - XCode IOS Apple LLVM 3.1 - Eigen NEON 中断

java - 为什么 File.createTempFile 在 Mac OS X 上返回符号链接(symbolic link)?

macos - 在 OS X 中模拟击键进行压力测试?

c++ - gcc vs. clang: "invalid use of incomplete type"with std::declval 和模板特化

ios - 自 Xcode 9.3 以来的可空性完整性警告

ios - 在 iOS 应用程序中创建共享按钮(twitter facebook ...)

ios - 我如何在真正的预提交处理程序中修复 “[App] if we' re,由于 CA 限制,我们实际上无法添加任何新的围栏”?