From patchwork Wed Mar 4 18:53:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Waugh X-Patchwork-Id: 446378 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 17A0B14016B for ; Thu, 5 Mar 2015 05:53:26 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 93780281611; Wed, 4 Mar 2015 19:53:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id F34142801E6 for ; Wed, 4 Mar 2015 19:52:56 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .bethesignal. - helo: .mail-pa0-f51.google. - helo-domain: .google.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -8.5 Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Wed, 4 Mar 2015 19:52:55 +0100 (CET) Received: by pabrd3 with SMTP id rd3so11744253pab.5 for ; Wed, 04 Mar 2015 10:53:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=TGVYRpZG0gf2vdwqC5oUDmtgZ5Lc5d4Y/VmVjfAyYJk=; b=km1d2DK9FGcq4bwU9yrzwZ4thgu1cvTlkMgKBhXhyVQ/sEhW0QTbS1DotVNociaNVj 9a/FL+KRE+a1wnlOdweRGreJEjinUBOvtHvfNL0Iheq4NkY9vVADfVQndUnXNtv0UCFr kxi4XeUikAcs3QwAIqEM3IKnvmNQh3aS9c+k8xN2NhtfjPyWQPnkHiETLnowUM98vXEO 4jznWdPbSYaRIp5a5UuAo1WbJAj5GoJRA8ml8+dWBglvZWz3IFRomwWMbFiCDF1XM+Zs n31woKes5OJmS2Iy5zYucs68ukcagKgowWHDQ5B1w7HsQV9uU/ksDtHhtg+SPmeyM9l3 F/sA== X-Gm-Message-State: ALoCoQlxseLffLNIFwhuDJc6ayM9Oo1y9JSsX0C3iNaHiEuq2RT5B1D+M0rorliVfvX7utSR2baX X-Received: by 10.70.140.104 with SMTP id rf8mr9014367pdb.89.1425495189610; Wed, 04 Mar 2015 10:53:09 -0800 (PST) Received: from ubuntu (ppp121-44-87-117.lns20.syd4.internode.on.net. [121.44.87.117]) by mx.google.com with ESMTPSA id zd14sm4777944pab.20.2015.03.04.10.53.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 04 Mar 2015 10:53:09 -0800 (PST) Date: Thu, 5 Mar 2015 05:53:02 +1100 From: Jeff Waugh To: openwrt-devel@lists.openwrt.org Message-ID: <20150304185302.GA23180@ubuntu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Subject: [OpenWrt-Devel] [PATCH 1/2] gccgo/libgo toolchain support for OpenWrt X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Hi all, I'm sure there are style weirdnesses with this. Commentary much appreciated! - Jeff - It won't work with uClibc 0.99.33.x because it requires make/get/setcontext - It DOES work with a recent uClibc snapshot (with UCLIBC_HAS_CONTEXT_FUNCS), as well as eglibc - It works with gcc 4.8, and 4.9 with an additional fix submitted separately Only very slightly adapted from Geert-Johan Riemer's work, plus fixes on top. - https://github.com/GeertJohan/openwrt-go/tree/add-gccgo-and-libgo - https://lists.openwrt.org/pipermail/openwrt-devel/2014-January/023214.html Signed-off-by: Jeff Waugh --- package/libs/toolchain/Makefile | 42 ++++++++++++++++++++++ toolchain/gcc/Config.in | 7 ++++ toolchain/gcc/common.mk | 2 +- .../400-libgo-do-not-redefine-CPU_COUNT.patch | 15 ++++++++ .../patches/4.8-linaro/401-go1-needs-libm.patch | 11 ++++++ .../patches/4.9-linaro/401-go1-needs-libm.patch | 11 ++++++ 6 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 toolchain/gcc/patches/4.8-linaro/400-libgo-do-not-redefine-CPU_COUNT.patch create mode 100644 toolchain/gcc/patches/4.8-linaro/401-go1-needs-libm.patch create mode 100644 toolchain/gcc/patches/4.9-linaro/401-go1-needs-libm.patch diff --git a/package/libs/toolchain/Makefile b/package/libs/toolchain/Makefile index 42b9935..2666d5a 100644 --- a/package/libs/toolchain/Makefile +++ b/package/libs/toolchain/Makefile @@ -254,6 +254,34 @@ define Package/libgfortran/config endmenu endef + +define Package/libgo +$(call Package/gcc/Default) + TITLE:=Go support library + DEPENDS+=@INSTALL_GCCGO +endef + +define Package/libgo/config + menu "Configuration" + depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgo + + config LIBGO_ROOT_DIR + string + prompt "libgo shared library base directory" + depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgo + default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN + default "/" if NATIVE_TOOLCHAIN + + config LIBGO_FILE_SPEC + string + prompt "libgo shared library files (use wildcards)" + depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgo + default "./usr/lib/libgo.so.*" + + endmenu +endef + + define Package/ldd $(call Package/libc/Default) DEPENDS:=@!USE_MUSL @@ -410,6 +438,11 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/) endef + define Package/libgo/install + $(INSTALL_DIR) $(1)/usr/lib + $(if $(CONFIG_GCC_VERSION_4_6)$(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgo.so.* $(1)/usr/lib/) + endef + define Package/libssp/install $(INSTALL_DIR) $(1)/lib $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/ @@ -559,6 +592,14 @@ else done endef + define Package/libgo/install + for file in $(call qstrip,$(CONFIG_LIBGO_FILE_SPEC)); do \ + dir=`dirname $$$$file` ; \ + $(INSTALL_DIR) $(1)/$$$$dir ; \ + $(CP) $(call qstrip,$(CONFIG_LIBGO_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \ + done + endef + define Package/libssp/install for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \ dir=`dirname $$$$file` ; \ @@ -642,5 +683,6 @@ $(eval $(call BuildPackage,libpthread)) $(eval $(call BuildPackage,libthread-db)) $(eval $(call BuildPackage,librt)) $(eval $(call BuildPackage,libgfortran)) +$(eval $(call BuildPackage,libgo)) $(eval $(call BuildPackage,ldd)) $(eval $(call BuildPackage,ldconfig)) diff --git a/toolchain/gcc/Config.in b/toolchain/gcc/Config.in index ecd7c26..ec87d32 100644 --- a/toolchain/gcc/Config.in +++ b/toolchain/gcc/Config.in @@ -74,3 +74,10 @@ config INSTALL_GFORTRAN default n help Build/install GNU fortran compiler ? + +config INSTALL_GCCGO + bool + prompt "Build/install gccgo compiler?" if TOOLCHAINOPTS && !(GCC_VERSION_4_4_7 || GCC_VERSION_4_6 || GCC_VERSION_4_6_LINARO) && !UCLIBC_VERSION_0_9_33 + default n + help + Build/install GNU gccgo compiler ? diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk index 925964e..9c01bbd 100644 --- a/toolchain/gcc/common.mk +++ b/toolchain/gcc/common.mk @@ -99,7 +99,7 @@ HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed SEP:=, -TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)" +TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)$(if $(CONFIG_INSTALL_GCCGO),$(SEP)go)" export libgcc_cv_fixed_point=no ifdef CONFIG_USE_UCLIBC diff --git a/toolchain/gcc/patches/4.8-linaro/400-libgo-do-not-redefine-CPU_COUNT.patch b/toolchain/gcc/patches/4.8-linaro/400-libgo-do-not-redefine-CPU_COUNT.patch new file mode 100644 index 0000000..a6ba713 --- /dev/null +++ b/toolchain/gcc/patches/4.8-linaro/400-libgo-do-not-redefine-CPU_COUNT.patch @@ -0,0 +1,15 @@ +https://sourceware.org/ml/crossgcc/2014-09/msg00034.html + +--- a/libgo/runtime/getncpu-linux.c ++++ b/libgo/runtime/getncpu-linux.c +@@ -5,8 +5,8 @@ + #include + #include + +-// CPU_COUNT is only provided by glibc 2.6 or higher +-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6) ++// Define CPU_COUNT if it isn't already. ++#if !defined(CPU_COUNT) + #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int)) + static int _CPU_COUNT(unsigned int *set, size_t len) { + int cnt; diff --git a/toolchain/gcc/patches/4.8-linaro/401-go1-needs-libm.patch b/toolchain/gcc/patches/4.8-linaro/401-go1-needs-libm.patch new file mode 100644 index 0000000..1b92a0a --- /dev/null +++ b/toolchain/gcc/patches/4.8-linaro/401-go1-needs-libm.patch @@ -0,0 +1,11 @@ +--- a/gcc/go/Make-lang.in 2015-03-05 02:40:05.246555190 +1100 ++++ b/gcc/go/Make-lang.in 2015-03-05 02:40:18.414555609 +1100 +@@ -75,7 +75,7 @@ + + go1$(exeext): $(GO_OBJS) attribs.o $(BACKEND) $(LIBDEPS) + +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +- $(GO_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS) ++ $(GO_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS) -lm + + # Documentation. + diff --git a/toolchain/gcc/patches/4.9-linaro/401-go1-needs-libm.patch b/toolchain/gcc/patches/4.9-linaro/401-go1-needs-libm.patch new file mode 100644 index 0000000..1b92a0a --- /dev/null +++ b/toolchain/gcc/patches/4.9-linaro/401-go1-needs-libm.patch @@ -0,0 +1,11 @@ +--- a/gcc/go/Make-lang.in 2015-03-05 02:40:05.246555190 +1100 ++++ b/gcc/go/Make-lang.in 2015-03-05 02:40:18.414555609 +1100 +@@ -75,7 +75,7 @@ + + go1$(exeext): $(GO_OBJS) attribs.o $(BACKEND) $(LIBDEPS) + +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +- $(GO_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS) ++ $(GO_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS) -lm + + # Documentation. +