Message ID | 20150304185302.GA23180@ubuntu |
---|---|
State | Changes Requested |
Headers | show |
Hello Jeff, It's a bit of a shame it doesn't work with the current default uclibc, however have you checked if it works with musl out of the box? That being the other more embedded-friendly solution here. Cheers, Steven
On Thu, Mar 5, 2015 at 8:42 PM, Steven Barth <cyrus@openwrt.org> wrote: > It's a bit of a shame it doesn't work with the current default uclibc, > however have you checked if it works with musl out of the box? That being > the other more embedded-friendly solution here. > Looks like libgo in gcc 4.8 has some fresh redefinition problems with musl. In this case, ethhdr and sysinfo structs included from both musl and linux headers. I'll try with gcc 4.9, and add some exclusions to kconfig if it makes sense. By the way, I realised the gcc 4.8 patch was a copy of the 4.9 patch in my last submission, so I've fixed that in my repo. Should I submit again to the list, or will it be merged from git anyway?) Thanks, Jeff
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@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. > + >
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. +
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@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 ++++++ .../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