簡體   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