From patchwork Tue May 8 15:55:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 910307 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="TZFg+xS3"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40gPGc60qGz9s1w for ; Wed, 9 May 2018 01:55:52 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E327F22763; Tue, 8 May 2018 15:55:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jR4Z2n2jlCEn; Tue, 8 May 2018 15:55:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 611392267B; Tue, 8 May 2018 15:55:46 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 3E97C1BFFDE for ; Tue, 8 May 2018 15:55:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 3B34322703 for ; Tue, 8 May 2018 15:55:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Uk6ojhBfCaz1 for ; Tue, 8 May 2018 15:55:43 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) by silver.osuosl.org (Postfix) with ESMTPS id 91BDB22664 for ; Tue, 8 May 2018 15:55:43 +0000 (UTC) Received: by mail-wr0-f173.google.com with SMTP id v5-v6so32794276wrf.9 for ; Tue, 08 May 2018 08:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id; bh=g1UWDXhpA2vKmDMNhrwcv2ZnfRV2i9pK4eWynHJrDb4=; b=TZFg+xS3YVf72eoYj0djbsyZ4d+d+n/xNI68ltGiLW2ezZnu06+pfv1DxS4JWUAwTg igLMrC4ufwff8P+O1wuBj1V1AXUJO7a0cR7fbmpk5Yd1bm/DvAo5vNegSYcmuxUfqwUD OhHeakoE8/bCXbswj8N50ZULvCj6NXxpzE8eE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=g1UWDXhpA2vKmDMNhrwcv2ZnfRV2i9pK4eWynHJrDb4=; b=GaeUORkAIXa1DrVi6W30cqwZfedRcYKE1Kyhb45Tjj8CUoa43IZ3piGLnsdnj4T/vI KsduGMWB6+VB/E4llmQWyKSB9plLHd05zfCkveD5TgsJLFP4VZmlSenP57jKWMFGsU6C 3Y98+mhsE2D+OYD7u6MRSUAUuURpY2qrNH8U+cJ8ji+n4v0qyp2+ITkSQ9TPeUNrdaOp ng21vBUs9Jo1IRw2bJelsjoMOxh0onNKMj3c/LVzJEpmCEi5Yfc33g654SLVOfF8fSCM +78Fuk/vdv0MTqdABuddttqYPbuYCe4MkWHJQdPiSEN5ctRU8QHkoM5we0n1KaVnJ1lT aFPQ== X-Gm-Message-State: ALQs6tCYRw2yFxPwS305AcFckqP5z4VvUkGgNfnWxrgln94oAICKm/xm imRuhwrGXJMaA7ajQU5C9ozDzvw4TTc= X-Google-Smtp-Source: AB8JxZo1wgbFrNmTon91MNwJlgyBkgxUuDG01kaNp211o7zaud3egEgX742mrvytBbcPxIOLvIfjIQ== X-Received: by 2002:adf:ad46:: with SMTP id p64-v6mr30652258wrc.44.1525794941651; Tue, 08 May 2018 08:55:41 -0700 (PDT) Received: from localhost.localdomain ([89.202.204.147]) by smtp.gmail.com with ESMTPSA id e202-v6sm12462701wma.43.2018.05.08.08.55.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 May 2018 08:55:40 -0700 (PDT) From: Angelo Compagnucci To: buildroot@buildroot.org Date: Tue, 8 May 2018 17:55:37 +0200 Message-Id: <1525794937-15437-1-git-send-email-angelo@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 Subject: [Buildroot] [PATCH] package/go: fixing host go cross compilation X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Angelo Compagnucci MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Actually if GOHOSTOS == GOOS || GOHOSTARCH == GOARCH the go build system assume it's not cross compiling and uses the same toolchain for both the host and the target. This commit adds a patch to enable the explicit GO_ASSUME_CROSSCOMPILING in go build system and updates to go package accordingly. Fixes: http://autobuild.buildroot.net/results/3636b1ac5756a782fd7578186508aaf9d105e3e9/ and many more. Signed-off-by: Angelo Compagnucci --- Patch was submitted upstream. ...d.go-explicit-option-for-crosscompilation.patch | 39 ++++++++++++++++++++++ package/go/go.mk | 3 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 package/go/0001-build.go-explicit-option-for-crosscompilation.patch diff --git a/package/go/0001-build.go-explicit-option-for-crosscompilation.patch b/package/go/0001-build.go-explicit-option-for-crosscompilation.patch new file mode 100644 index 0000000..e2f680d --- /dev/null +++ b/package/go/0001-build.go-explicit-option-for-crosscompilation.patch @@ -0,0 +1,39 @@ +From e1382a731a726293e30901038c6870fa77ef6095 Mon Sep 17 00:00:00 2001 +From: Angelo Compagnucci +Date: Tue, 8 May 2018 16:08:44 +0200 +Subject: [PATCH] build.go: explicit option for crosscompilation + +Actually if GOHOSTOS == GOOS || GOHOSTARCH == GOARCH the go build system +assume it's not cross compiling and uses the same toolchain also for the +bootstrap. This is a problem in case the cross compilation mandates a +different toolchain for bootstrap and target. This patch adds +GO_ASSUME_CROSSCOMPILING varible to assure that in case of cross +compilation CC_FOR_TARGET can be different from CC. + +Signed-off-by: Angelo Compagnucci +--- + src/cmd/dist/build.go | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go +index 99d1db5..eb4097f 100644 +--- a/src/cmd/dist/build.go ++++ b/src/cmd/dist/build.go +@@ -252,12 +252,13 @@ func xinit() { + // $CC_FOR_goos_goarch, if set, applies only to goos/goarch. + func compilerEnv(envName, def string) map[string]string { + m := map[string]string{"": def} ++ crosscompiling := os.Getenv("GO_ASSUME_CROSSCOMPILING") + + if env := os.Getenv(envName); env != "" { + m[""] = env + } + if env := os.Getenv(envName + "_FOR_TARGET"); env != "" { +- if gohostos != goos || gohostarch != goarch { ++ if gohostos != goos || gohostarch != goarch || crosscompiling == "1" { + m[gohostos+"/"+gohostarch] = m[""] + } + m[""] = env +-- +2.7.4 + diff --git a/package/go/go.mk b/package/go/go.mk index 4d55e16..6af58f0 100644 --- a/package/go/go.mk +++ b/package/go/go.mk @@ -75,7 +75,8 @@ HOST_GO_MAKE_ENV = \ $(if $(GO_GOARM),GOARM=$(GO_GOARM)) \ GOOS=linux \ CC=$(HOSTCC_NOCCACHE) \ - CXX=$(HOSTCXX_NOCCACHE) + CXX=$(HOSTCXX_NOCCACHE) \ + GO_ASSUME_CROSSCOMPILING=1 HOST_GO_TARGET_CC = \ CC_FOR_TARGET="$(TARGET_CC)" \