···18, buildPackages
19, pkgsBuildTarget
20, callPackage
021}:
0002223let
24 go_bootstrap = buildPackages.callPackage ./bootstrap.nix { };
···50 # We need a target compiler which is still runnable at build time,
51 # to handle the cross-building case where build != host == target
52 targetCC = pkgsBuildTarget.targetPackages.stdenv.cc;
0053in
5455stdenv.mkDerivation rec {
···70 propagatedBuildInputs = lib.optionals stdenv.isDarwin [ xcbuild ];
7172 depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ];
00007374 hardeningDisable = [ "all" ];
75···194 # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those
195 # to be different from CC/CXX
196 CC_FOR_TARGET =
197- if (stdenv.buildPlatform != stdenv.targetPlatform) then
198 "${targetCC}/bin/${targetCC.targetPrefix}cc"
199 else
200 null;
201 CXX_FOR_TARGET =
202- if (stdenv.buildPlatform != stdenv.targetPlatform) then
203 "${targetCC}/bin/${targetCC.targetPrefix}c++"
204 else
205 null;
···223224 export PATH=$(pwd)/bin:$PATH
225226- ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) ''
227 # Independent from host/target, CC should produce code for the building system.
228 # We only set it when cross-compiling.
229 export CC=${buildPackages.stdenv.cc}/bin/cc
···18, buildPackages
19, pkgsBuildTarget
20, callPackage
21+, threadsCross ? null # for MinGW
22}:
23+24+# threadsCross is just for MinGW
25+assert threadsCross != null -> stdenv.targetPlatform.isWindows;
2627let
28 go_bootstrap = buildPackages.callPackage ./bootstrap.nix { };
···54 # We need a target compiler which is still runnable at build time,
55 # to handle the cross-building case where build != host == target
56 targetCC = pkgsBuildTarget.targetPackages.stdenv.cc;
57+58+ isCross = stdenv.buildPlatform != stdenv.targetPlatform;
59in
6061stdenv.mkDerivation rec {
···76 propagatedBuildInputs = lib.optionals stdenv.isDarwin [ xcbuild ];
7778 depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ];
79+80+ depsBuildTarget = lib.optional isCross targetCC;
81+82+ depsTargetTarget = lib.optional (threadsCross != null) threadsCross;
8384 hardeningDisable = [ "all" ];
85···204 # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those
205 # to be different from CC/CXX
206 CC_FOR_TARGET =
207+ if isCross then
208 "${targetCC}/bin/${targetCC.targetPrefix}cc"
209 else
210 null;
211 CXX_FOR_TARGET =
212+ if isCross then
213 "${targetCC}/bin/${targetCC.targetPrefix}c++"
214 else
215 null;
···233234 export PATH=$(pwd)/bin:$PATH
235236+ ${lib.optionalString isCross ''
237 # Independent from host/target, CC should produce code for the building system.
238 # We only set it when cross-compiling.
239 export CC=${buildPackages.stdenv.cc}/bin/cc