From 8571cc18d9402e86ce420b66ce0fa518da8179ec Mon Sep 17 00:00:00 2001 From: aleksana Date: Sun, 4 May 2025 00:34:14 +0800 Subject: [PATCH] stdenv.mkDerivation: correct requiredSystemFeatures gccarch condition --- pkgs/stdenv/generic/make-derivation.nix | 28 ++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 22338e9983ff..1c655adb744c 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -528,11 +528,29 @@ let // optionalAttrs (hardeningDisable != [ ] || hardeningEnable != [ ] || stdenv.hostPlatform.isMusl) { NIX_HARDENING_ENABLE = builtins.concatStringsSep " " enabledHardeningOptions; } - // optionalAttrs (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform ? gcc.arch) { - requiredSystemFeatures = attrs.requiredSystemFeatures or [ ] ++ [ - "gccarch-${stdenv.hostPlatform.gcc.arch}" - ]; - } + // + # TODO: remove platform condition + # Enabling this check could be a breaking change as it requires to edit nix.conf + # NixOS module already sets gccarch, unsure of nix installers and other distributions + optionalAttrs + ( + stdenv.buildPlatform ? gcc.arch + && !( + stdenv.buildPlatform.isAarch64 + && ( + # `aarch64-darwin` sets `{gcc.arch = "armv8.3-a+crypto+sha2+...";}` + stdenv.buildPlatform.isDarwin + || + # `aarch64-linux` has `{ gcc.arch = "armv8-a"; }` set by default + stdenv.buildPlatform.gcc.arch == "armv8-a" + ) + ) + ) + { + requiredSystemFeatures = attrs.requiredSystemFeatures or [ ] ++ [ + "gccarch-${stdenv.buildPlatform.gcc.arch}" + ]; + } // optionalAttrs (stdenv.buildPlatform.isDarwin) ( let allDependencies = concatLists (concatLists dependencies);