考虑升级 Rust 工具链版本(rust-lang/rust#157750 导致 macOS 27 冷构建失败) #431

Closed
opened 2026-09-20 01:18:53 +08:00 by suzmii · 0 comments
Member

问题原因

本仓库 rust-toolchain.toml 固定在 Rust 1.96.0。在 macOS 27(已装 CLT for Xcode 27.0)上做冷构建时,第一批 proc-macro crate 的 dylib 会被链接成畸形 Mach-O,dyld 拒绝加载,rustc 报:

error[E0463]: can't find crate for `phf_macros` / `serde_derive` / `zerofrom_derive`
dlopen(...): mis-aligned LINKEDIT string pool

这是 Rust 官方已跟踪并修复的上游 bug:

issue 内补充的环境条件:只在用 Xcode 27 链接器(LC_BUILD_VERSION SDK ≥ 27.0)链接时出现。本机 2026-09-11 装了 CLT 27.0,正好满足该条件。

影响

  • 任何冷构建都会失败:清空 target/ 后重建、以及 Jenkins 干净 workspace 的每次构建
  • 增量构建不受影响——旧的 proc-macro 产物是 CLT 26 时代生成的、本身是好的,cargo 认为指纹新鲜就不重编。这解释了为什么本地长期看起来正常,而 Jenkins 那个 Job 从未真正构建成功过
  • 直接后果:Mac 发布 Job(PR #430 引入的 dev-mac 渠道构建)无法跑通,端到端验证被阻断

实测矩阵

复现条件:--target aarch64-apple-darwin + MACOSX_DEPLOYMENT_TARGET=15.0(Tauri 会从 minimumSystemVersion: 15.0 自动注入该变量)。

rustc 产物
1.96.0(当前 pin) 损坏 ✗
1.97.0 损坏 ✗(1.97 分支在修复 PR 合并前已切出)
1.98.1 可加载 ✓

最小修复版本为 1.98.x;1.96 / 1.97 均含该缺陷。

补充:softwareupdate --list 显示无可用更新,因此无法通过更新 CLT 规避。

打算进行的更改(待确认)

  1. (推荐)将 rust-toolchain.toml 升级到 1.98.1 —— 直接应用上游修复,开发机与 CI 一并恢复
  2. 备选:仓库 pin 保持 1.96.0,只在 macOS 发布 Job 里加 RUSTUP_TOOLCHAIN=1.98.1 —— 影响面最小,但本机冷构建仍然失败
  3. 备选:改用 CLT 26 / Xcode 26 的链接器 —— Apple 不官方支持降级,且本机无法通过软件更新回退

节点侧:本机已安装 1.98.1(rustup toolchain list 可见),升级后 macOS 构建节点无需额外操作。

复现方式(10 秒)

# 任意含 proc-macro 依赖的 cargo 工程
MACOSX_DEPLOYMENT_TARGET=15.0 cargo build --release --target aarch64-apple-darwin
# → 产物 dlopen 报 mis-aligned LINKEDIT string pool,rustc 报 can't find crate

备注:1.96.0 下没有可用的规避手段

已逐个验证无效:-C strip=none-C strip=debuginfo-C debuginfo=0-Wl,-no_fixup_chains-Wl,-ld_classic-fuse-ld=lld(rust 自带 ld64.lld)。该修复位于 LLVM 内部,只能通过更换工具链解决。

## 问题原因 本仓库 `rust-toolchain.toml` 固定在 **Rust 1.96.0**。在 macOS 27(已装 CLT for Xcode 27.0)上做**冷构建**时,第一批 proc-macro crate 的 dylib 会被链接成畸形 Mach-O,dyld 拒绝加载,rustc 报: ``` error[E0463]: can't find crate for `phf_macros` / `serde_derive` / `zerofrom_derive` dlopen(...): mis-aligned LINKEDIT string pool ``` 这是 **Rust 官方已跟踪并修复**的上游 bug: - 问题:**rust-lang/rust#157750 — "Stripping debuginfo on macOS produces misaligned dylibs"** https://github.com/rust-lang/rust/issues/157750 - 修复 PR:**#158410 — "Update LLVM for Mach-O __LINKEDIT alignment fix"**(2026-06-26 合并) https://github.com/rust-lang/rust/pull/158410 issue 内补充的环境条件:**只在用 Xcode 27 链接器(`LC_BUILD_VERSION` SDK ≥ 27.0)链接时出现**。本机 2026-09-11 装了 CLT 27.0,正好满足该条件。 ## 影响 - 任何**冷构建**都会失败:清空 `target/` 后重建、以及 **Jenkins 干净 workspace 的每次构建** - 增量构建不受影响——旧的 proc-macro 产物是 CLT 26 时代生成的、本身是好的,cargo 认为指纹新鲜就不重编。**这解释了为什么本地长期看起来正常,而 Jenkins 那个 Job 从未真正构建成功过** - 直接后果:Mac 发布 Job(PR #430 引入的 dev-mac 渠道构建)无法跑通,端到端验证被阻断 ## 实测矩阵 复现条件:`--target aarch64-apple-darwin` + `MACOSX_DEPLOYMENT_TARGET=15.0`(Tauri 会从 `minimumSystemVersion: 15.0` 自动注入该变量)。 | rustc | 产物 | | --- | --- | | 1.96.0(当前 pin) | 损坏 ✗ | | 1.97.0 | 损坏 ✗(1.97 分支在修复 PR 合并前已切出) | | 1.98.1 | 可加载 ✓ | **最小修复版本为 1.98.x**;1.96 / 1.97 均含该缺陷。 补充:`softwareupdate --list` 显示无可用更新,因此无法通过更新 CLT 规避。 ## 打算进行的更改(待确认) 1. **(推荐)将 `rust-toolchain.toml` 升级到 1.98.1** —— 直接应用上游修复,开发机与 CI 一并恢复 2. 备选:仓库 pin 保持 1.96.0,只在 macOS 发布 Job 里加 `RUSTUP_TOOLCHAIN=1.98.1` —— 影响面最小,但本机冷构建仍然失败 3. 备选:改用 CLT 26 / Xcode 26 的链接器 —— Apple 不官方支持降级,且本机无法通过软件更新回退 节点侧:本机已安装 1.98.1(`rustup toolchain list` 可见),升级后 macOS 构建节点无需额外操作。 ## 复现方式(10 秒) ```sh # 任意含 proc-macro 依赖的 cargo 工程 MACOSX_DEPLOYMENT_TARGET=15.0 cargo build --release --target aarch64-apple-darwin # → 产物 dlopen 报 mis-aligned LINKEDIT string pool,rustc 报 can't find crate ``` ## 备注:1.96.0 下没有可用的规避手段 已逐个验证无效:`-C strip=none`、`-C strip=debuginfo`、`-C debuginfo=0`、`-Wl,-no_fixup_chains`、`-Wl,-ld_classic`、`-fuse-ld=lld`(rust 自带 `ld64.lld`)。该修复位于 LLVM 内部,只能通过更换工具链解决。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GenarrativeAI/Genarrative#431