Skip to content

Commit

Permalink
nix: fix usage of new parallel linker in Darwin devShell
Browse files Browse the repository at this point in the history
As reported by @lilyball on Discord, the recent nixpkgs update this week brought
with it an entirely new Darwin stdenv, which had a behavioral change versus
the prior one, causing builds inside the developer shell to fail, as the new
super-duper parallel linker could not be used.

However, rather than giving up and throwing away *billions* of precious CPU
cycles, @emilazy and @lilyball instead doubled down and diagnosed the issue. The
result is a new impenetrable line of Nix code, which is fully explained by the
comments within.

Signed-off-by: Austin Seipp <[email protected]>
  • Loading branch information
thoughtpolice committed Nov 26, 2024
1 parent 7f57866 commit 4c55d54
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@
if pkgs.stdenv.isLinux then
[ "-fuse-ld=mold" "-Wl,--compress-debug-sections=zstd" ]
else if pkgs.stdenv.isDarwin then
[ "-fuse-ld=/usr/bin/ld" "-ld_new" ]
# on darwin, /usr/bin/ld actually looks at the environment variable
# $DEVELOPER_DIR, which is set by the nix stdenv, and if set,
# automatically uses it to route the `ld` invocation to the binary
# within. in the devShell though, that isn't what we want; it's
# functional, but we actually want to use the newer Xcode linker
# instead (unfortunately not yet open source) which is ultra-fast and
# very shiny; it is enabled via -ld_new
[ "-fuse-ld=ld" "--ld-path=$(unset DEVELOPER_DIR; /usr/bin/xcrun -find ld)" "-ld_new" ]
else
[ ];

Expand Down

0 comments on commit 4c55d54

Please sign in to comment.