Swift: macro plugin host fails with "Bad CPU type in executable" when tracing an Xcode 27 build on Apple Silicon
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- macos, swift
- 領域
- build-system, devtools
研究方向
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 內容生成。
描述
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 fromtools/osx64/preload_tracer - macOS 27.0.1 on Apple M1 Pro
- Rosetta 2 installed
- Xcode 27.0 (27A266a), iOS 27 SDK
lipo -archsreportsarm64only 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
- Use an iOS project containing any SwiftData
@Modelclass. - 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 - 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
- Without the macro plugin, the tracer copes with the arm64-only toolchain. A probe with
--command="xcodebuild -version"runsxcodebuildand printsXcode 27.0 / Build version 27A266a, and the plain build of the same project (without CodeQL) succeeds. So the failure seems specific to how the tracedswift-frontendlaunchesswift-plugin-server. - During the traced build, the relocator makes patched
.slice.arm64copies ofxcodebuild,SWBBuildService,actool,ibtooldandld. Each one logs aninstall_name_toolheader-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 天 13 小時
- 30 天內合併 PR
- 144
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
github/codeql 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 66/100
維護者通常 1 天內回覆
-
Python: trailing comma in a PEP 695 type parameter list causes a parse error可能已有人在做 @jketema 於 6 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 88/100
github/codeql#22739 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
false-positive javascript
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
Add AlertSuppression.ql for Rust (inline // codeql[...] suppression)可能已有人在做 @cnuss 於 189 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
false-positive
難度 2/5 1-3 小時 新手友好度 70/100
github/codeql#21076 · 3 則留言 · 3 個 reaction ·
維護者通常 1 天內回覆
相似的 Issue
-
status:needs-triage
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
? - Needs Triage bot_watch bug
難度 2/5 1-3 小時 新手友好度 68/100
NVIDIA/cudf-spark-jni#5267 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
aks129/HealthClawGuardrails#917 ·
維護者通常 1 天內回覆
-
area/build area/tech debt
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 2 天內回覆
-
category:port-update
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 2 天內回覆