From 2b284e73665703da61720f9d33b4f3c13b0e04ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= <peterke@gmail.com>
Date: Fri, 3 Mar 2017 12:18:44 +0200
Subject: [PATCH] build: fix xgo argument order when building from make

---
 build/ci.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/build/ci.go b/build/ci.go
index 05e95b0f1..4ff63fd7f 100644
--- a/build/ci.go
+++ b/build/ci.go
@@ -930,9 +930,9 @@ func doXgo(cmdline []string) {
 
 	// If all tools building is requested, build everything the builder wants
 	args := append(buildFlags(env), flag.Args()...)
-	args = append(args, []string{"--dest", GOBIN}...)
 
 	if *alltools {
+		args = append(args, []string{"--dest", GOBIN}...)
 		for _, res := range allToolsArchiveFiles {
 			if strings.HasPrefix(res, GOBIN) {
 				// Binary tool found, cross build it explicitly
@@ -945,6 +945,9 @@ func doXgo(cmdline []string) {
 		return
 	}
 	// Otherwise xxecute the explicit cross compilation
+	path := args[len(args)-1]
+	args = append(args[:len(args)-1], []string{"--dest", GOBIN, path}...)
+
 	xgo := xgoTool(args)
 	build.MustRun(xgo)
 }
-- 
GitLab