繁体   English   中英

在 Xcode 中以 Release 模式编译 .cpp 期间 clang 崩溃,但在调试中正常

[英]clang crashed during compilation of .cpp in Xcode in Release mode but ok in debug

我有一个项目,其中有一个 .h、.cpp 和一个桥接头,所以基本上是尝试从 swift 调用一些 c++ 代码。 当我在调试模式下构建和运行时,一切看起来都很好。

如果我切换到发布模式,它将无法构建,并且在从 clang 编译期间发生崩溃。 这是消息:

clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: aarch64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://developer.apple.com/bugreporter/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/r5/bs8mgc751_bbl3gcths89jc00000gp/T/CBaseMath-8e4bd0.cpp
clang: note: diagnostic msg: /var/folders/r5/bs8mgc751_bbl3gcths89jc00000gp/T/CBaseMath-8e4bd0.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/kelvinchan/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg: 

在尝试按照指示为 Apple 提交错误报告之前,是否知道我应该查看哪些内容? 我试图查看 .crash 文件,但我的技术水平不足以理解它。 它没有引用我拥有的任何 C++ 代码。

你的编译器崩溃了,这很烦人。 记录错误的最佳方法是尽可能减少这种情况。

最好的方法是使用名为Creduce的程序。 这是一个需要文件和脚本的程序。 该文件是您的起始情况。 该脚本需要证明您的错误仍然存​​在。

在这种情况下,您的脚本可能存在关于 2 个编译命令和检查返回码。 该文件只是您的 .CPP

有了所有这些,程序将丢弃代码......并尽可能减少文件。 我已经看到 100 000 行减少到 5 行。

一个技巧:预处理的文件虽然自包含但更大,这使得它更容易减少。

最后,你需要很多时间。 你启动它并运行直到它减少

如果它在不到五分钟的时间内运行,则您的脚本有问题,并且您通常会得到一个空的 .CPP 预期时间在数小时范围内。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM