From 3c8981ee8bc18e62e5f16b9d323bfe1065ebee0a Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 25 Dec 2020 01:35:33 +0100 Subject: [PATCH] buildGoModule: fix cross-compilation with CGO_ENABLED=1 When building a go binary that's linking against some .so/.a, while cross-compiling, we need to pass the correct compiler, otherwise `go build` will fail with the not-so helpful error message: ``` gcc_arm64.S: Assembler messages: gcc_arm64.S:28: Error: no such instruction: `stp x29,x30,[sp,' gcc_arm64.S:32: Error: too many memory references for `mov' gcc_arm64.S:34: Error: no such instruction: `stp x19,x20,[sp,' gcc_arm64.S:37: Error: no such instruction: `stp x21,x22,[sp,' gcc_arm64.S:40: Error: no such instruction: `stp x23,x24,[sp,' gcc_arm64.S:43: Error: no such instruction: `stp x25,x26,[sp,' gcc_arm64.S:46: Error: no such instruction: `stp x27,x28,[sp,' gcc_arm64.S:50: Error: too many memory references for `mov' gcc_arm64.S:51: Error: too many memory references for `mov' gcc_arm64.S:52: Error: too many memory references for `mov' gcc_arm64.S:54: Error: no such instruction: `blr x20' gcc_arm64.S:55: Error: no such instruction: `blr x19' gcc_arm64.S:57: Error: no such instruction: `ldp x27,x28,[sp,' gcc_arm64.S:60: Error: no such instruction: `ldp x25,x26,[sp,' gcc_arm64.S:63: Error: no such instruction: `ldp x23,x24,[sp,' gcc_arm64.S:66: Error: no such instruction: `ldp x21,x22,[sp,' gcc_arm64.S:69: Error: no such instruction: `ldp x19,x20,[sp,' gcc_arm64.S:72: Error: no such instruction: `ldp x29,x30,[sp],' ``` --- pkgs/development/go-modules/generic/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/go-modules/generic/default.nix b/pkgs/development/go-modules/generic/default.nix index 58716d37170..130387a97b0 100644 --- a/pkgs/development/go-modules/generic/default.nix +++ b/pkgs/development/go-modules/generic/default.nix @@ -46,7 +46,7 @@ with builtins; let args = removeAttrs args' [ "overrideModAttrs" "vendorSha256" "disabled" ]; - go-modules = if vendorSha256 != null then go.stdenv.mkDerivation (let modArgs = { + go-modules = if vendorSha256 != null then stdenv.mkDerivation (let modArgs = { name = "${name}-go-modules"; @@ -119,7 +119,7 @@ let } ) // overrideModAttrs modArgs) else ""; - package = go.stdenv.mkDerivation (args // { + package = stdenv.mkDerivation (args // { nativeBuildInputs = [ go ] ++ nativeBuildInputs; inherit (go) GOOS GOARCH;