Update LLVM for Mach-O __LINKEDIT alignment fix. - #158410
Conversation
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @cuviper (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
|
|
Note, this also includes the 22.1.8 update from rust-lang/llvm-project#197 @bors r+ rollup=iffy (LLVM rebuild) |
…lign-157750, r=cuviper Update LLVM for Mach-O __LINKEDIT alignment fix. Update LLVM submodule to pull in changes from rust-lang/llvm-project#198. Fixes rust-lang#157750. This backport has been discussed in: [#t-compiler > Backport LLVM change to Rust for macOS 27 support?](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Backport.20LLVM.20change.20to.20Rust.20for.20macOS.2027.20support.3F/with/605925959).
Rollup of 10 pull requests Successful merges: - #158410 (Update LLVM for Mach-O __LINKEDIT alignment fix.) - #157397 (cmse: clear padding when crossing the secure boundary) - #158036 (Add -Zinstrument-mcount=fentry to -Zinstrument-mcount) - #158330 (llvm: use intrinsics for f16, f32 minimum/maximum) - #158359 (fix(tests): allow either branch direction in ilog_known_base) - #158067 (LLVM 23: Adapt codegen test to moved assume) - #158261 (Move part of the target checking for `#[may_dangle]` to the parser) - #158358 (Fix invalid E0609 raw pointer deref suggestion inside macros) - #158392 (delegation: add tests for defaults and infers in generics) - #158394 (Generate synthetic generic args only for delegation's child segment)
Rollup merge of #158410 - goranmoomin:update-llvm-linkedit-align-157750, r=cuviper Update LLVM for Mach-O __LINKEDIT alignment fix. Update LLVM submodule to pull in changes from rust-lang/llvm-project#198. Fixes #157750. This backport has been discussed in: [#t-compiler > Backport LLVM change to Rust for macOS 27 support?](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Backport.20LLVM.20change.20to.20Rust.20for.20macOS.2027.20support.3F/with/605925959).
Upstream fixed this in rust-lang/rust#158410, and the LLVM 22.1.8 bundled in 1.98.0 now aligns every LINKEDIT entry to pointer size rather than just the symbol strings, so the patch is redundant. Its LLVM hunk no longer applies to that refactored MachOLayoutBuilder either, so the patch phase would fail outright on any system matching the guard. No revision bump: the guard was `os.major >= 27`, which no buildable system satisfies, so the patch never applied and the installed files do not change. Assisted-by: Claude:claude-opus-5
规避背景(c8f05c8):Xcode 27 链接器为大符号量 cdylib 排布 Mach-O 符号表 时串池不按 8 字节对齐,macOS 27 dyld 对声明 sdk ≥ 27 的二进制 dlopen 拒载,当时以 -Wl,-platform_version 声明 SDK 26.0 走宽容路径规避。 rust-lang/rust#158410(llvm-objcopy Mach-O 串池对齐)已随 rustc 1.98.0 落地,mise 钉版 1.97.1 → 1.98.0;本机 macOS 27 + CLT ld-27037 实测: 去规避后无论 strip 与否,产物声明 sdk 27.0、stroff 8 字节对齐、node dlopen 均通过。CI macos-latest 为 macOS 26 + Xcode 26.6,本就无此 问题。[profile.release] strip 维持停用,注释更正为已验证可随时恢复。
Cargo passes `-C strip=debuginfo` by default in the release profile, and
below 1.98 rustc strips Mach-O with an llvm-objcopy that writes the symbol
string table straight after the 4-byte-per-entry indirect symbol table with
no padding. Whenever that table has an odd entry count the LINKEDIT string
pool lands 4-byte aligned, and macOS 27's dyld refuses to load the image:
rustc 1.95 -> stroff=345252 stroff%8=4 (rejected)
rustc 1.98 -> stroff=328880 stroff%8=0
Every release-profile proc macro is a coin flip, which is what breaks the
macOS OBS plugin build (rustc can't dlopen a derive macro), and so is every
cdylib we ship there: moq-ffi behind the Python/Kotlin/Dart bindings, and
the moq-gst plugin.
Fixed upstream in 1.98.0 by rust-lang/rust#158410, so the build toolchain
pin moves above the relay's 1.95 MSRV. The crates keep their own floors.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Cargo passes `-C strip=debuginfo` by default in the release profile, and
below 1.98 rustc strips Mach-O with an llvm-objcopy that writes the symbol
string table straight after the 4-byte-per-entry indirect symbol table with
no padding. Whenever that table has an odd entry count the LINKEDIT string
pool lands 4-byte aligned, and macOS 27's dyld refuses to load the image:
rustc 1.95 -> stroff=345252 stroff%8=4 (rejected)
rustc 1.98 -> stroff=328880 stroff%8=0
Every release-profile proc macro is a coin flip, which is what breaks the
macOS OBS plugin build (rustc can't dlopen a derive macro), and so is every
cdylib we ship there: moq-ffi behind the Python/Kotlin/Dart bindings, and
the moq-gst plugin.
Fixed upstream in 1.98.0 by rust-lang/rust#158410, so the build toolchain
pin moves above the relay's 1.95 MSRV. The crates keep their own floors.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Before 1.98, rustc strips Mach-O release artifacts with an llvm-objcopy that can leave the LINKEDIT string pool 4-byte aligned; macOS 27's dyld refuses such images, so a release build there dies with "can't find crate for `rquickjs_macro`" once the stripped proc-macro dylib will not load (fixed upstream in rust-lang/rust#158410). On 1.96.1 the stripped kloop executable itself was misaligned too, so exempting only host artifacts would not have been enough, and turning strip off would keep std's debuginfo in Linux release binaries. - rust-toolchain.toml: 1.96.1 -> 1.98.1; rust-version: 1.96 -> 1.98, since the pin is the only toolchain any gate runs. - 1.98 lints: drop `use anyhow::Context as _` from the three tools/fs platform files (the parent's import already arrives via `use super::*`) and use as_chunks in a powershell test (chunks_exact_to_as_chunks). - README and DESIGN.md "Running" name 1.98; DESIGN.md also records why 1.98 is a floor on macOS 27, and now lists the whole-workspace Windows clippy check among the Windows evidence. Verified with: make check on 1.98.1 (fmt, clippy, all 34 test binaries, parity); cargo clippy --workspace --target x86_64-pc-windows-msvc --all-targets --all-features -- -D warnings via the stand-in C compiler; make build, then every freshly built proc-macro dylib (19) and the kloop binary have LC_SYMTAB.stroff % 8 == 0 with no OSO stabs left (strip ran). Under 1.96.1 the same check found rquickjs_macro and kloop at 4. Not run on macOS 27, Linux or Windows; fallback.rs is not compiled by any available target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rustc below 1.98 strips release debuginfo (Cargo's default) with an llvm-objcopy that can leave
the Mach-O LINKEDIT string pool 4-byte aligned; macOS 27's dyld refuses it ("mis-aligned LINKEDIT
string pool", rust-lang/rust#158410). maturin's strip = false wasn't enough: Cargo's own default
still stripped. strip = "none" in the release profile avoids it on any toolchain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CrBBhViD1su1XP2Wq7diSZ
Fixes issues when building on macOS 27 see: rust-lang/rust#158410
Fixes issues when building on macOS 27 see: rust-lang/rust#158410
Update LLVM submodule to pull in changes from rust-lang/llvm-project#198.
Fixes #157750.
This backport has been discussed in: #t-compiler > Backport LLVM change to Rust for macOS 27 support?.