简体   繁体   English

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

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

I have a project where I have a .h, .cpp, and a bridging header, so basically trying to call some c++ code from swift.我有一个项目,其中有一个 .h、.cpp 和一个桥接头,所以基本上是尝试从 swift 调用一些 c++ 代码。 When i built and ran in Debug mode, things looked fine.当我在调试模式下构建和运行时,一切看起来都很好。

If I switch to release mode, it failed to build, and the crash happened during compilation from clang.如果我切换到发布模式,它将无法构建,并且在从 clang 编译期间发生崩溃。 Here's the message:这是消息:

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: 

Any idea if there's something I should look, before trying to file a bug report for Apple as instructed?在尝试按照指示为 Apple 提交错误报告之前,是否知道我应该查看哪些内容? I tried to looked at the .crash file but i am not technical enough to understand it.我试图查看 .crash 文件,但我的技术水平不足以理解它。 It does not reference any of the c++ code I have.它没有引用我拥有的任何 C++ 代码。

You have a crash in your compiler, which is annoying.你的编译器崩溃了,这很烦人。 The best way to log a bug is to reduce this as much as possible.记录错误的最佳方法是尽可能减少这种情况。

The best way of doing so is with a program called Creduce .最好的方法是使用名为Creduce的程序。 It's a program that requires a file and a script.这是一个需要文件和脚本的程序。 The file is your starting situation.该文件是您的起始情况。 The script needs to prove your bug still exists.该脚本需要证明您的错误仍然存​​在。

In this case, your script could exist about the 2 compile commands and checking the return code.在这种情况下,您的脚本可能存在关于 2 个编译命令和检查返回码。 The file is simply your .CPP该文件只是您的 .CPP

With all of this, the program will throw away code ... and reduce the file as much as possible.有了所有这些,程序将丢弃代码......并尽可能减少文件。 I've seen 100 000 lines being reduced to 5.我已经看到 100 000 行减少到 5 行。

A tricks: preprocessed files are larger though self-contained, this makes it easier to reduce.一个技巧:预处理的文件虽然自包含但更大,这使得它更容易减少。

Finally, you need a lot of time.最后,你需要很多时间。 You start it and it runs until it is reduced你启动它并运行直到它减少

If it runs in less than five minutes your script is faulty and you usually end up with an empty .CPP Expected time are in the range of hours.如果它在不到五分钟的时间内运行,则您的脚本有问题,并且您通常会得到一个空的 .CPP 预期时间在数小时范围内。

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

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