[OpenWrt-Devel] [PATCH 1/2] gccgo/libgo toolchain support for OpenWrt

John Crispin blogic at openwrt.org
Tue Mar 17 04:13:11 EDT 2015


Hi,

comment inline

On 04/03/2015 19:53, Jeff Waugh wrote:
> 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 <jdub at bethesignal.org>
> ---
>  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 ++++++

this patch causes a build error when building gcc 4.8 as it does not apply.

	John


>  .../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 <features.h>
> + #include <sched.h>
> + 
> +-// 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.
> + 
> 
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list