简体   繁体   中英

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. 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. 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? I tried to looked at the .crash file but i am not technical enough to understand it. It does not reference any of the c++ code I have.

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 . 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. The file is simply your .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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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