Skip to content

Commit b46a0c9

Browse files
committed
Adapt pydantic-core linker flags on macOS
Co-authored-by: Elena Washington <[email protected]> Backport of: #13147
1 parent 50629c8 commit b46a0c9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎pydantic-core/build.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@ fn main() {
1313
}
1414
println!("cargo:rustc-check-cfg=cfg(specified_profile_use)");
1515
println!("cargo:rustc-env=PROFILE={}", std::env::var("PROFILE").unwrap());
16+
17+
// The macOS `ld_prime` new Linker (used in macOS 15 GitHub CI runners),
18+
// reserves significantly less Mach-O header padding than the old linker.
19+
// Tools like Homebrew use install_name_tool to rewrite dylib paths post-install,
20+
// and that requires spare space in the header. Without this flag the relink
21+
// fails with "updated load commands do not fit in the header".
22+
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos") {
23+
println!("cargo:rustc-link-arg=-Wl,-headerpad_max_install_names");
24+
}
1625
}

0 commit comments

Comments
 (0)