From patchwork Fri Apr 12 12:30:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 162110 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp571637jan; Fri, 12 Apr 2019 05:31:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNaRfWkduLGqbAsCbudv2uwIVyj8ZCq3V1JBTZ+jKTpficiIhomEF3+TqOuZRGC4fTtd2K X-Received: by 2002:a17:902:f094:: with SMTP id go20mr56669720plb.159.1555072268326; Fri, 12 Apr 2019 05:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555072268; cv=none; d=google.com; s=arc-20160816; b=zFjpK6AJ57YCrlGtB/uSbIuOE8QHohPqPT/kuf9uO49AqjyPPauqMZGge/suI42THd kxoP69Aw9aqnv/pMJYKtj1JJkG754sRilgUvcaSr78MYrotjznZMYBHhdslmMtC2+LQX SxEYXpNFu/op3Pg4idCIu7GfoTT2s/ou+f9n1AGAdf3EDlqdJPSj/rt3J1Ym1E4SOAQG g4jpmAel2gJcY9SjgwpBRq+mTwahViyK6YflqTbnvBy9HmrQJD97e5HnHdeZ5C7lJho6 11azPWi9brQDSFDD/MOl6iIKpYSEBHsMrvhIVBZ8BdrbR2wKHwRJQ8puPj4mb3uBaDOK wRfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from:dkim-signature:delivered-to; bh=rpQ33al/ithBXIKrAjhzOdP7MoIEHFuJl4nr3yr2x4Q=; b=lqJKddBclhARXqYfa16QRerV+uqSsBMyDNMZeOagcpjFHpqXVipBTMhMdAt2kYjM6C QocqRrD6xelQ/yJgIpoHJhFt0UNvpA+eXwXtV7cKSN1DbDn1fbbWVLfSFqBgmeN5OpUL AtIKus0BrA2tK1nynUIlwTRexSDCGLPeY2dzleztimqmRSnsaVVAjMHAKA4qSSzrnBeN KDtIkDdQ5dVsLWfU6gOC64i2PrwA0mfVYYT24737YjuSRxfrbSjcdIDhk1BySrVxOCl2 zo4e8AaETL9s94Qb/NuQCt09oBSUNxTftxYw44d69WBqFJFfBMaRBHSQab3wQ4fY1shJ Zl1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Xd5g2hSD; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id d9si34759112plr.253.2019.04.12.05.31.07; Fri, 12 Apr 2019 05:31:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Xd5g2hSD; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from ec2-34-214-78-129.us-west-2.compute.amazonaws.com (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id 5E6377DBB5; Fri, 12 Apr 2019 12:31:04 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mail.openembedded.org (Postfix) with ESMTP id DBD6E7D720 for ; Fri, 12 Apr 2019 12:31:01 +0000 (UTC) Received: by mail-wr1-f50.google.com with SMTP id w1so11719463wrp.2 for ; Fri, 12 Apr 2019 05:31:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=X2iu+9y6/U89dym76q7HQ2EJ0/9NT7NVjCPPhrYFZNo=; b=Xd5g2hSDB2RTlI0GgZDhN82zFhuwxleWuZt3QIPP/MUbkrErCQQdDhmJ+Q58G8IOwl 2EisTizI+K11PxtAwmlaXs+FJeHb/z8bpHTr15YaGCdDsrQkN4xSoH9jLUpdEneAdP54 DNDyugR5+HeTJHIOqTcyWLS9/xmAUg093gK8RS65i51KMlbG8xwj2pPDSFW2nJ+yPe4o 10fOESmyaFisSUQEjArp3S7nQD1IhXHhJnpq2xoFjUn0zLXBxWck4BtL+4k9WBIqcH6e 4axr/q3MMaJX6JfL9tDZPqwjLOHDRY1ldVPhf8EX6Ad4ulDkJgBcOHbfl9vd3WWaJk43 v4gw== 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:mime-version :content-transfer-encoding; bh=X2iu+9y6/U89dym76q7HQ2EJ0/9NT7NVjCPPhrYFZNo=; b=e7WcWkyBnV895DhFxAhhrcXHLW8s8dM6Em9S6DOzorLdQmPsdnYugn20Dr6FqYowif kqryZUeP+6pX5DR9wSrGWV1vhI3LYnIkHBRH/CfSrSJq6Z1H1mg9eDejJUGXwBuxna0/ uB/9xRznz9AuOi82AjMsyTrPq58cuXsqM1Zf7UDPVij/G+c3szpDW753jkk8jWv1m8hA UbP2mo0KMzNE09VWJCCL1hR6Iuxuyx85PjIc9n3+TmzP1pLP1aUhTZxLf0RVAB7AU7Ig Edv625zmY5o81INoIHb82spxTMPNNj8BbS3FPGH3vU4vcdyFm1aCzk27jwDolw3GXI9K otRw== X-Gm-Message-State: APjAAAXUU+ebrK0oKL+gMoLQi3WmogSvom+pv1GUsqAdByYcPz1Mlwot RcM4OhIKR6lmEd/c8aOnKZRd8efLz2BBGA== X-Received: by 2002:a05:6000:14a:: with SMTP id r10mr15708797wrx.107.1555072262283; Fri, 12 Apr 2019 05:31:02 -0700 (PDT) Received: from oak.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id 13sm10610126wmf.23.2019.04.12.05.31.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 05:31:01 -0700 (PDT) From: Daniel Thompson To: openembedded-core@lists.openembedded.org Date: Fri, 12 Apr 2019 13:30:46 +0100 Message-Id: <20190412123046.17510-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [OE-core] [PATCH] go: Allow bootstrapping using host go compiler X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org Currently go-native bootstraps without any dependency on the host go compiler by building go-1.4 (the last version written in C) and using that to build a more recent version of go. This does not work on host architectures, such as arm64, that are not supported by go-1.4. To support these host architectures we must rely on an existing host go compiler and use that to build go-native instead. Rather than add arm64 specific code that forces the use of the host go compiler, we use an architecture neutral approach based on adopting the host go compiler if it is both recent enough and the output of `go env GOROOT` passes basic sanity testing. Signed-off-by: Daniel Thompson --- meta/conf/bitbake.conf | 4 +++ meta/recipes-devtools/go/go-native.inc | 38 ++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) -- 2.20.1 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index 7f8b043cc4..61a3069579 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -514,6 +514,10 @@ HOSTTOOLS_NONFATAL += "bzr" # Used by ssh fetcher HOSTTOOLS_NONFATAL += "scp" +# Used to bootstrap go more quickly (and to support host architectures not +# supported by go-1.4) +HOSTTOOLS_NONFATAL += "go" + CCACHE ??= "" TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_TARGET}" diff --git a/meta/recipes-devtools/go/go-native.inc b/meta/recipes-devtools/go/go-native.inc index 207708745e..adf1666e29 100644 --- a/meta/recipes-devtools/go/go-native.inc +++ b/meta/recipes-devtools/go/go-native.inc @@ -10,14 +10,46 @@ CC = "${@d.getVar('BUILD_CC').strip()}" GOMAKEARGS ?= "--no-banner" +check_host_go () { + local GOROOT="`go env GOROOT`" + if [ ! -x "$GOROOT/bin/go" ] + then + return 1 + fi + + local GOVERSION=`$GOROOT/bin/go version | tr ' ' '\n' | grep ^go[0-9] | cut -b3-` + local GOMAJOR=`echo $GOVERSION | cut -d. -f 1` + local GOMINOR=`echo $GOVERSION | cut -d. -f 2` + if [ "`echo $GOMAJOR.$GOMINOR | tr -d 0-9`" != "." ] || \ + [ "$GOMAJOR" -lt 1 ] || \ + [ "$GOMAJOR" -eq 1 -a "$GOMINOR" -lt 4 ] + then + return 1 + fi + + return 0 +} + do_configure() { - cd ${WORKDIR}/go1.4/go/src - CGO_ENABLED=0 GOROOT=${WORKDIR}/go1.4/go ./make.bash + if check_host_go + then + bbplain "Bootstrap using host go compiler: `go env GOROOT`" + else + cd ${WORKDIR}/go1.4/go/src + CGO_ENABLED=0 GOROOT=${WORKDIR}/go1.4/go ./make.bash + fi } +do_configure[cleandirs] =+ "${GOTMPDIR}" do_compile() { export GOROOT_FINAL="${libdir_native}/go" - export GOROOT_BOOTSTRAP="${WORKDIR}/go1.4/go" + + if check_host_go + then + export GOROOT_BOOTSTRAP="`go env GOROOT`" + else + export GOROOT_BOOTSTRAP="${WORKDIR}/go1.4/go" + fi cd src ./make.bash ${GOMAKEARGS}