Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Swift: macro plugin host fails with "Bad CPU type in executable" when tracing an Xcode 27 build on Apple Silicon

未关闭
#22,742 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
macos, swift

调研方向

Start with tools/osx64/preload_tracer and reproduce the failure using the provided codeql database create command on the SwiftData project. Compare how traced swift-frontend launches swift-plugin-server, using the reported arm64-only binaries and relocator output as evidence. Done means the traced Xcode build succeeds and creates the CodeQL database without the Bad CPU type error.

由索引模型根据 Issue 内容生成。

描述

bug

Description

Creating a Swift database for an iOS app that uses SwiftData macros (@Model, #Predicate) fails on an Apple Silicon Mac with Xcode 27. swift-frontend runs under the tracer, but it cannot launch the macro plugin host, so every macro expansion fails and the build stops.

Environment

  • CodeQL CLI 2.27.1 (Homebrew cask codeql); the tracer runs from tools/osx64/preload_tracer
  • macOS 27.0.1 on Apple M1 Pro
  • Rosetta 2 installed
  • Xcode 27.0 (27A266a), iOS 27 SDK
  • lipo -archs reports arm64 only for both of these:
    • /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-server
    • /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend

Steps to reproduce

  1. Use an iOS project containing any SwiftData @Model class.
  2. Put the build in a script, build.sh:
    #!/bin/bash
    set -euo pipefail
    xcodebuild -project App.xcodeproj -scheme App -destination 'generic/platform=iOS Simulator' -derivedDataPath /tmp/dd-codeql CODE_SIGNING_ALLOWED=NO clean build
    
  3. Run:
    codeql database create /tmp/db --language=swift --overwrite --command=./build.sh
    

Expected behaviour

The database is created. Running ./build.sh without CodeQL ends in ** BUILD SUCCEEDED **.

Actual behaviour

The build fails with exit code 65. Every file using a SwiftData macro reports:

error: external macro implementation type 'SwiftDataMacros.PersistentModelMacro' could not be found for macro 'Model()'; compiler plugin '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-server' could not be loaded: Bad CPU type in executable

Related observations

  1. Without the macro plugin, the tracer copes with the arm64-only toolchain. A probe with --command="xcodebuild -version" runs xcodebuild and prints Xcode 27.0 / Build version 27A266a, and the plain build of the same project (without CodeQL) succeeds. So the failure seems specific to how the traced swift-frontend launches swift-plugin-server.
  2. During the traced build, the relocator makes patched .slice.arm64 copies of xcodebuild, SWBBuildService, actool, ibtoold and ld. Each one logs an install_name_tool header-padding error and then falls back to a short symlink, after which tracing continues normally. I include this in case it's related:
    error: .../install_name_tool: changing install names or rpaths can't be redone for: .../xcodebuild.semmle.<id>.slice.arm64 (for architecture arm64) because larger updated load commands do not fit (the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)
    relocator: resorting to replacing "/Applications/Xcode.app/Contents/Developer/usr/bin" with short symlink "/tmp/<random>"
    
主要语言
CodeQL
星标
10.2k
派生
2.1k
平均合并
2 天 14 小时
30 天内合并 PR
142

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/codeql 的其他 Issue

查看 github/codeql 的全部 Issue

相似的 Issue

更多 Build System Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。