c++ - '-print_statistics' 链接器选项在 Xcode 中产生错误

标签 c++ xcode clang llvm ld

我想分析我们大型 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/

相关文章:

c++ - Realm 中是否会支持 C++/Qt?

c++ - 如何使用 Windows Native API 访问 PE 资源?

ios - Xcode - 代码签名身份自动?

ios - 从 Xcode App Loader 上传 Ionic ios 应用程序时出现错误

objective-c - CLang 编译失败

C++默认复制构造函数

ios - 如何测试 iOS 升级场景?

c++ - 强制 clang 在此 C++ 代码片段上生成编译错误

xcode - "ld: mach-o string pool extends beyond end of file"是什么意思?

c++ - Visual Studio 无法识别虚幻引擎