From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 8/9] package/go: Build special host binaries
Date: Thu, 12 May 2016 16:34:18 +0200 [thread overview]
Message-ID: <20160512163418.6382e3d2@free-electrons.com> (raw)
In-Reply-To: <5bc0cf8e34e53eee49c11c7b4fc9b523530ad393.1463010772.git.geoff@infradead.org>
Hello,
On Thu, 12 May 2016 00:08:48 +0000, Geoff Levand wrote:
> To work around cross compile limitations of go's build scripts, when the
> host and target arches are the same build the host go binaries with
> CC_FOR_TARGET set to the host compiler.
What happens when the host and target architectures are different? It
all works fine?
Is the problem just that Go doesn't "cross compile" properly when the
host and target architectures are the same ?
> +# To work around cross compile limitations of go's build scripts, when the
Please give more details about those "limitations".
> +# host and target arches are the same build the host go binaries with
> +# CC_FOR_TARGET set to the host compiler.
> +ifeq ($(ARCH),$(HOSTARCH))
> + HOST_GO_BUILD_SPECIAL = y
Don't indent this line.
> +endif
> +
> +HOST_GO_ENV_COMMON = \
> GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_ROOT) \
> GOROOT_FINAL=$(HOST_GO_ROOT) \
> - GOROOT="$(@D)" \
> GOBIN="$(@D)/bin" \
> GOARCH=$(GO_GOARCH) \
> $(if $(GO_GOARM),GOARM=$(GO_GOARM)) \
> GOOS=linux \
> CGO_ENABLED=1 \
> + CC=$(HOSTCC_NOCCACHE)
This addition seems unrelated to the patch. And why are you using
HOSTCC_NOCCACHE and not just HOSTCC ?
> +
> +HOST_GO_MAKE_ENV = \
> + $(HOST_GO_ENV_COMMON) \
> + GOROOT="$(@D)" \
> CC_FOR_TARGET=$(TARGET_CC) \
> CXX_FOR_TARGET=$(TARGET_CXX)
>
> +HOST_GO_MAKE_ENV_SPECIAL = \
> + $(HOST_GO_ENV_COMMON) \
> + GOROOT="$(@D).host" \
> + CC_FOR_TARGET=$(HOSTCC_NOCCACHE) \
> + CXX_FOR_TARGET=$(HOSTCC_NOCCACHE) \
Please no final backslash on the last line.
> +define HOST_GO_CONFIGURE_CMDS
> + if [ "$(HOST_GO_BUILD_SPECIAL)" ]; then \
> + cp -a $(@D) $(@D).host; \
> + fi
> +endef
Please use make conditionals, i.e:
ifeq ($(HOST_GO_BUILD_SPECIAL),y)
define HOST_GO_CONFIGURE_CMDS
cp -a $(@D) $(@D).host
endef
endif
> +
> define HOST_GO_BUILD_CMDS
> cd $(@D)/src && $(HOST_GO_MAKE_ENV) ./make.bash
You really need a different set of environment variables for here?
> + if [ "$(HOST_GO_BUILD_SPECIAL)" ]; then \
> + rm -f $(@D)/bin/go $(@D)/bin/gofmt; \
> + cd $(@D).host/src && $(HOST_GO_MAKE_ENV_SPECIAL) ./make.bash; \
And here ?
Also, same here: use make conditionals, i.e:
ifeq ($(HOST_GO_BUILD_SPECIAL),y)
define HOST_GO_BUILD_SPECIAL_CMDS
...
endef
endif
define HOST_GO_BUILD_CMDS
.... build go normally ...
$(HOST_GO_BUILD_SPECIAL_CMDS)
endef
> + fi
> endef
>
> define HOST_GO_INSTALL_CMDS
> @@ -66,7 +93,8 @@ define HOST_GO_INSTALL_CMDS
> cp -a $(@D)/lib $(HOST_GO_ROOT)/
>
> mkdir -p $(HOST_GO_ROOT)/pkg
> - cp -a $(@D)/pkg/include $(@D)/pkg/linux_* $(HOST_GO_ROOT)/pkg/
> + cp -a $(@D)/pkg/include $(HOST_GO_ROOT)/pkg/
> + cp -a $(@D)/pkg/linux_* $(HOST_GO_ROOT)/pkg/
This change seems useless and unrelated.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
next prev parent reply other threads:[~2016-05-12 14:34 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-12 0:08 [Buildroot] [PATCH 0/9] Fixes for go language support Geoff Levand
2016-05-12 0:08 ` [Buildroot] [PATCH 4/9] package/go: Add BR2_TOOLCHAIN_HAS_THREADS Geoff Levand
2016-05-12 13:30 ` Thomas Petazzoni
2016-05-12 14:12 ` Thomas Petazzoni
2016-05-12 18:32 ` Geoff Levand
2016-05-13 13:35 ` Thomas Petazzoni
2016-05-13 16:21 ` Geoff Levand
2016-05-12 0:08 ` [Buildroot] [PATCH 1/9] package/go-bootstrap: Add toolchain dependency Geoff Levand
2016-05-12 14:11 ` Thomas Petazzoni
2016-05-12 0:08 ` [Buildroot] [PATCH 3/9] package/go-bootstrap: Set CC to host CC Geoff Levand
2016-05-12 13:28 ` Thomas Petazzoni
2016-05-12 16:53 ` Geoff Levand
2016-05-13 13:30 ` Thomas Petazzoni
2016-05-12 0:08 ` [Buildroot] [PATCH 2/9] package/go-bootstrap: Set CGO_ENABLED=0 Geoff Levand
2016-05-12 14:11 ` Thomas Petazzoni
2016-05-13 11:56 ` Peter Korsgaard
2016-05-13 16:05 ` Geoff Levand
2016-05-13 17:12 ` Peter Korsgaard
2016-05-13 18:40 ` Geoff Levand
2016-05-12 0:08 ` [Buildroot] [PATCH 5/9] package/go: Fix powerpc64 config typo Geoff Levand
2016-05-12 14:26 ` Thomas Petazzoni
2016-05-12 0:08 ` [Buildroot] [PATCH 6/9] package/go: Enable MIPS support Geoff Levand
2016-05-12 0:08 ` [Buildroot] [PATCH 7/9] package/go: Add HOST_GO_TOOLDIR Geoff Levand
2016-05-12 0:08 ` [Buildroot] [PATCH 8/9] package/go: Build special host binaries Geoff Levand
2016-05-12 14:34 ` Thomas Petazzoni [this message]
2016-05-12 17:12 ` Geoff Levand
2016-05-12 0:08 ` [Buildroot] [PATCH 9/9] package/flannel: Set go env variables Geoff Levand
2016-05-12 0:15 ` [Buildroot] [PATCH 0/9] Fixes for go language support Christian Stewart
2016-05-12 14:29 ` Thomas Petazzoni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160512163418.6382e3d2@free-electrons.com \
--to=thomas.petazzoni@free-electrons.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox