You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xcode 14使用-mcmodel=large编译时ld断言失败问题求助

Xcode14下-mcmodel=large链接断言错误解决方案

问题背景

升级至Xcode14后,使用-mcmodel=large编译选项出现链接断言错误,Xcode13下可正常工作,移除该选项可解决问题但业务代码依赖此选项。错误日志如下:

0  0x104a141a0  __assert_rtn + 140
1  0x104a1d2ec  ld::tool::SymbolTableAtom<arm64>::classicOrdinalForProxy(ld::Atom const*) (.cold.2) + 0
2  0x104925598  ld::tool::LocalRelocationsAtom<arm64_32>::~LocalRelocationsAtom() + 0
3  0x104924ab8  ld::tool::SymbolTableAtom<arm64>::addImport(ld::Atom const*, ld::tool::StringPoolAtom*) + 204
4  0x104924150  ld::tool::SymbolTableAtom<arm64>::encode() + 420
5  0x104910c18  ___ZN2ld4tool10OutputFile20buildLINKEDITContentERNS_8InternalE_block_invoke_3 + 36
6  0x1ac8465f0  _dispatch_call_block_and_release + 32
7  0x1ac8481b4  _dispatch_client_callout + 20
8  0x1ac859b14  _dispatch_root_queue_drain + 952
9  0x1ac85a104  _dispatch_worker_thread2 + 164
10  0x1aca08324  _pthread_wqthread + 228
A linker snapshot was created at:
    /tmp/project_name-2022-09-18-183942.ld-snapshot
ld: Assertion failed: (dylib != NULL), function classicOrdinalForProxy, file LinkEditClassic.hpp, line 495.

解决方案

1. 回退使用Xcode13的链接器

这是最直接的临时解决方案,利用Xcode13的ld链接器规避Xcode14的bug:

  • 找到Xcode13安装路径下的ld工具,默认路径为:/Applications/Xcode_13.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
  • 在Xcode14项目的Build Settings中,找到Other Linker Flags,添加参数:-fuse-ld=/Applications/Xcode_13.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld

2. 针对目标架构单独配置编译选项

如果项目不需要为所有架构启用-mcmodel=large,可仅对需要的架构(如arm64)单独配置:

  • 打开项目Build Settings,找到Other C Flags和Other C++ Flags
  • 双击选项进入编辑模式,点击+号添加新条目
  • 在条件栏输入$(ARCHS_STANDARD_64_BIT),对应的值栏输入-mcmodel=large,确保仅64位架构启用该选项

3. 向Apple提交bug反馈

该问题属于Xcode14链接器的已知bug,提交反馈有助于Apple修复:

  • 打开Feedback Assistant工具
  • 附上完整的错误日志和链接快照文件(路径已在错误信息中给出),描述清楚问题场景(Xcode14 + -mcmodel=large触发断言)

内容的提问来源于stack exchange,提问作者gkpln3

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 20:40:31