From 81f818aa86a96b39614eba23a95e5332a4c4ab84 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Fri, 29 May 2026 14:22:37 +0200 Subject: [PATCH] nix: Go around a linker issue on Darwin (#58070) Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [ ] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [ ] Performance impact has been considered and is acceptable Release Notes: - N/A --- nix/build.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nix/build.nix b/nix/build.nix index 2f283f83a4d..0375b0de5f8 100644 --- a/nix/build.nix +++ b/nix/build.nix @@ -38,6 +38,7 @@ libxfixes, libxkbcommon, libxrandr, + lld, libx11, libxcb, nodejs_22, @@ -137,6 +138,8 @@ let ] ++ lib.optionals stdenv'.hostPlatform.isLinux [ makeWrapper ] ++ lib.optionals stdenv'.hostPlatform.isDarwin [ + # Provides `ld64.lld` for clang's `-fuse-ld=lld`. + lld (cargo-bundle.overrideAttrs ( new: old: { version = "0.6.1-zed"; @@ -246,6 +249,11 @@ let }"; NIX_OUTPATH_USED_AS_RANDOM_SEED = "norebuilds"; + } + // lib.optionalAttrs stdenv'.hostPlatform.isDarwin { + # Link with lld on Darwin. nixpkgs' classic open-source ld64 fails to insert + # ARM64 branch thunks for this binary, producing `b(l) ARM64 branch out of range`. + NIX_CFLAGS_LINK = "-fuse-ld=lld"; }; # prevent nix from removing the "unused" wayland/gpu-lib rpaths