From 4aa9e4ecc6c3d1cf48379cb2e89aac32c0a6b4f7 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Sun, 14 Apr 2024 15:32:41 +0200 Subject: [PATCH] wrapCC, wrapBintools: don't alias stdenvNoCC to stdenv In delicate code like this, it seems unwise to pass something of as something it isn't for convenience's (?) sake. It causes a slight possibility for confusion with `buildPackages.stdenv`. However, it should be possible to eliminate the need for this in a separate change. --- .../bintools-wrapper/default.nix | 13 ++++---- pkgs/build-support/cc-wrapper/default.nix | 32 +++++++++---------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index b2545d0ad0e5..8baac3626892 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -83,8 +83,7 @@ let replaceStrings ; - stdenv = stdenvNoCC; - inherit (stdenv) hostPlatform targetPlatform; + inherit (stdenvNoCC) hostPlatform targetPlatform; # Prefix for binaries. Customarily ends with a dash separator. # @@ -138,7 +137,7 @@ let in -stdenv.mkDerivation { +stdenvNoCC.mkDerivation { pname = targetPrefix + (if name != "" then name else "${bintoolsName}-wrapper"); version = optionalString (bintools != null) bintoolsVersion; @@ -346,7 +345,7 @@ stdenv.mkDerivation { done '' - + optionalString stdenv.targetPlatform.isDarwin '' + + optionalString stdenvNoCC.targetPlatform.isDarwin '' echo "-arch ${targetPlatform.darwinArch}" >> $out/nix-support/libc-ldflags '' @@ -363,7 +362,7 @@ stdenv.mkDerivation { ### ### Remove certain timestamps from final binaries ### - + optionalString (stdenv.targetPlatform.isDarwin && !(bintools.isGNU or false)) '' + + optionalString (stdenvNoCC.targetPlatform.isDarwin && !(bintools.isGNU or false)) '' echo "export ZERO_AR_DATE=1" >> $out/nix-support/setup-hook '' @@ -380,9 +379,9 @@ stdenv.mkDerivation { ### ### Ensure consistent LC_VERSION_MIN_MACOSX ### - + optionalString stdenv.targetPlatform.isDarwin ( + + optionalString stdenvNoCC.targetPlatform.isDarwin ( let - inherit (stdenv.targetPlatform) + inherit (stdenvNoCC.targetPlatform) darwinPlatform darwinSdkVersion darwinMinVersion darwinMinVersionVariable; in '' diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index fa32108963f3..17029736faca 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -82,9 +82,7 @@ let versionAtLeast ; - inherit (stdenv) hostPlatform targetPlatform; - - stdenv = stdenvNoCC; + inherit (stdenvNoCC) hostPlatform targetPlatform; includeFortifyHeaders' = if includeFortifyHeaders != null then includeFortifyHeaders @@ -119,10 +117,10 @@ let useGccForLibs = useCcForLibs && libcxx == null - && !stdenv.targetPlatform.isDarwin - && !(stdenv.targetPlatform.useLLVM or false) - && !(stdenv.targetPlatform.useAndroidPrebuilt or false) - && !(stdenv.targetPlatform.isiOS or false) + && !stdenvNoCC.targetPlatform.isDarwin + && !(stdenvNoCC.targetPlatform.useLLVM or false) + && !(stdenvNoCC.targetPlatform.useAndroidPrebuilt or false) + && !(stdenvNoCC.targetPlatform.isiOS or false) && gccForLibs != null; gccForLibs_solib = getLib gccForLibs + optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}"; @@ -249,17 +247,17 @@ let then cc.hardeningUnsupportedFlagsByTargetPlatform targetPlatform else (cc.hardeningUnsupportedFlags or []); - darwinPlatformForCC = optionalString stdenv.targetPlatform.isDarwin ( + darwinPlatformForCC = optionalString stdenvNoCC.targetPlatform.isDarwin ( if (targetPlatform.darwinPlatform == "macos" && isGNU) then "macosx" else targetPlatform.darwinPlatform ); - darwinMinVersion = optionalString stdenv.targetPlatform.isDarwin ( - stdenv.targetPlatform.darwinMinVersion + darwinMinVersion = optionalString stdenvNoCC.targetPlatform.isDarwin ( + stdenvNoCC.targetPlatform.darwinMinVersion ); - darwinMinVersionVariable = optionalString stdenv.targetPlatform.isDarwin - stdenv.targetPlatform.darwinMinVersionVariable; + darwinMinVersionVariable = optionalString stdenvNoCC.targetPlatform.isDarwin + stdenvNoCC.targetPlatform.darwinMinVersionVariable; in assert includeFortifyHeaders' -> fortify-headers != null; @@ -272,7 +270,7 @@ assert nativeTools == bintools.nativeTools; assert nativeLibc == bintools.nativeLibc; assert nativePrefix == bintools.nativePrefix; -stdenv.mkDerivation { +stdenvNoCC.mkDerivation { pname = targetPrefix + (if name != "" then name else "${ccName}-wrapper"); version = optionalString (cc != null) ccVersion; @@ -426,7 +424,7 @@ stdenv.mkDerivation { ../setup-hooks/role.bash ] ++ optional (cc.langC or true) ./setup-hook.sh ++ optional (cc.langFortran or false) ./fortran-hook.sh - ++ optional (targetPlatform.isWindows) (stdenv.mkDerivation { + ++ optional (targetPlatform.isWindows) (stdenvNoCC.mkDerivation { name = "win-dll-hook.sh"; dontUnpack = true; installPhase = '' @@ -479,8 +477,8 @@ stdenv.mkDerivation { # break `useLLVM` into.) + optionalString (isClang && targetPlatform.isLinux - && !(stdenv.targetPlatform.useAndroidPrebuilt or false) - && !(stdenv.targetPlatform.useLLVM or false) + && !(stdenvNoCC.targetPlatform.useAndroidPrebuilt or false) + && !(stdenvNoCC.targetPlatform.useLLVM or false) && gccForLibs != null) ('' echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags @@ -689,7 +687,7 @@ stdenv.mkDerivation { done '' - + optionalString stdenv.targetPlatform.isDarwin '' + + optionalString stdenvNoCC.targetPlatform.isDarwin '' echo "-arch ${targetPlatform.darwinArch}" >> $out/nix-support/cc-cflags ''