From fa9a6eb88dba3f8c6db8a908ecded3d8999fa4ab Mon Sep 17 00:00:00 2001 From: Chris Marchesi Date: Mon, 20 Nov 2023 21:11:09 -0800 Subject: [PATCH] nix: use -Doptimize=ReleaseFast I figured out how to override the hook default build flags so that we can set -Doptimize=ReleaseFast. :) There's a long conversation that's gone on about this in nixpkgs, but it's fairly well summed up here: https://github.com/ziglang/zig/issues/14281#issuecomment-1624220653 I'd imagine we will want to adopt whatever is eventually done - after this, we can remove the override and rely on more first-class configuration, or logic in build.zig. --- nix/package.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nix/package.nix b/nix/package.nix index 8119d9af7..7749b2721 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -27,6 +27,17 @@ }: let + # The Zig hook has no way to select the release type without actual + # overriding of the default flags. + # + # TODO: Once + # https://github.com/ziglang/zig/issues/14281#issuecomment-1624220653 is + # ultimately acted on and has made its way to a nixpkgs implementation, this + # can probably be removed in favor of that. + zig012Hook = zig_0_12.hook.overrideAttrs { + zig_default_flags = "-Dcpu=baseline -Doptimize=ReleaseFast"; + }; + # This hash is the computation of the zigCache fixed-output derivation. This # allows us to use remote package dependencies without breaking the sandbox. # @@ -82,7 +93,7 @@ stdenv.mkDerivation (finalAttrs: { git ncurses pkg-config - zig_0_12.hook + zig012Hook ]; buildInputs = [