Hi,

Thanks for your reponse, Luka.

I've added the depend statements as you said. This does work, but completely removes the entry's instead of greying them out. Someone searching for gccgo/libgo must now know it is required to enable gcc 4.7.x+ and eglibc before gccgo/libgo appears. Isn't there a better way to do it?

I've attached what I have so far.

Best regards,
Geert-Johan Riemer

On Tue, 7 Jan 2014, Luka Perkov wrote:

Hi Geert-Johan,

On Tue, Jan 07, 2014 at 11:13:50AM +0100, Geert-Johan Riemer wrote:
I'm working on adding Go (http://golang.org) to OpenWRT. Actually, I already
have it working.

Great!

The goals:
 - Create gcc crosscompiler with the gccgo frontend which can be used to
compile a go project into a binary.
 - Build and include libgo.so in the target image. libgo.so is the only
run-time requirement for binaries built with gccgo. ("go packages" that
are included in the project are compiled into the binary, afaik there's no
need for a packages feed providing go libs)

To achieve these I've added some directives in the OpenWRT makefiles an
menu config.
https://github.com/GeertJohan/openwrt-go/commit/ac3ad0dc738ed94bed82723b486566b23ea491d1

This all works fine, and I have go binaries running on the MikroTIK 750GL.
However, I would like to add/fix a two problems before I create and submit a
patch.

GCC version
The gccgo frontend is only available in gcc 4.7.x (or higher). What would
be the proper way to force the user to use gcc 4.7.x (or higher) when
building with gccgo?
Can the "Build/install gccgo compiler?" option be greyed out until the
proper version of gcc is selected?

Not sure if this will work but please try:

DEPENDS:=@GCC_VERSION_4_8

I've picked that one from toolchain/gcc/Config.version.

libgo.so depends on eglibc
I have the same "dependency" problem with libgo.so, it requires eglibc. The
default is uclibc. What would be the proper way to notify the user?

Try adding @USE_EGLIBC in DEPENDS variable.

I don't want people having to figure out why their build fails when it can
be avoided.

Any thoughts on how to do this?
Do you see anything else that might need attention before submitting a
patch?

Please send your patch so we can test it and comment...

Luka
diff --git a/package/libs/toolchain/Makefile b/package/libs/toolchain/Makefile
index 202e9d0..74a4e2c 100644
--- a/package/libs/toolchain/Makefile
+++ b/package/libs/toolchain/Makefile
@@ -228,6 +228,35 @@ define Package/libgfortran/config
 	endmenu
 endef
 
+
+define Package/libgo
+$(call Package/gcc/Default)
+  TITLE:=Go support library
+  DEPENDS+=@INSTALL_GCCGO
+  DEPENDS+=@USE_EGLIBC
+endef
+
+define Package/libgo/config
+       menu "Configuration"
+               depends EXTERNAL_TOOLCHAIN && PACKAGE_libgo
+
+       config LIBGO_ROOT_DIR
+               string
+               prompt "libgo shared library base directory"
+               depends 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 EXTERNAL_TOOLCHAIN && PACKAGE_libgo
+               default "./usr/lib/libgo.so.*"
+
+       endmenu
+endef
+
+
 define Package/ldd
 $(call Package/libc/Default)
   DEPENDS:=@!USE_MUSL
@@ -372,11 +401,24 @@ 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_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/
   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/libstdcpp/install
 	$(INSTALL_DIR) $(1)/usr/lib
 	$(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
@@ -591,5 +633,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 737164a..0568e70 100644
--- a/toolchain/gcc/Config.in
+++ b/toolchain/gcc/Config.in
@@ -73,3 +73,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_8_0 || GCC_VERSION_4_8_LINARO)
+	default n
+	help
+	    Build/install GNU gccgo compiler ?
\ No newline at end of file
diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk
index ebfcfc1..c7b04c6 100644
--- a/toolchain/gcc/common.mk
+++ b/toolchain/gcc/common.mk
@@ -86,7 +86,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

Attachment: add-gccgo-and-libgo.patch.sig
Description: PGP signature

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to