diff --git a/pkgs/by-name/ld/ld64/package.nix b/pkgs/by-name/ld/ld64/package.nix index 6ecbc20da105..8699a4132d4a 100644 --- a/pkgs/by-name/ld/ld64/package.nix +++ b/pkgs/by-name/ld/ld64/package.nix @@ -19,25 +19,35 @@ let # Copy the files from their original sources instead of using patches to reduce the size of the patch set in nixpkgs. otherSrcs = { # The last version of ld64 to have dyldinfo - ld64 = fetchFromGitHub { + dyldinfo = fetchFromGitHub { owner = "apple-oss-distributions"; repo = "ld64"; tag = "ld64-762"; hash = "sha256-UIq/fwO40vk8yvoTfx+UlLhnuzkI0Ih+Ym6W/BwnP0s="; }; + # The last version of ld64 to have machochecker and libpruntrie + machochecker = fetchFromGitHub { + owner = "apple-oss-distributions"; + repo = "ld64"; + tag = "ld64-954.16"; + hash = "sha256-CVIyL2J9ISZnI4+r+wp4QtOb3+3Tmz2z2Z7/qeRqHS0="; + }; + # Provides the source files used in the vendored libtapi. The libtapi derivation puts `tapi-src` first. libtapi = lib.head libtapi.srcs; }; - ld64src = lib.escapeShellArg "${otherSrcs.ld64}"; + dyldinfoSrc = lib.escapeShellArg "${otherSrcs.dyldinfo}"; + machocheckerSrc = lib.escapeShellArg "${otherSrcs.machochecker}"; + libprunetrieSrc = lib.escapeShellArg "${otherSrcs.machochecker}"; libtapisrc = lib.escapeShellArg "${otherSrcs.libtapi}"; llvmPath = "${lib.getLib llvm}"; in stdenv.mkDerivation (finalAttrs: { pname = "ld64"; - version = "954.16"; + version = "956.6"; outputs = [ "out" @@ -49,16 +59,15 @@ stdenv.mkDerivation (finalAttrs: { owner = "apple-oss-distributions"; repo = "ld64"; tag = "ld64-${finalAttrs.version}"; - hash = "sha256-CVIyL2J9ISZnI4+r+wp4QtOb3+3Tmz2z2Z7/qeRqHS0="; + hash = "sha256-2VlBjlCZ+ZPKGZ0f5UuG3jJTLZIBXf8IZOiD6snheh4="; }; patches = [ - # These patches are vendored from https://github.com/reckenrode/ld64/tree/ld64-951.9-nixpkgs. + # These patches are vendored from https://github.com/reckenrode/ld64/tree/ld64-956.6-nixpkgs. # See their comments for more on what they do. ./patches/0001-Always-use-write-instead-of-mmap.patch ./patches/0002-Add-compile_stubs.h-using-Clang-s-embed-extension-fo.patch ./patches/0003-Inline-missing-definitions-instead-of-using-private-.patch - ./patches/0004-Removed-unused-Blob-clone-method.patch ./patches/0005-Use-std-atomics-and-std-mutex-for-portability.patch ./patches/0006-Add-Meson-build-system.patch ./patches/0007-Add-CrashReporterClient-header.patch @@ -73,16 +82,22 @@ stdenv.mkDerivation (finalAttrs: { ./patches/0016-Add-dyldinfo-to-the-ld64-build.patch ./patches/0017-Fix-dyldinfo-build.patch ./patches/0018-Use-STL-containers-instead-of-LLVM-containers.patch - - # Fix zippered versions on macOS 26+. Part of upstream ld64-956.6. Remove on next version bump. - # https://github.com/apple-oss-distributions/ld64/commit/1a4389663d65d6630e4b3e31ace2a86b6183b452 - ./patches/0019-Fix-zippered-versions-macos-26.patch + ./patches/0019-Deduplicate-RPATH-entries.patch + ./patches/0020-Remove-private-analytics-APIs.patch + ./patches/0021-Support-text-based-stubs-with-compatible-architectur.patch ]; prePatch = '' # Copy dyldinfo source files - cp ${ld64src}/doc/man/man1/dyldinfo.1 doc/man/man1/dyldinfo.1 - cp ${ld64src}/src/other/dyldinfo.cpp src/other/dyldinfo.cpp + cp ${dyldinfoSrc}/doc/man/man1/dyldinfo.1 doc/man/man1/dyldinfo.1 + cp ${dyldinfoSrc}/src/other/dyldinfo.cpp src/other/dyldinfo.cpp + + # Copy machochecker source files + cp ${machocheckerSrc}/src/other/machochecker.cpp src/other/machochecker.cpp + + # The current version of cctools in Nixpkgs needs libprunetrie + cp ${libprunetrieSrc}/src/other/PruneTrie.cpp src/other/PruneTrie.cpp + cp ${libprunetrieSrc}/src/other/prune_trie.h src/other/prune_trie.h # Copy files needed from libtapi by ld64 mkdir -p subprojects/libtapi/tapi @@ -104,7 +119,7 @@ stdenv.mkDerivation (finalAttrs: { done ''; - xcodeHash = "sha256-qip/1eiGn8PdLThonhPq3oq2veN4E1zOiamDPBfTeNE="; + xcodeHash = "sha256-b0KCdHkMWsdOb68LB8B2rbZPAQma8AOnGUGQNvHOnV0="; xcodeProject = "ld64.xcodeproj"; nativeBuildInputs = [ diff --git a/pkgs/by-name/ld/ld64/patches/0003-Inline-missing-definitions-instead-of-using-private-.patch b/pkgs/by-name/ld/ld64/patches/0003-Inline-missing-definitions-instead-of-using-private-.patch index 7622f9a8e70f..82333e8948c0 100644 --- a/pkgs/by-name/ld/ld64/patches/0003-Inline-missing-definitions-instead-of-using-private-.patch +++ b/pkgs/by-name/ld/ld64/patches/0003-Inline-missing-definitions-instead-of-using-private-.patch @@ -1,7 +1,7 @@ -From ddcefc16f5db7fd36c885cf3bcd3713c8383e93b Mon Sep 17 00:00:00 2001 +From 57222d068a4ba1d64249d19fb4a281d8dd9c0a5e Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Wed, 13 Nov 2024 13:53:14 -0500 -Subject: [PATCH 03/18] Inline missing definitions instead of using private +Subject: [PATCH] Inline missing definitions instead of using private mach-o/dyld_private.h header Based on: https://github.com/llvm/llvm-project/blob/38870fe124eb5e6e24136f9d3e4551a62370faee/libunwind/src/AddressSpace.hpp#L57-L67 @@ -11,7 +11,7 @@ Based on: https://github.com/llvm/llvm-project/blob/38870fe124eb5e6e24136f9d3e45 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ld/Options.cpp b/src/ld/Options.cpp -index 991387f..cde3fad 100644 +index b52747a..9841689 100644 --- a/src/ld/Options.cpp +++ b/src/ld/Options.cpp @@ -35,7 +35,6 @@ @@ -19,9 +19,9 @@ index 991387f..cde3fad 100644 #include #include -#include + #include #include - #include diff --git a/src/ld/parsers/libunwind/AddressSpace.hpp b/src/ld/parsers/libunwind/AddressSpace.hpp index eb47390..0788cc2 100644 --- a/src/ld/parsers/libunwind/AddressSpace.hpp @@ -52,5 +52,5 @@ index eb47390..0788cc2 100644 namespace libunwind { -- -2.47.2 +2.51.2 diff --git a/pkgs/by-name/ld/ld64/patches/0004-Removed-unused-Blob-clone-method.patch b/pkgs/by-name/ld/ld64/patches/0004-Removed-unused-Blob-clone-method.patch deleted file mode 100644 index 05c45d651a1b..000000000000 --- a/pkgs/by-name/ld/ld64/patches/0004-Removed-unused-Blob-clone-method.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 3c0038576173103e8aaa5286f853046b619c35fe Mon Sep 17 00:00:00 2001 -From: Randy Eckenrode -Date: Wed, 13 Nov 2024 13:53:14 -0500 -Subject: [PATCH 04/18] Removed unused `Blob::clone` method - -Fixes a compiler error due to a missing `BlobCore::clone` method. ---- - src/ld/code-sign-blobs/blob.h | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/src/ld/code-sign-blobs/blob.h b/src/ld/code-sign-blobs/blob.h -index 19c63a9..2ac0aa8 100644 ---- a/src/ld/code-sign-blobs/blob.h -+++ b/src/ld/code-sign-blobs/blob.h -@@ -179,9 +179,6 @@ public: - return p; - return NULL; - } -- -- BlobType *clone() const -- { assert(validateBlob()); return specific(this->BlobCore::clone()); } - - static BlobType *readBlob(int fd) - { return specific(BlobCore::readBlob(fd, _magic, sizeof(BlobType), 0), true); } --- -2.47.2 - diff --git a/pkgs/by-name/ld/ld64/patches/0006-Add-Meson-build-system.patch b/pkgs/by-name/ld/ld64/patches/0006-Add-Meson-build-system.patch index 70756685c2f7..60b998d8d1dd 100644 --- a/pkgs/by-name/ld/ld64/patches/0006-Add-Meson-build-system.patch +++ b/pkgs/by-name/ld/ld64/patches/0006-Add-Meson-build-system.patch @@ -35,7 +35,7 @@ index 0000000..cd4e8da + license : 'APSL-2.0', + license_files : 'APPLE_LICENSE', + meson_version : '>=1.6.0', -+ version : '954.16', ++ version : '956.6', +) + +add_project_arguments( diff --git a/pkgs/by-name/ld/ld64/patches/0019-Deduplicate-RPATH-entries.patch b/pkgs/by-name/ld/ld64/patches/0019-Deduplicate-RPATH-entries.patch new file mode 100644 index 000000000000..25bd52279065 --- /dev/null +++ b/pkgs/by-name/ld/ld64/patches/0019-Deduplicate-RPATH-entries.patch @@ -0,0 +1,72 @@ +From 19919df4055361b5c24458766754dbe01b67df69 Mon Sep 17 00:00:00 2001 +From: Ben Simms +Date: Wed, 15 Apr 2026 21:53:24 -0400 +Subject: [PATCH] Deduplicate RPATH entries + +This is required for MacOS 15.4 and above, which rejects loading +libraries with duplicate RPATH entries +--- + src/ld/HeaderAndLoadCommands.hpp | 29 +- + src/ld/HeaderAndLoadCommands.hpp.orig | 1828 +++++++++++++++++++++++++ + 2 files changed, 1855 insertions(+), 2 deletions(-) + create mode 100644 src/ld/HeaderAndLoadCommands.hpp.orig + +diff --git a/src/ld/HeaderAndLoadCommands.hpp b/src/ld/HeaderAndLoadCommands.hpp +index 55700768df..4001f47c0e 100644 +--- a/src/ld/HeaderAndLoadCommands.hpp ++++ b/src/ld/HeaderAndLoadCommands.hpp +@@ -472,7 +472,14 @@ + + if ( _hasRPathLoadCommands ) { + const std::vector& rpaths = _options.rpaths(); ++ std::set seen; ++ + for (std::vector::const_iterator it = rpaths.begin(); it != rpaths.end(); ++it) { ++ std::string it_(*it); ++ if (seen.find(it_) != std::end(seen)) ++ continue; ++ seen.insert(it_); ++ + sz += alignedSize(sizeof(macho_rpath_command

) + strlen(*it) + 1); + } + } +@@ -581,8 +588,18 @@ + + count += _dylibLoadCommmandsCount; + +- count += _options.rpaths().size(); +- ++ { ++ const std::vector& rpaths = _options.rpaths(); ++ std::set seen; ++ for (std::vector::const_iterator it = rpaths.begin(); it != rpaths.end(); ++it) { ++ std::string it_(*it); ++ if (seen.find(it_) != std::end(seen)) ++ continue; ++ seen.insert(it_); ++ ++count; ++ } ++ } ++ + if ( _hasSubFrameworkLoadCommand ) + ++count; + +@@ -1771,7 +1788,15 @@ + + if ( _hasRPathLoadCommands ) { + const std::vector& rpaths = _options.rpaths(); ++ std::set seen; ++ + for (std::vector::const_iterator it = rpaths.begin(); it != rpaths.end(); ++it) { ++ std::string it_(*it); ++ if (seen.find(it_) != std::end(seen)) ++ continue; ++ ++ seen.insert(it_); ++ + p = this->copyRPathLoadCommand(p, *it); + } + } +-- +2.51.2 + diff --git a/pkgs/by-name/ld/ld64/patches/0019-Fix-zippered-versions-macos-26.patch b/pkgs/by-name/ld/ld64/patches/0019-Fix-zippered-versions-macos-26.patch deleted file mode 100644 index 06f5ce310272..000000000000 --- a/pkgs/by-name/ld/ld64/patches/0019-Fix-zippered-versions-macos-26.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/ld/Options.cpp b/src/ld/Options.cpp ---- a/src/ld/Options.cpp -+++ b/src/ld/Options.cpp -@@ -4882,7 +4885,8 @@ void Options::reconfigureDefaults() - uint32_t iOSMacOSMajorVersion = (iOSMacVersion >> 16) & 0xFFFF; - - // macOS 11 -> iOSMac 14, and so on -- uint32_t newMajorVersion = macOSMajorVersion + 3; -+ uint32_t newMajorVersion = macOSMajorVersion < 26 ? macOSMajorVersion + 3 : macOSMajorVersion; -+ // rdar://154107557 (ld64 fix handling of zippered versions for macOS 26+) - if ( newMajorVersion > iOSMacOSMajorVersion ) { - uint32_t newVersion = newMajorVersion << 16; - std::string oldVersionString = getVersionString32(iOSMacVersion); diff --git a/pkgs/by-name/ld/ld64/patches/0020-Remove-private-analytics-APIs.patch b/pkgs/by-name/ld/ld64/patches/0020-Remove-private-analytics-APIs.patch new file mode 100644 index 000000000000..cca29a541707 --- /dev/null +++ b/pkgs/by-name/ld/ld64/patches/0020-Remove-private-analytics-APIs.patch @@ -0,0 +1,52 @@ +From 0b587a5f6df1cbab0ff145b96672a95faed301d1 Mon Sep 17 00:00:00 2001 +From: Randy Eckenrode +Date: Tue, 14 Apr 2026 21:35:22 -0400 +Subject: [PATCH] Remove private analytics APIs + +--- + src/ld/Options.cpp | 2 -- + src/ld/Options.h | 3 --- + 2 files changed, 5 deletions(-) + +diff --git a/src/ld/Options.cpp b/src/ld/Options.cpp +index 9841689..00adba2 100644 +--- a/src/ld/Options.cpp ++++ b/src/ld/Options.cpp +@@ -35,13 +35,11 @@ + #include + #include + #include +-#include + + #include + #include + #include + #include +-#include + + #include "ld.hpp" + #include "Options.h" +diff --git a/src/ld/Options.h b/src/ld/Options.h +index e1cd720..20ba2ab 100644 +--- a/src/ld/Options.h ++++ b/src/ld/Options.h +@@ -33,7 +33,6 @@ + #include + #include + #include +-#include + + #include "ld.hpp" + #include "Snapshot.h" +@@ -664,8 +663,6 @@ private: + void cannotBeUsedWithBitcode(const char* arg); + void loadImplictZipperFile(const char *path,std::vector& paths); + void inferArchAndPlatform(); +- xpc_object_t makeAnalyticsObject() const; +- void sendAnalytics() const; + + + // ObjectFile::ReaderOptions fReaderOptions; +-- +2.51.2 + diff --git a/pkgs/by-name/ld/ld64/patches/0021-Support-text-based-stubs-with-compatible-architectur.patch b/pkgs/by-name/ld/ld64/patches/0021-Support-text-based-stubs-with-compatible-architectur.patch new file mode 100644 index 000000000000..db1d08915b30 --- /dev/null +++ b/pkgs/by-name/ld/ld64/patches/0021-Support-text-based-stubs-with-compatible-architectur.patch @@ -0,0 +1,35 @@ +From f18377dd297f669be5b9fbf10c132698f452c318 Mon Sep 17 00:00:00 2001 +From: Randy Eckenrode +Date: Tue, 14 Apr 2026 21:35:22 -0400 +Subject: [PATCH] Support text-based stubs with compatible architectures + +This is necessary to support newer (e.g., 26.4) SDKs, which only include +symbol definitions for arm64e. Fortunately, arm64e dylibs are +ABI-compatible with arm64 binaries. +--- + subprojects/libtapi/LinkerInterfaceFile.cpp | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/subprojects/libtapi/LinkerInterfaceFile.cpp b/subprojects/libtapi/LinkerInterfaceFile.cpp +index 632eac8b0f..dfc5a18a73 100644 +--- a/subprojects/libtapi/LinkerInterfaceFile.cpp ++++ b/subprojects/libtapi/LinkerInterfaceFile.cpp +@@ -186,6 +186,15 @@ + + if (enforceCpuSubType) + return AK_unknown; ++ ++ // Check whether any archs has a compatible cpu type and return that if so. ++ for (const auto& targetArch : archs) { ++ auto [targetCpuType, _] = getCPUTypeFromArchitecture(targetArch); ++ if (cpuType == targetCpuType) { ++ return targetArch; ++ } ++ } ++ + return arch; + } + +-- +2.51.2 +