From 56a1e3d64b6b9d2507d831f5997561ec9f3257a7 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Thu, 13 Jun 2024 15:29:05 -0500 Subject: [PATCH] nix: use `-ld_new` on macOS The new parallel macOS linker reduces link time for the debug `jj` binary from 3s to 0.7s on my M2 Macbook Air, which is a significant reduction for nearly no cost at all. However, enabling it is rather strange because we have to give a full path to the /Applications directory, and I don't know of a good way to encapsulate it with existing Nix primitives inside Nixpkgs... This change requires Sonoma and Xcode 15, but in theory I think we could target a lower macOS SDK version in order to produce binaries that are more backwards compatible, so the only real cost is that developers who also use Nix would require Sonoma. --- flake.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index bbafd1cde1..b33e60bec4 100644 --- a/flake.nix +++ b/flake.nix @@ -176,9 +176,11 @@ export LIBSSH2_SYS_USE_PKG_CONFIG=1 export RUSTFLAGS="-Zthreads=0" - '' + pkgs.lib.optionalString useMoldLinker '' + '' + (if pkgs.stdenv.isLinux then '' export RUSTFLAGS+=" -C link-arg=-fuse-ld=mold -C link-arg=-Wl,--compress-debug-sections=zstd" - '' + darwinNextestHack; + '' else '' + export RUSTFLAGS+=" -C link-arg=-fuse-ld=/usr/bin/ld -C link-arg=-ld_new" + '') + darwinNextestHack; }; })); }