mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-08 08:30:47 -09:00
package/go: expose host CGO linking support
Even when configured for cross-compilation, the go compiler is always able to build natively as well, and this is was we use in Buildroot to build host go packages. This implies that when the target has limitations, those limitations thus also apply to the host builds. This means that, when there is no CGO linking support for the target, the compiler is built without CGO linking support, and thus CGO linking is also not available for the host builds. Of course, when there is no go support for the target, the CGO linking support only depends on the host architecture. Add a new Kconfig symbol that repesent whether CGO linking is available for the host; host packages can then depend on that symbol, like the target variants do on the corresponding target symbol. The dependencies of this symbol are a bit complicated. Fortunately, because it is a blind symbol, we can write it with a combination of "default y" and "depends on" statements. As mentioned, CGO for the host is available if CGO is available for the target, but also if Go is not available for the target at all. In addition, Go must of course be available for the host. There are also the toolchain constraints of CGO. We exclude MIPS64 explicitly based on BR2_HOSTARCH. For the host, we always assume that dynamic library and threads are available so we don't have conditions for that. Signed-off-by: Yann E. MORIN <yann.morin@orange.com> Cc: Thomas Perale <thomas.perale@mind.be> Cc: Christian Stewart <christian@aperture.us> Cc: Anisse Astier <anisse@astier.eu> Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
This commit is contained in:
committed by
Arnout Vandecappelle
parent
2c222c2968
commit
6016dad5cf
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user