我想分析我们大型 C++ 项目的链接阶段,因为使用 Xcode 或 xcodebuild
链接 iOS 项目最多需要 30 分钟。
$ man ld
表示可以使用“-print_statistics”命令行选项。但是通过build设置中的“其他链接器标志”设置此选项会在 Ld
期间产生错误:
clang:错误:未知参数:'-print_statistics'
看起来 Xcode 构建系统有些如何检查“其他链接器标志”并且不识别“-print_statistics”。
最佳答案
正如@shaiba 猜测的那样,Xcode 使用 Clang/LLVM。在幕后 LLVM 使用 LLD指向
的链接器"LLD is a drop-in replacement for the GNU linkers. That accepts the same command line arguments and linker scripts as GNU"
作为主要特征之一。
您尝试直接传递链接器参数是错误的。它应该通过 clang
-Wl,<arg>,<arg2>...
Pass the comma separated arguments in <arg> to the linker
-X
-Xlinker <arg>, --for-linker <arg>, --for-linker=<arg>
Pass <arg> to the linker
尝试设置-Wl,-print_statistics
关于c++ - '-print_statistics' 链接器选项在 Xcode 中产生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51786178/