ld64
ld64 copied to clipboard
Instructions on how to build the ld64 linker on macOS
ld64
These instructions are for building ld64 based on Apple's sources for the ld64 that comes with Xcode 10.1 and the dyld from Mojave (10.14.1) with clang/llvm 7.0.1.
Thanks to @rmaz for helping simplify my instructions.
- Initial setup
- Install Xcode 10.1 from Apple
- Clone this project, or download the zip.
- Navigate to the project directory in the terminal.
- Make sure there are no spaces in the current directory path, or things will go badly for you.
- Get Sources
curl https://opensource.apple.com/tarballs/ld64/ld64-409.12.tar.gz --output ld64-409.12.tar.gz | tar xzcurl https://opensource.apple.com/tarballs/dyld/dyld-635.2.tar.gz --output dyld-635.2.tar.gz | tar xzmkdir tapi-mastercurl -L https://github.com/ributzka/tapi/tarball/master | tar xz -C tapi-master --strip-components=1curl http://releases.llvm.org/7.0.1/llvm-7.0.1.src.tar.xz | tar xJcurl http://releases.llvm.org/7.0.1/cfe-7.0.1.src.tar.xz | tar xJ
- Apply patches
patch -p1 -d tapi-master < patches/tapi.patchpatch -p1 -d ld64-409.12 < patches/ld64.patchpatch -p1 -d dyld-635.2 < patches/dyld.patch
- Configure ld64 project
open ld64-409.12/ld64.xcodeproj- Change the
Base SDKfor the ld64 project frommacosx.internaltomacos
- Remove the override for
Base SDKfrom the ld target so it changes frommacosx.internaltomacos(you can do this be selecting it and hitting delete).
- Add the following
Header Search Paths:$(SRCROOT)/../tapi-master/include$(SRCROOT)/../dyld-635.2/include$(SRCROOT)/../llvm-7.0.1.src/include$(SRCROOT)/../cfe-7.0.1.src/include
- Set
Treat Warnings as ErrorstoNo
- Select the
ldtarget to build Build
You should be able to replace the ld64 that comes with Xcode 10.1 with this one (located in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/). It will successfully link macOS 10.14, iOS 12 apps.
Be sure to back up your original ld64!!!
Do not ship anything to Apple that was linked with this linker. This is purely for debugging linker related issues.
Level of support
This is not an officially supported Google product.