go_1_18: Fix build when targetting MinGW

+13 -3
+13 -3
pkgs/development/compilers/go/1.18.nix
··· 18 18 , buildPackages 19 19 , pkgsBuildTarget 20 20 , callPackage 21 + , threadsCross ? null # for MinGW 21 22 }: 23 + 24 + # threadsCross is just for MinGW 25 + assert threadsCross != null -> stdenv.targetPlatform.isWindows; 22 26 23 27 let 24 28 go_bootstrap = buildPackages.callPackage ./bootstrap.nix { }; ··· 50 54 # We need a target compiler which is still runnable at build time, 51 55 # to handle the cross-building case where build != host == target 52 56 targetCC = pkgsBuildTarget.targetPackages.stdenv.cc; 57 + 58 + isCross = stdenv.buildPlatform != stdenv.targetPlatform; 53 59 in 54 60 55 61 stdenv.mkDerivation rec { ··· 70 76 propagatedBuildInputs = lib.optionals stdenv.isDarwin [ xcbuild ]; 71 77 72 78 depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ]; 79 + 80 + depsBuildTarget = lib.optional isCross targetCC; 81 + 82 + depsTargetTarget = lib.optional (threadsCross != null) threadsCross; 73 83 74 84 hardeningDisable = [ "all" ]; 75 85 ··· 188 198 # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those 189 199 # to be different from CC/CXX 190 200 CC_FOR_TARGET = 191 - if (stdenv.buildPlatform != stdenv.targetPlatform) then 201 + if isCross then 192 202 "${targetCC}/bin/${targetCC.targetPrefix}cc" 193 203 else 194 204 null; 195 205 CXX_FOR_TARGET = 196 - if (stdenv.buildPlatform != stdenv.targetPlatform) then 206 + if isCross then 197 207 "${targetCC}/bin/${targetCC.targetPrefix}c++" 198 208 else 199 209 null; ··· 217 227 218 228 export PATH=$(pwd)/bin:$PATH 219 229 220 - ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) '' 230 + ${lib.optionalString isCross '' 221 231 # Independent from host/target, CC should produce code for the building system. 222 232 # We only set it when cross-compiling. 223 233 export CC=${buildPackages.stdenv.cc}/bin/cc