How theiphoneos1project/ld64-build works
Purpose and Entry Point
This repository is a macOS build wrapper for producing a patched ld64 linker binary, ld64-objc1, with fragile Objective-C runtime support. Its operational entry point is build.sh; the repository intentionally contains only orchestration and source patches, not vendored third-party code.
Paths: build.sh, README.md
Build Orchestration
build.sh is the primary control plane. It runs interactively by default and supports automation through --non-interactive. It fetches required upstream dependencies at build time, applies this repository’s patches, and compiles the resulting linker with the active Xcode toolchain.
The script’s environment is macOS 12+ with Xcode 14+ and C++20 support. Output architecture depends on Xcode generation: older toolchains can produce universal x86_64/arm64 output, while Xcode 26+ produces arm64.
Paths: build.sh, .github/workflows/build.yml
Upstream Source Boundary
No third-party source is committed here. The build process crosses a deliberate boundary from repository-owned scripts/patches into externally fetched ld64 and related dependency sources. Reproducibility therefore depends on the fetch behavior encoded in build.sh and on availability/compatibility of upstream repositories and the installed Xcode SDK.
Paths: build.sh, README.md
Patch Layer
The Patches/ directory defines the product’s differentiating behavior: adapting ld64 to support fragile Objective-C runtime handling. Patches target linker option processing, output-file generation, LTO integration, Mach-O relocatable-file processing, and Apple dynamic-loader private declarations.
Key patch surface:
• Linker option and mode behavior: Patches/Options.cpp.patch
• Output binary/linker behavior: Patches/OutputFile.cpp.patch
• LTO file handling: Patches/lto_file.cpp.patch
• Mach-O relocatable-object handling: Patches/macho_relocatable_file.cpp.patch
• dyld-private API compatibility: Patches/dyld_priv.h.patch
• Version metadata changes: Patches/Version.inc
Produced Artifact and Runtime Boundary
The build produces ld64-objc1, a linker executable rather than a standalone application. The binary is dynamically coupled to Xcode-provided libraries, specifically libtapi.dylib and libswiftDemangle.dylib. It will fail at launch unless those libraries are reachable through its runtime loader paths.
Deployment is therefore separate from compilation: users should install the executable beside a lib/ directory containing copies of the required dylibs, or place it in an existing Xcode-compatible toolchain.
Paths: README.md, build.sh
CI and Validation Infrastructure
GitHub Actions provides the repository’s automated build environment. The workflow is the main infrastructure contract for verifying that the script, patch set, and supported macOS/Xcode environment remain compatible.
Paths: .github/workflows/build.yml, build.sh
Ownership and Licensing
Repository-owned orchestration and patches are MIT-licensed. Upstream ld64 and fetched dependencies remain under their own licenses, reinforcing the separation between this build layer and externally sourced compiler/linker code.
Paths: LICENSE, Patches/, README.md
Main entry points: build.sh Build orchestrator · README.md Build and deployment guidance · LICENSE MIT license · build.yml GitHub Actions build
Components 18
Repository-owned build layer
MIT-licensed orchestration and ld64 patch set.
- Build orchestrator · Interactive by default; supports --non-interactive automation.
build.sh - Build and deployment guidance
README.md - GitHub Actions build · Validates script, patches, and supported macOS/Xcode compatibility.
.github/workflows/build.yml - Fragile ObjC patch set · Repository-specific ld64 behavior changes.
- Linker options and modes
Patches/Options.cpp.patch - Output-file behavior
Patches/OutputFile.cpp.patch - LTO handling
Patches/lto_file.cpp.patch - Mach-O relocatable handling
Patches/macho_relocatable_file.cpp.patch - dyld private compatibility
Patches/dyld_priv.h.patch - Version metadata
Patches/Version.inc - MIT license · Applies to repository-owned orchestration and patches.
LICENSE
Fetched upstream sources
Third-party sources are acquired at build time.
- ld64 and dependencies · Fetched rather than vendored; retain their own licenses.
- macOS Xcode toolchain · Requires macOS 12+, Xcode 14+, and C++20 support.
- Patched ld64 source tree · Transient upstream source after patch application.
Deployment runtime
The linker requires Xcode-provided dynamic libraries.
- ld64-objc1 · Universal x86_64/arm64 on older Xcode or arm64 on Xcode 26+.
- Xcode runtime dylibs · libtapi.dylib and libswiftDemangle.dylib must be reachable at launch.
- Installed toolchain layout · Place the executable beside lib/ copies or in a compatible Xcode toolchain.
Other components
- Developer or CI
Connections 21
- Developer or CI → Build orchestrator: runs
- GitHub Actions build → Build orchestrator: automates
- Build and deployment guidance → Build orchestrator: documents
- Build orchestrator → ld64 and dependencies: fetches
- Build orchestrator → Fragile ObjC patch set: applies
- Fragile ObjC patch set → Linker options and modes: contains
- Fragile ObjC patch set → Output-file behavior: contains
- Fragile ObjC patch set → LTO handling: contains
- Fragile ObjC patch set → Mach-O relocatable handling: contains
- Fragile ObjC patch set → dyld private compatibility: contains
- Fragile ObjC patch set → Version metadata: contains
- ld64 and dependencies → Patched ld64 source tree: provides base sources
- Fragile ObjC patch set → Patched ld64 source tree: modifies
- macOS Xcode toolchain → Build orchestrator: provides compiler and SDK
- Build orchestrator → ld64-objc1: builds
- Patched ld64 source tree → ld64-objc1: compiled as
- Xcode runtime dylibs → ld64-objc1: required at launch
- ld64-objc1 → Installed toolchain layout: installed with
- Build and deployment guidance → Installed toolchain layout: documents
- MIT license → Build orchestrator: licenses
- MIT license → Fragile ObjC patch set: licenses