我已经从 Home-brew 下载了 LLVM,但在检查 C 中的内存问题时仍然无法使用 -fsanitize=memory。我收到以下错误:
clang: error: unsupported option '-fsanitize=memory' for target 'arm64-apple-darwin21.2.0'
。我需要做什么才能在 M1 Mac Pro 上使用 Memory Sanitizer 和 Leak Sanitizer? (macOS 蒙特利)
MemorySanitizer 在以下操作系统上受支持: Linux 网络BSD 免费BSD
Apple clang 版本 13.1.6 (clang-1316.0.21.2.5) 编译器不支持 Leak Sanitizer。 或者,您可以在构建程序时使用
-fsanitize=address
来识别泄漏,它可能比 -fsanitize=leak 慢,但可以完成工作。
也可以尝试ASAN_OPTIONS=detect_leaks=1
(尚未测试)
欲了解Apple平台上ASAN的更多信息,请阅读: https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early