2
1
Эх сурвалжийг харах

package/go: disable cgo support with static libs

The go stdlib "plugin" package relies on dlfcn.h which isn't available
when we have BR2_STATIC_LIBS=y.

Concentrate all cgo decision (including the existing threads part)
under the config option BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
that has the proper depends.

This should fix this build error from autobuilders:

/buildroot/build/host-go-1.19.3/src/plugin/plugin_dlopen.go:11:10: fatal error: dlfcn.h: No such file or directory
   11 | #include <dlfcn.h>

Fixes:
  http://autobuild.buildroot.net/results/1f4/1f4b9882986b9df723a1446493d270c29287b505
  http://autobuild.buildroot.net/results/a9d/a9de62374c948f773634c694a47abcaa2bc266d0

Signed-off-by: Anisse Astier <anisse@astier.eu>
Reviewed-by: Christian Stewart <christian@paral.in>
[Arnout: revert parts to v2, keeping most of the overall logic as it
was]
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
Anisse Astier 2 жил өмнө
parent
commit
079f5ccdca

+ 4 - 0
package/go/Config.in.host

@@ -25,6 +25,10 @@ config BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
 	# Go doesn't support CGO linking on MIPS64x platforms
 	# See: https://github.com/karalabe/xgo/issues/46
 	depends on !BR2_mips64 && !BR2_mips64el
+	# go uses dlfcn.h + cgo for its plugin module
+	depends on !BR2_STATIC_LIBS
+	# cgo supports uses threads
+	depends on BR2_TOOLCHAIN_HAS_THREADS
 
 # Host go packages should depend on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS
 config BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS

+ 10 - 9
package/go/go.mk

@@ -78,23 +78,24 @@ HOST_GO_TARGET_ENV = \
 	CGO_LDFLAGS="$(TARGET_LDFLAGS)" \
 	GOTOOLDIR="$(HOST_GO_TOOLDIR)"
 
-# The go compiler's cgo support uses threads.  If BR2_TOOLCHAIN_HAS_THREADS is
-# set, build in cgo support for any go programs that may need it.  Note that
-# any target package needing cgo support must include
-# 'depends on BR2_TOOLCHAIN_HAS_THREADS' in its config file.
-ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+# Allow packages to use cgo support if it is available for the target. They
+# will need the toolchain for cgo support; for convenence, include that
+# dependency here.
+#
+# Note that any target package needing cgo support must include 'depends on
+# BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS' in its config file.
+ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS),y)
 HOST_GO_DEPENDENCIES_CGO += toolchain
 HOST_GO_CGO_ENABLED = 1
 else
 HOST_GO_CGO_ENABLED = 0
 endif
-
 else # !BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
-# host-go can still be used to build packages for the host. No need to set all
-# the arch stuff since we will not be cross-compiling.
+# 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.
 HOST_GO_CGO_ENABLED = 1
 endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
-
 # Ensure the toolchain is available, whatever the provider
 HOST_GO_DEPENDENCIES += $(HOST_GO_DEPENDENCIES_CGO)