From patchwork Tue Jul 14 18:42:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Stewart X-Patchwork-Id: 495204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 09CAE140788 for ; Wed, 15 Jul 2015 04:42:27 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id A1AAF33ADC; Tue, 14 Jul 2015 18:42:26 +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 EvcGre-seHYz; Tue, 14 Jul 2015 18:42:15 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 829B02D865; Tue, 14 Jul 2015 18:42:14 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 95DC51C105E for ; Tue, 14 Jul 2015 18:42:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 900F992132 for ; Tue, 14 Jul 2015 18:42:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C5dwMq3PmOwl for ; Tue, 14 Jul 2015 18:42:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by whitealder.osuosl.org (Postfix) with ESMTPS id 747F291E5B for ; Tue, 14 Jul 2015 18:42:12 +0000 (UTC) Received: by pdbep18 with SMTP id ep18so10533464pdb.1 for ; Tue, 14 Jul 2015 11:42:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=C6YIAkeCo7I5cW6xPbK3wjsSGlvL7mjXYi0e2Gh9d00=; b=KlKb/lJ/oGJrx7INg+VSRp1UWAaVKrHfsuJ4KRC8Y1aA4n/mhbJbgyx+e9DebEuqRM xbPJ9fDAO/lUUpw2+ZkkcbrhUMwOFZm88NvsyI3i8zW8H0bD/Dr6rgSYmvKw4TomnGEo syfFfgYEnR6Vrw4nHJU999w8wniFoFIYx0PaL6jNRsPeMj1zv1GM/Tdm1Qi95iPv4MYh +XJKr/z30flaiM38I1Bm1Cg3eTZgaDBUVdx3gqI/LR8E6jYmH6SknkdJwsg+/pjhBc0s gccWw86EbleVxMiqcArPlaiimzEn6U9lfnq3JYffnU4SahRPRtF7xvrQPpm0voUrfERM INLg== X-Gm-Message-State: ALoCoQk0oBoX/17cXRr8EEP1ND17bwz9CYm9kyljx9yTZaw1RHwjv4ZGxfOSdBDLSkNfgovZQYn9 X-Received: by 10.70.88.80 with SMTP id be16mr4643pdb.37.1436899332214; Tue, 14 Jul 2015 11:42:12 -0700 (PDT) Received: from localhost.localdomain ([64.145.76.195]) by smtp.gmail.com with ESMTPSA id uk6sm2108381pac.27.2015.07.14.11.42.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Jul 2015 11:42:10 -0700 (PDT) From: Christian Stewart To: buildroot@busybox.net Date: Tue, 14 Jul 2015 11:42:00 -0700 Message-Id: <1436899322-19731-1-git-send-email-christian@paral.in> X-Mailer: git-send-email 2.1.4 Cc: Christian Stewart Subject: [Buildroot] [PATCH 1/3] golang: new package X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This patch introduces golang as a host and target package, allowing for cross-platform go builds. Signed-off-by: Christian Stewart --- package/Config.in | 1 + package/Config.in.host | 1 + package/golang/0001-add-no-march-option-gccp.patch | 19 ++++++++++ .../0002-remove-unnecessary-march-ld-flag.patch | 29 ++++++++++++++++ package/golang/Config.in | 6 ++++ package/golang/Config.in.host | 6 ++++ package/golang/golang.mk | 40 ++++++++++++++++++++++ 7 files changed, 102 insertions(+) create mode 100644 package/golang/0001-add-no-march-option-gccp.patch create mode 100644 package/golang/0002-remove-unnecessary-march-ld-flag.patch create mode 100644 package/golang/Config.in create mode 100644 package/golang/Config.in.host create mode 100644 package/golang/golang.mk diff --git a/package/Config.in b/package/Config.in index 5beb450..b49c94f 100644 --- a/package/Config.in +++ b/package/Config.in @@ -455,6 +455,7 @@ menu "Erlang libraries/modules" source "package/erlang-p1-zlib/Config.in" endmenu endif + source "package/golang/Config.in" source "package/guile/Config.in" source "package/haserl/Config.in" source "package/jamvm/Config.in" diff --git a/package/Config.in.host b/package/Config.in.host index 1e047aa..e36afee 100644 --- a/package/Config.in.host +++ b/package/Config.in.host @@ -11,6 +11,7 @@ menu "Host utilities" source "package/genext2fs/Config.in.host" source "package/genimage/Config.in.host" source "package/genpart/Config.in.host" + source "package/golang/Config.in.host" source "package/imx-usb-loader/Config.in.host" source "package/lpc3250loader/Config.in.host" source "package/mke2img/Config.in.host" diff --git a/package/golang/0001-add-no-march-option-gccp.patch b/package/golang/0001-add-no-march-option-gccp.patch new file mode 100644 index 0000000..87231aa --- /dev/null +++ b/package/golang/0001-add-no-march-option-gccp.patch @@ -0,0 +1,19 @@ +Adds an option to not add the problematic -m parameter to GCC. + +Signed-off-by: Christian Stewart + +diff -Nau golang.orig/src/cmd/cgo/gcc.go golang/src/cmd/cgo/gcc.go +--- golang.orig/src/cmd/cgo/gcc.go.orig 2015-07-09 15:53:55.720794139 -0700 ++++ golang/src/cmd/cgo/gcc.go 2015-07-09 17:46:43.664496374 -0700 +@@ -736,6 +736,11 @@ + + // gccMachine returns the gcc -m flag to use, either "-m32", "-m64" or "-marm". + func (p *Package) gccMachine() []string { ++ ++ if os.Getenv("CGO_NO_EMULATION") == "1" { ++ return nil ++ } ++ + switch goarch { + case "amd64": + return []string{"-m64"} diff --git a/package/golang/0002-remove-unnecessary-march-ld-flag.patch b/package/golang/0002-remove-unnecessary-march-ld-flag.patch new file mode 100644 index 0000000..7cc20f4 --- /dev/null +++ b/package/golang/0002-remove-unnecessary-march-ld-flag.patch @@ -0,0 +1,29 @@ +Removes defining -m parameter to LD, which is unnecessary in buildroot. + +Signed-off-by: Christian Stewart + +diff -Nau golang.orig/src/cmd/ld/lib.c golang/src/cmd/ld/lib.c +--- golang.orig/src/cmd/ld/lib.c.orig 2015-07-09 18:38:44.192359082 -0700 ++++ golang/src/cmd/ld/lib.c 2015-07-09 18:39:02.108358294 -0700 +@@ -589,20 +589,7 @@ + if(extld == nil) + extld = "gcc"; + argv[argc++] = extld; +- switch(thechar){ +- case '8': +- argv[argc++] = "-m32"; +- break; +- case '6': +- argv[argc++] = "-m64"; +- break; +- case '5': +- argv[argc++] = "-marm"; +- break; +- } +- if(!debug['s'] && !debug_s) { +- argv[argc++] = "-gdwarf-2"; +- } else { ++ if(debug['s'] || debug_s) { + argv[argc++] = "-s"; + } + if(HEADTYPE == Hdarwin) diff --git a/package/golang/Config.in b/package/golang/Config.in new file mode 100644 index 0000000..5f058c6 --- /dev/null +++ b/package/golang/Config.in @@ -0,0 +1,6 @@ +config BR2_PACKAGE_GOLANG + bool "golang" + help + Go compiler and cli tool. + + http://golang.org/ diff --git a/package/golang/Config.in.host b/package/golang/Config.in.host new file mode 100644 index 0000000..5d556bb --- /dev/null +++ b/package/golang/Config.in.host @@ -0,0 +1,6 @@ +config BR2_PACKAGE_HOST_GOLANG + bool "host golang" + help + Go compiler for the host system. + + http://golang.org/ diff --git a/package/golang/golang.mk b/package/golang/golang.mk new file mode 100644 index 0000000..4893bcc --- /dev/null +++ b/package/golang/golang.mk @@ -0,0 +1,40 @@ +################################################################################ +# +# GOLANG +# +################################################################################ + +GOLANG_VERSION = 883bc6ed0ea815293fe6309d66f967ea60630e87 +GOLANG_SITE = $(call github,golang,go,$(GOLANG_VERSION)) +GOLANG_LICENSE_FILES = LICENSE +GOLANG_INSTALL_STAGING = NO +GOLANG_INSTALL_TARGET = YES + +HOST_GOLANG_DEPENDENCIES = +GOLANG_DEPENDENCIES = + +GOLANG = $(HOST_DIR)/usr/bin/go +GOLANGFMT = $(HOST_DIR)/usr/bin/gofmt + +define GOLANG_BUILD_CMDS + cd $(@D)/src/ && CC_FOR_TARGET="$(TARGET_CC)" LD_FOR_TARGET="$(TARGET_LD)" GOOS=linux GOARCH=$(ARCH) GOROOT_FINAL="/usr/src/go" ./make.bash +endef + +define GOLANG_INSTALL_TARGET_CMDS + cp $(@D)/bin/linux_$(ARCH)/* $(TARGET_DIR)/usr/bin/ + mkdir -p $(TARGET_DIR)/usr/src/go/ + cp -r $(@D)/* $(TARGET_DIR)/usr/src/go/ +endef + +define HOST_GOLANG_BUILD_CMDS + cd $(@D)/src/ && CC_FOR_TARGET="$(TARGET_CC)" GOOS=linux GOARCH=$(ARCH) GOROOT_FINAL=$(HOST_DIR)/usr/src/go/ bash ./make.bash +endef + +define HOST_GOLANG_INSTALL_CMDS + cp $(@D)/bin/go $(@D)/bin/gofmt $(HOST_DIR)/usr/bin/ + mkdir -p $(HOST_DIR)/usr/src/go/ + cp -r $(@D)/* $(HOST_DIR)/usr/src/go/ +endef + +$(eval $(host-generic-package)) +$(eval $(generic-package))