stdenv.mkDerivation: check if host suffix is necessary

Rather than precomputing what the stdenv host suffix should be, we check
the condition first. This is even better than turning the concats into
multiple comparisons (although I'm going to do that as well), since if
hostPlatform == buildPlatform, we never have to evaluate any further.
This commit is contained in:
Eman Resu
2026-05-02 17:27:49 -04:00
parent efa31b9d8b
commit 9e49230e6d
+7 -5
View File
@@ -229,9 +229,8 @@ let
canExecuteHostOnBuild = buildPlatform.canExecute hostPlatform;
defaultHardeningFlags =
(if stdenvHasCC then stdenv.cc else { }).defaultHardeningFlags or knownHardeningFlags;
stdenvHostSuffix = optionalString (
hostPlatform != buildPlatform && stdenvHasCC
) "-${hostPlatform.config}";
hostSuffixNecessary = hostPlatform != buildPlatform && stdenvHasCC;
stdenvHostSuffix = "-${hostPlatform.config}";
stdenvStaticMarker = optionalString isStatic "-static";
userHook = config.stdenv.userHook or null;
@@ -529,8 +528,10 @@ let
# just used for their side-affects. Those might as well since the
# hash can't be the same. See #32986.
hostSuffix = optionalString (
!(attrs ? outputHash)
||
hostSuffixNecessary &&
(
!(attrs ? outputHash)
||
(
depsBuildTarget
++ depsBuildTargetPropagated
@@ -541,6 +542,7 @@ let
++ depsTargetTarget
++ depsTargetTargetPropagated
) == [ ]
)
) stdenvHostSuffix;
# Disambiguate statically built packages. This was originally