From 3546e574ca97115384aa82d1c4cae935b10870dc Mon Sep 17 00:00:00 2001 From: silvanshade Date: Mon, 31 Mar 2025 09:35:41 -0600 Subject: [PATCH 1/2] Use mold instead of GNU ld for faster builds --- packaging/dev-shell.nix | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packaging/dev-shell.nix b/packaging/dev-shell.nix index e824ebf71..ae491f5b6 100644 --- a/packaging/dev-shell.nix +++ b/packaging/dev-shell.nix @@ -71,12 +71,17 @@ pkgs.nixComponents.nix-util.overrideAttrs ( # We use this shell with the local checkout, not unpackPhase. src = null; - env = { - # For `make format`, to work without installing pre-commit - _NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml" - modular.pre-commit.settings.rawConfig - }"; - }; + env = + { + # For `make format`, to work without installing pre-commit + _NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml" + modular.pre-commit.settings.rawConfig + }"; + } + // lib.optionalAttrs stdenv.hostPlatform.isLinux { + CC_LD = "mold"; + CXX_LD = "mold"; + }; mesonFlags = map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents.nix-util.mesonFlags) @@ -119,7 +124,8 @@ pkgs.nixComponents.nix-util.overrideAttrs ( ++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) pkgs.buildPackages.bear ++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) ( lib.hiPrio pkgs.buildPackages.clang-tools - ); + ) + ++ lib.optional stdenv.hostPlatform.isLinux pkgs.buildPackages.mold-wrapped; buildInputs = attrs.buildInputs or [ ] From cfeb9404a8a63d10e19101b81b25653d0b6385c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 1 Apr 2025 12:52:24 +0200 Subject: [PATCH 2/2] remove deprecated gold linker Binutils deprecated the gold linker, so do we. For development we now use mold instead, we can potentially also use it for release builds later. --- packaging/components.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packaging/components.nix b/packaging/components.nix index 991d54241..e51e79755 100644 --- a/packaging/components.nix +++ b/packaging/components.nix @@ -159,13 +159,6 @@ let ]; separateDebugInfo = !stdenv.hostPlatform.isStatic; hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie"; - env = - prevAttrs.env or { } - // lib.optionalAttrs ( - stdenv.isLinux - && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux") - && !(stdenv.hostPlatform.useLLVM or false) - ) { LDFLAGS = "-fuse-ld=gold"; }; }; mesonLibraryLayer = finalAttrs: prevAttrs: {