Skip to content

Commit

Permalink
nix: use -ld_new on macOS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thoughtpolice committed Jun 20, 2024
1 parent f8b87f6 commit 8491644
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,11 @@
export LIBSSH2_SYS_USE_PKG_CONFIG=1
export RUSTFLAGS="-Zthreads=0"
'' + pkgs.lib.optionalString useMoldLinker ''
'' + (if (useMoldLinker) 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=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -C link-arg=-ld_new"
'') + darwinNextestHack;
};
}));
}

0 comments on commit 8491644

Please sign in to comment.