about summary refs log tree commit diff
path: root/pkgs/development/compilers/go
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2022-05-18 08:13:11 -0400
committerShea Levy <shea@shealevy.com>2022-05-18 08:13:11 -0400
commit5726b8faec7e5d1cbb08debd26f8ea0063f33abe (patch)
treeb9baf05f137bb12643a1c7c07f7473d4177f53f7 /pkgs/development/compilers/go
parentf4033eeeafc0c180a45c9e17b9577e6ce2c93681 (diff)
go_1_18: Fix build when targetting MinGW
Diffstat (limited to 'pkgs/development/compilers/go')
-rw-r--r--pkgs/development/compilers/go/1.18.nix16
1 files changed, 13 insertions, 3 deletions
diff --git a/pkgs/development/compilers/go/1.18.nix b/pkgs/development/compilers/go/1.18.nix
index aad9c27fc563b..48ca47321cdca 100644
--- a/pkgs/development/compilers/go/1.18.nix
+++ b/pkgs/development/compilers/go/1.18.nix
@@ -18,8 +18,12 @@
 , buildPackages
 , pkgsBuildTarget
 , callPackage
+, threadsCross ? null # for MinGW
 }:
 
+# threadsCross is just for MinGW
+assert threadsCross != null -> stdenv.targetPlatform.isWindows;
+
 let
   go_bootstrap = buildPackages.callPackage ./bootstrap.nix { };
 
@@ -50,6 +54,8 @@ let
   # We need a target compiler which is still runnable at build time,
   # to handle the cross-building case where build != host == target
   targetCC = pkgsBuildTarget.targetPackages.stdenv.cc;
+
+  isCross = stdenv.buildPlatform != stdenv.targetPlatform;
 in
 
 stdenv.mkDerivation rec {
@@ -71,6 +77,10 @@ stdenv.mkDerivation rec {
 
   depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ];
 
+  depsBuildTarget = lib.optional isCross targetCC;
+
+  depsTargetTarget = lib.optional (threadsCross != null) threadsCross;
+
   hardeningDisable = [ "all" ];
 
   prePatch = ''
@@ -188,12 +198,12 @@ stdenv.mkDerivation rec {
   # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those
   # to be different from CC/CXX
   CC_FOR_TARGET =
-    if (stdenv.buildPlatform != stdenv.targetPlatform) then
+    if isCross then
       "${targetCC}/bin/${targetCC.targetPrefix}cc"
     else
       null;
   CXX_FOR_TARGET =
-    if (stdenv.buildPlatform != stdenv.targetPlatform) then
+    if isCross then
       "${targetCC}/bin/${targetCC.targetPrefix}c++"
     else
       null;
@@ -217,7 +227,7 @@ stdenv.mkDerivation rec {
 
     export PATH=$(pwd)/bin:$PATH
 
-    ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) ''
+    ${lib.optionalString isCross ''
     # Independent from host/target, CC should produce code for the building system.
     # We only set it when cross-compiling.
     export CC=${buildPackages.stdenv.cc}/bin/cc