build/config: Link -dead_strip_dylibs on macOS

This commit is contained in:
Lorenz Leutgeb
2026-08-06 17:31:04 +02:00
parent 4641c342c6
commit 6ba619f9a6
+16
View File
@@ -11,3 +11,19 @@ rustflags = [
"-C", "incremental=false",
"-C", "opt-level=3",
]
# Both `libgit2-sys` and `libc` link `iconv` on Apple targets, so `rustc` passes
# `-liconv` twice. Apple's `ld` deduplicates, but Zig does not, and
# emits two `LC_LOAD_DYLIB` commands for `/usr/lib/libiconv.2.dylib`.
# `dyld` on macOS 26 refuses to load such a binary ("duplicate linked dylib"),
# while older versions tolerate it.
# `-dead_strip_dylibs` drops the redundant entry.
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-Wl,-dead_strip_dylibs",
]
[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-Wl,-dead_strip_dylibs",
]