Build fails on macOS 27: dyld refuses stripped Rust proc-macros (mis-aligned LINKEDIT string pool)

Aperta Adatta ai principianti
#8,963 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
73/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
macos, rust
Ambito
build-system

Direzione di ricerca

Inizia dalla versione di Rust fissata in build/deps/rust.MODULE.bazel e dalle impostazioni di compilazione macOS in .bazelrc; confronta l’aggiornamento proposto alla versione 1.98.0 con la soluzione temporanea tramite il flag exec di rustc. Verifica che la soluzione scelta consenta a bazel build //src/workerd/server:workerd di completarsi su macOS 27 mantenendo il requisito della toolchain --config=cross-lto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

On macOS 27, bazel build //src/workerd/server:workerd on main (e7d43bddb) fails at the first crate that uses a proc-macro:

error[E0463]: can't find crate for `thiserror_impl`

rustc can't load the proc-macro dylib, and dlopen on it says why:

dlopen(.../darwin_arm64-opt-exec/bin/external/rules_rust++i2+rrc__thiserror-impl-1.0.69/libthiserror_impl-991351018.dylib, 0x0002): tried: '...' (mis-aligned LINKEDIT string pool, fileOffset=0x001682DC)

This is rust-lang/rust#157750. Bazel builds exec-config Rust in opt mode, where rules_rust passes -Cstrip=debuginfo. The LLVM in rustc 1.97 writes the stripped dylib's string pool at a 4-byte boundary (LC_SYMTAB stroff 1475292), and dyld rejects that when the dylib was linked against the 27 SDK. llvm/llvm-project#203680 fixed the stripper, and rustc 1.98.0 shipped it (rust-lang/rust#158410). workerd pins 1.97.1 in build/deps/rust.MODULE.bazel.

I hit it on macOS 27.3 (26C5047e) with the Command Line Tools linker (ld-27106.1, SDK 27.2). CI runs macos-26-xlarge, and the README tests Xcode 26.6, so neither should see it; I haven't checked an Xcode 26 build on a macOS 27 host.

The workaround is one line in .local/bazelrc:

build --@rules_rust//:extra_exec_rustc_flag=-Cstrip=none

With it, the same build on a clean main worktree completes in 2990 s.

I see two fixes:

  1. Bump RUST_STABLE_VERSION to 1.98.0. It's the last stable on LLVM 22, so it still matches the toolchains_llvm 22.1.8 that --config=cross-lto needs; 1.99 moves to LLVM 23. rules_rust 0.75.0 already has its checksums.
  2. Put the flag above under build:macos in .bazelrc until the bump lands.

I have an attempt at (2) on a branch if you want it.

Minimal cdylib from rust-lang/rust#157750 on 3 rustc versions: only 1.97.1 with strip=debuginfo fails to load

minimal.rs is the MCVE from the rustc issue, built with rustc --crate-type cdylib minimal.rs -C strip=<level> and loaded with a 5-line dlopen program, on macOS 27.3.

rustc (LLVM) strip stroff mod 8 dlopen
1.97.1 (22.1.6) debuginfo 4 mis-aligned LINKEDIT string pool
1.97.1 (22.1.6) none 0 ok
1.98.0 (22.1.8) debuginfo 0 ok
1.98.0 (22.1.8) none 0 ok
1.100.0 (23.1.5) debuginfo 0 ok
1.100.0 (23.1.5) none 0 ok
Lingua principale
C++
Stelle
9.3k
Fork
845
Merge medio
1g 23h
PR unite (30g)
558

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cloudflare/workerd

Tutte le issue di cloudflare/workerd

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.