You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#70 investigated enabling LTO (-flto) in scripts/build-zstd.sh for a compile-time cross-TU inlining win. It works fine on Linux (zig cc links ELF with its bundled real lld), but is currently impossible on macOS:
$ zig cc -target aarch64-macos -O3 -flto -c third_party/zstd/lib/common/xxhash.c -o /tmp/test.o
error: LTO requires using LLD
zig's Mach-O backend is a self-hosted linker, not LLD, so it has no LTO support at all — this reproduces at the -c (compile-only) stage, before any linking. -fuse-ld=lld doesn't help either (no real ld64.lld binary was available to force it).
Separately, even where LTO did work (Linux), the benchmark in #70 showed a net regression on the compress path (zstdJavaBytes -6.2%, zstdJavaSegment -3.7%) versus a smaller decompress gain (+1.9-2.5%) — so LTO was rejected project-wide, not just on macOS. This issue is scoped narrowly to the macOS tooling blocker, in case zig gains Mach-O LTO support and it's ever worth re-benchmarking.
What to watch for
zig adding LTO support to its self-hosted Mach-O linker, or shipping a real ld64.lld that zig cc -fuse-ld=lld can target on macOS.
Track via zig release notes / changelog for aarch64-macos and x86_64-macos linker work.
Re-benchmark compress/decompress (JMH, benchmark-lto.yml) — the Linux result (compress regression, decompress gain) may or may not hold on ARM/Mach-O codegen, so don't assume the same disposition applies.
No action needed until then; this issue exists purely to remember to check back.
Background
#70 investigated enabling LTO (
-flto) inscripts/build-zstd.shfor a compile-time cross-TU inlining win. It works fine on Linux (zig cclinks ELF with its bundled reallld), but is currently impossible on macOS:zig's Mach-O backend is a self-hosted linker, not LLD, so it has no LTO support at all — this reproduces at the
-c(compile-only) stage, before any linking.-fuse-ld=llddoesn't help either (no realld64.lldbinary was available to force it).Separately, even where LTO did work (Linux), the benchmark in #70 showed a net regression on the compress path (
zstdJavaBytes-6.2%,zstdJavaSegment-3.7%) versus a smaller decompress gain (+1.9-2.5%) — so LTO was rejected project-wide, not just on macOS. This issue is scoped narrowly to the macOS tooling blocker, in case zig gains Mach-O LTO support and it's ever worth re-benchmarking.What to watch for
ld64.lldthatzig cc -fuse-ld=lldcan target on macOS.aarch64-macosandx86_64-macoslinker work.Revisit when
If Mach-O LTO becomes available via
zig cc:-fltoexperiment from Optimize the native build #70 onosx-aarch64/osx-x86_64.benchmark-lto.yml) — the Linux result (compress regression, decompress gain) may or may not hold on ARM/Mach-O codegen, so don't assume the same disposition applies.No action needed until then; this issue exists purely to remember to check back.