惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
GbyAI
GbyAI
aimingoo的专栏
aimingoo的专栏
L
LangChain Blog
I
InfoQ
D
Docker
F
Fortinet All Blogs
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
月光博客
月光博客
B
Blog
Engineering at Meta
Engineering at Meta
T
Tailwind CSS Blog
罗磊的独立博客
博客园_首页
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
IT之家
IT之家
V
V2EX

Peter Steinberger

OpenClaw, OpenAI and the future | Peter Steinberger Shipping at Inference-Speed | Peter Steinberger The Signature Flicker | Peter Steinberger Just Talk To It - the no-bs Way of Agentic Engineering | Peter Steinberger Claude Code Anonymous | Peter Steinberger Live Coding Session: Building Arena | Peter Steinberger My Current AI Dev Workflow | Peter Steinberger Essential Reading for Agentic Engineers - August 2025 | Peter Steinberger Just One More Prompt | Peter Steinberger Poltergeist: The Ghost That Keeps Your Builds Fresh | Peter Steinberger Don't read this Startup Slop | Peter Steinberger Essential Reading for Agentic Engineers - July 2025 | Peter Steinberger Self-Hosting AI Models After Claude's Usage Limits | Peter Steinberger Logging Privacy Shenanigans | Peter Steinberger VibeTunnel's first AI-anniversary | Peter Steinberger Making AppleScript Work in macOS CLI Tools: The Undocumented Parts | Peter Steinberger Peekaboo 2.0 – Free the CLI from its MCP shackles | Peter Steinberger Command your Claude Code Army, Reloaded | Peter Steinberger Essential Reading for Agentic Engineers | Peter Steinberger Slot Machines for Programmers: How Peter Builds Apps 20x Faster with AI | Peter Steinberger My AI Workflow for Understanding Any Codebase | Peter Steinberger stats.store: Privacy-First Sparkle Analytics | Peter Steinberger Showing Settings from macOS Menu Bar Items: A 5-Hour Journey | Peter Steinberger VibeTunnel: Turn Any Browser into Your Mac's Terminal | Peter Steinberger Vibe Meter 2.0: Calculating Claude Code Usage with Token Counting | Peter Steinberger llm.codes: Make Apple Docs AI-Readable | Peter Steinberger Automatic Observation Tracking in UIKit and AppKit: The Feature Apple Forgot to Mention | Peter Steinberger Peekaboo MCP – lightning-fast macOS screenshots for AI agents | Peter Steinberger Migrating 700+ Tests to Swift Testing: A Real-World Experience | Peter Steinberger Commanding Your Claude Code Army | Peter Steinberger
zld — A Faster Version of Apple's Linker | Peter Steinberger
Peter Steinberger · 2020-06-05 · via Peter Steinberger

zld is a drop-in replacement of Apple’s linker that uses optimized data structures and parallelizing to speed things up. It comes with a great promise:

“Feel free to file an issue if you find it’s not at least 40% faster for your case” — Michael Eisel, Maintainer

In our setup, zld indeed improves overall build time by approximately 25 percent, measured from a clean build to the running application. Building PSPDFCatalog in debug mode with ccache enabled and everything precached takes roughly:

  • ld — 4:40min
  • zld — 3:30min

If you’re asking yourself, is this safe? Well, Instagram uses it too.

Heads up: zld seems to cause issues when using the Swift trunk toolchain.

Installation

zld is easy to enable for your project:

  1. brew install michaeleisel/zld/zld
  2. OTHER_LDFLAGS = -fuse-ld=/usr/local/bin/zld

In our setup, things aren’t quite so easy, as we have a few additional requirements:

  • The build should work independently of zld installed, so people can opt in on their own and don’t have a surprising build failure after pulling master. This is even truer for CI.
  • We have a large monorepo with different projects in different folders, which is managed by shared xcconfig files.

I wrote a zld-detect wrapper that conditionally forwards to zld if found. Otherwise, it uses Apple’s default linker:

#!/bin/sh

# /usr/local/bin is not always included in the Xcode context.
export PATH="$PATH:/usr/local/bin"

# Detect if zld is available.
if type -p zld >/dev/null 2>&1; then
  exec zld "$@"
else
  exec ld "$@"
fi

The second problem (different paths) was solved by defining a REPOROOT = "$(SRCROOT)/../.."; in each project, so that we could build a path from the root of the monorepo and only have one location for the zld-detect script:

OTHER_LDFLAGS = -ObjC -Wl,-no_uuid -fuse-ld=$(REPOROOT)/iOS/Resources/zld-detect

Mac Catalyst

After implementing the above, our Mac Catalyst builds started failing:

Building for Mac Catalyst, but linking in .tbd built for , file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks//CoreImage.framework/CoreImage.tbd' for architecture x86_64

It seems there’s some special code in the linker that helps with linking the correct framework for Mac Catalyst, which isn’t yet part of the v510 release. Apple released v520 and v530 of the ld64 project, so there’s a good chance this will be fixed once zld merges with upstream (Issue #43).

Writing this conditionally in xcconfig is tricky, as there’s no support for a separate architecture like [sdk=maccatalyst] (Apple folks: FB6822740).

Here’s how things look if we put everything together:

// Settings to improve link time performance for debug/test builds
// https://github.com/michaeleisel/zld#a-faster-version-of-apples-linker
// Linker fails for Mac Catalyst — maybe try once it's updated to v530.
// This is always defined as YES or NO.
PSPDF_ZLD = -fuse-ld=$(REPOROOT)/iOS/Resources/zld-detect
PSPDF_LINKER_MACCATALYST_YES = ""
PSPDF_LINKER_MACCATALYST_NO = $(PSPDF_ZLD)
// This will be the case on iOS.
PSPDF_LINKER_MACCATALYST_ = $(PSPDF_ZLD)
PSPDF_LINKER_IF_NOT_CATALYST = $(PSPDF_LINKER_MACCATALYST_$(IS_MACCATALYST))
PSPDF_NORELEASE_LDFLAGS = -ObjC -Wl,-no_uuid $(PSPDF_LINKER_IF_NOT_CATALYST)

In Defaults-Debug.xcconfig and Defaults-testing.xcconfig

// Use fast linker if available.
OTHER_LDFLAGS = $(inherited) $(PSPDF_NORELEASE_LDFLAGS)

Update: Xcode also supports the LD xcconfig key to make this even easier to configure.

That’s it! Let me know on Twitter if this was helpful.