···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
+13-3
pkgs/development/compilers/go/1.18.nix
···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···188198 # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those
189199 # to be different from CC/CXX
190200 CC_FOR_TARGET =
191191- if (stdenv.buildPlatform != stdenv.targetPlatform) then
201201+ if isCross then
192202 "${targetCC}/bin/${targetCC.targetPrefix}cc"
193203 else
194204 null;
195205 CXX_FOR_TARGET =
196196- if (stdenv.buildPlatform != stdenv.targetPlatform) then
206206+ if isCross then
197207 "${targetCC}/bin/${targetCC.targetPrefix}c++"
198208 else
199209 null;
···217227218228 export PATH=$(pwd)/bin:$PATH
219229220220- ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) ''
230230+ ${lib.optionalString isCross ''
221231 # Independent from host/target, CC should produce code for the building system.
222232 # We only set it when cross-compiling.
223233 export CC=${buildPackages.stdenv.cc}/bin/cc