···1818, buildPackages
1919, pkgsBuildTarget
2020, callPackage
2121+, threadsCross ? null # for MinGW
2122}:
2323+2424+# threadsCross is just for MinGW
2525+assert threadsCross != null -> stdenv.targetPlatform.isWindows;
22262327let
2428 go_bootstrap = buildPackages.callPackage ./bootstrap.nix { };
···5054 # We need a target compiler which is still runnable at build time,
5155 # to handle the cross-building case where build != host == target
5256 targetCC = pkgsBuildTarget.targetPackages.stdenv.cc;
5757+5858+ isCross = stdenv.buildPlatform != stdenv.targetPlatform;
5359in
54605561stdenv.mkDerivation rec {
···7076 propagatedBuildInputs = lib.optionals stdenv.isDarwin [ xcbuild ];
71777278 depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ];
7979+8080+ depsBuildTarget = lib.optional isCross targetCC;
8181+8282+ depsTargetTarget = lib.optional (threadsCross != null) threadsCross;
73837484 hardeningDisable = [ "all" ];
7585···194204 # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those
195205 # to be different from CC/CXX
196206 CC_FOR_TARGET =
197197- if (stdenv.buildPlatform != stdenv.targetPlatform) then
207207+ if isCross then
198208 "${targetCC}/bin/${targetCC.targetPrefix}cc"
199209 else
200210 null;
201211 CXX_FOR_TARGET =
202202- if (stdenv.buildPlatform != stdenv.targetPlatform) then
212212+ if isCross then
203213 "${targetCC}/bin/${targetCC.targetPrefix}c++"
204214 else
205215 null;
···223233224234 export PATH=$(pwd)/bin:$PATH
225235226226- ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) ''
236236+ ${lib.optionalString isCross ''
227237 # Independent from host/target, CC should produce code for the building system.
228238 # We only set it when cross-compiling.
229239 export CC=${buildPackages.stdenv.cc}/bin/cc