just playing with tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

nix: use mold linker on Linux

Summary: Pure QOL improvement, not that this was too awful as it stood. But this
ultimately makes all builds faster, effectively for free; on my Linux machine,
debug link time for jj-cli goes from 3s to 1s.

This was originally submitted as part of #1864, and backed out as part of #1982,
because the default `mold` package did not have the proper "wrapper script"
that allowed it to find the right external libraries. Using the `mold-wrapped`
package however fixes this.

On top of that, let's go ahead and make `mold` the default linker in the Nix
package/flake as well; this should improve the `nix build` speed since a lot of
tests need to be linked.

Signed-off-by: Austin Seipp <aseipp@pobox.com>

+15 -2
+15 -2
flake.nix
··· 49 49 libiconv 50 50 ]; 51 51 52 + # NOTE (aseipp): on Linux, go ahead and use mold by default to improve 53 + # link times a bit; mostly useful for debug build speed, but will help 54 + # over time if we ever get more dependencies, too 55 + useMoldLinker = pkgs.stdenv.isLinux; 56 + 57 + # these are needed in both devShell and buildInputs 58 + linuxNativeDeps = with pkgs; lib.optionals stdenv.isLinux [ 59 + mold-wrapped 60 + ]; 61 + 52 62 in 53 63 { 54 64 packages = { ··· 72 82 installShellFiles 73 83 makeWrapper 74 84 pkg-config 75 - ]; 85 + ] ++ linuxNativeDeps; 76 86 buildInputs = with pkgs; [ 77 87 openssl zstd libgit2 libssh2 78 88 ] ++ darwinDeps; 79 89 80 90 ZSTD_SYS_USE_PKG_CONFIG = "1"; 81 91 LIBSSH2_SYS_USE_PKG_CONFIG = "1"; 92 + RUSTFLAGS = pkgs.lib.optionalString useMoldLinker "-C link-arg=-fuse-ld=mold"; 82 93 NIX_JJ_GIT_HASH = self.rev or ""; 83 94 CARGO_INCREMENTAL = "0"; 84 95 ··· 135 146 136 147 # For building the documentation website 137 148 poetry 138 - ] ++ darwinDeps; 149 + ] ++ darwinDeps ++ linuxNativeDeps; 139 150 140 151 shellHook = '' 141 152 export RUST_BACKTRACE=1 142 153 export ZSTD_SYS_USE_PKG_CONFIG=1 143 154 export LIBSSH2_SYS_USE_PKG_CONFIG=1 155 + '' + pkgs.lib.optionalString useMoldLinker '' 156 + export RUSTFLAGS="-C link-arg=-fuse-ld=mold $RUSTFLAGS" 144 157 ''; 145 158 }; 146 159 }));