From 079f5ccdca2e65e21d64a50b7badaa57c04d91dc Mon Sep 17 00:00:00 2001 From: Anisse Astier Date: Sun, 27 Nov 2022 17:45:33 +0100 Subject: [PATCH] package/go: disable cgo support with static libs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Fixes: http://autobuild.buildroot.net/results/1f4/1f4b9882986b9df723a1446493d270c29287b505 http://autobuild.buildroot.net/results/a9d/a9de62374c948f773634c694a47abcaa2bc266d0 Signed-off-by: Anisse Astier Reviewed-by: Christian Stewart [Arnout: revert parts to v2, keeping most of the overall logic as it was] Signed-off-by: Arnout Vandecappelle --- package/go/Config.in.host | 4 ++++ package/go/go.mk | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/package/go/Config.in.host b/package/go/Config.in.host index 92c1f4cdc3..11ce6df369 100644 --- a/package/go/Config.in.host +++ b/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 diff --git a/package/go/go.mk b/package/go/go.mk index bfbe997911..660c7a9bad 100644 --- a/package/go/go.mk +++ b/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)