Skip to content

Fix iOS 15 launch dyld crash caused by shaderc libc++ symbol reference.#1441

Open
0x1306a94 wants to merge 1 commit into
Tencent:mainfrom
0x1306a94:bugfix/0x1306a94_ios_dyld
Open

Fix iOS 15 launch dyld crash caused by shaderc libc++ symbol reference.#1441
0x1306a94 wants to merge 1 commit into
Tencent:mainfrom
0x1306a94:bugfix/0x1306a94_ios_dyld

Conversation

@0x1306a94
Copy link
Copy Markdown
Contributor

@0x1306a94 0x1306a94 commented May 21, 2026

问题现象

  • 偶然在iOS 15上运行时我的业务代码时发现启动时,dyld 直接崩溃,报错如下:
Symbol not found: __ZNSt3__122__libcpp_verbose_abortEPKcz
Referenced from: SeatCanvas.framework/SeatCanvas
Expected in: /usr/lib/libc++.1.dylib
  • demangle 后为 std::__1::__libcpp_verbose_abort(char const*, ...)排查确认该符号来自 tgfx.a 中 shaderc / SPIRV 相关静态库对象,并非业务代码引入。
  • 同时发现最新的提交 Metal Hello2D demo 运行报错如下
image

根因分析

  • vendor.json 中 iOS 平台 shaderc 的 CMAKE_CXX_FLAGS 包含 -D_LIBCPP_DISABLE_AVAILABILITY 定位到是在 Add Metal and OpenGL Hello2D demos, fix GPU resource sync and rendering issues. #1354 这次添加的 -D_LIBCPP_DISABLE_AVAILABILITY

  • 在 Xcode 26.4 / iPhoneOS 26.4 SDK 下,Debug 构建会启用 libc++ hardening_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG 正常情况下,libc++ 的 availability 机制会识别 __libcpp_verbose_abort 在 iOS 15 上不可用,并在编译期退化为 __builtin_abort() 不会产生外部符号引用。

  • _LIBCPP_DISABLE_AVAILABILITY 关闭了这一保护,导致 shaderc 及其依赖(glslang、SPIRV-Tools 等)编译出的 .o 文件中包含对 __libcpp_verbose_abort 的外部引用。这些对象被链入 tgfx.a 后,宿主 App 在 iOS 15 设备上加载时,系统 libc++ 中找不到该符号,dyld 在启动阶段即失败。

修复方案

  • 从 vendor.json iOS shaderc 平台配置中移除 -D_LIBCPP_DISABLE_AVAILABILITY让 libc++ availability 机制正常工作

Test plan

  • ./autotest.sh 验证测试通过
  • ./autotest.sh USE_METAL CanvasTest.PictureMaskPath 测试失败
  • iOS/macOS 上验证 Metal Hello2D demo 渲染正常(需临时修改下 ShaderCompiler.cpp:88 binding=0)
  • iOS 15 环境验证通过,App 启动不再出现 dyld 崩溃

@0x1306a94 0x1306a94 force-pushed the bugfix/0x1306a94_ios_dyld branch from fe9ec31 to 8dcb94f Compare May 22, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant