mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-25 00:36:30 +00:00
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>
This commit is contained in:
parent
fc2b595098
commit
c8271f7617
1 changed files with 15 additions and 2 deletions
17
flake.nix
17
flake.nix
|
@ -49,6 +49,16 @@
|
|||
libiconv
|
||||
];
|
||||
|
||||
# NOTE (aseipp): on Linux, go ahead and use mold by default to improve
|
||||
# link times a bit; mostly useful for debug build speed, but will help
|
||||
# over time if we ever get more dependencies, too
|
||||
useMoldLinker = pkgs.stdenv.isLinux;
|
||||
|
||||
# these are needed in both devShell and buildInputs
|
||||
linuxNativeDeps = with pkgs; lib.optionals stdenv.isLinux [
|
||||
mold-wrapped
|
||||
];
|
||||
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
|
@ -72,13 +82,14 @@
|
|||
installShellFiles
|
||||
makeWrapper
|
||||
pkg-config
|
||||
];
|
||||
] ++ linuxNativeDeps;
|
||||
buildInputs = with pkgs; [
|
||||
openssl zstd libgit2 libssh2
|
||||
] ++ darwinDeps;
|
||||
|
||||
ZSTD_SYS_USE_PKG_CONFIG = "1";
|
||||
LIBSSH2_SYS_USE_PKG_CONFIG = "1";
|
||||
RUSTFLAGS = pkgs.lib.optionalString useMoldLinker "-C link-arg=-fuse-ld=mold";
|
||||
NIX_JJ_GIT_HASH = self.rev or "";
|
||||
CARGO_INCREMENTAL = "0";
|
||||
|
||||
|
@ -135,12 +146,14 @@
|
|||
|
||||
# For building the documentation website
|
||||
poetry
|
||||
] ++ darwinDeps;
|
||||
] ++ darwinDeps ++ linuxNativeDeps;
|
||||
|
||||
shellHook = ''
|
||||
export RUST_BACKTRACE=1
|
||||
export ZSTD_SYS_USE_PKG_CONFIG=1
|
||||
export LIBSSH2_SYS_USE_PKG_CONFIG=1
|
||||
'' + pkgs.lib.optionalString useMoldLinker ''
|
||||
export RUSTFLAGS="-C link-arg=-fuse-ld=mold $RUSTFLAGS"
|
||||
'';
|
||||
};
|
||||
}));
|
||||
|
|
Loading…
Reference in a new issue