diff --git a/docs/manual/adding-packages-golang.adoc b/docs/manual/adding-packages-golang.adoc index 3ddbe57afe..aa25426591 100644 --- a/docs/manual/adding-packages-golang.adoc +++ b/docs/manual/adding-packages-golang.adoc @@ -49,7 +49,8 @@ infrastructure should depend on +BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS+ because Buildroot will automatically add a dependency on +host-go+ to such packages. If you need CGO support in your package, you must add a dependency on -+BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS+. ++BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS+; for host packages, +add a dependency on +BR2_PACKAGE_HOST_GO_HOST_CGO_LINKING_SUPPORTS+. The main macro of the Go package infrastructure is +golang-package+. It is similar to the +generic-package+ macro. The diff --git a/package/go/Config.in.host b/package/go/Config.in.host index 11ce6df369..eefca03b02 100644 --- a/package/go/Config.in.host +++ b/package/go/Config.in.host @@ -36,6 +36,18 @@ config BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS default y depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE3_ARCH_SUPPORTS +# CGO linking for the host. Since we use the same compiler for target +# and host, if the target can't do CGO linking, then the host can't. +# But if the target is not supported by Go, then the host can do CGO +# linking (except when it itself does not support CGO linking). +config BR2_PACKAGE_HOST_GO_HOST_CGO_LINKING_SUPPORTS + bool + default y if BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS + default y if !BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS + depends on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS + depends on BR2_HOSTARCH != "mips64" + depends on BR2_HOSTARCH != "mips64el" + # Go packages should select BR2_PACKAGE_HOST_GO config BR2_PACKAGE_HOST_GO bool diff --git a/package/go/go.mk b/package/go/go.mk index 660c7a9bad..7e0dfc5880 100644 --- a/package/go/go.mk +++ b/package/go/go.mk @@ -91,10 +91,11 @@ else HOST_GO_CGO_ENABLED = 0 endif else # !BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS -# If the target arch does not support go, host-go can still be used to build -# packages for the host, and enable cgo. No need to set all the arch stuff -#since we will not be cross-compiling. +ifeq ($(BR2_PACKAGE_HOST_GO_HOST_CGO_LINKING_SUPPORTS),y) HOST_GO_CGO_ENABLED = 1 +else # !BR2_PACKAGE_HOST_GO_HOST_CGO_LINKING_SUPPORTS +HOST_GO_CGO_ENABLED = 0 +endif # BR2_PACKAGE_HOST_GO_HOST_CGO_LINKING_SUPPORTS endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS # Ensure the toolchain is available, whatever the provider HOST_GO_DEPENDENCIES += $(HOST_GO_DEPENDENCIES_CGO)