diff mbox series

[v2] package/go: disable cgo support with static libs

Message ID 20221121224955.951056-1-anisse@astier.eu
State Superseded
Headers show
Series [v2] package/go: disable cgo support with static libs | expand

Commit Message

Anisse Astier Nov. 21, 2022, 10:49 p.m. UTC
The go stdlib "plugin" package relies on dlfcn.h which isn't available
when we have BR2_STATIC_LIBS=y.

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>

Signed-off-by: Anisse Astier <anisse@astier.eu>
---
 package/go/Config.in.host | 1 +
 package/go/go.mk          | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

Comments

Christian Stewart Nov. 22, 2022, 6:36 a.m. UTC | #1
Reviewed-by: Christian Stewart <christian@paral.in>

Thanks!


On Mon, Nov 21, 2022, 2:50 PM Anisse Astier <anisse@astier.eu> wrote:

> The go stdlib "plugin" package relies on dlfcn.h which isn't available
> when we have BR2_STATIC_LIBS=y.
>
> 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>
>
> Signed-off-by: Anisse Astier <anisse@astier.eu>
> ---
>  package/go/Config.in.host | 1 +
>  package/go/go.mk          | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/package/go/Config.in.host b/package/go/Config.in.host
> index ded02d3b3a..9e79a7dfd5 100644
> --- a/package/go/Config.in.host
> +++ b/package/go/Config.in.host
> @@ -23,6 +23,7 @@ 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
> +       depends on !BR2_STATIC_LIBS
>
>  # 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 fd4caa2e5a..d54be8cd78 100644
> --- a/package/go/go.mk
> +++ b/package/go/go.mk
> @@ -87,7 +87,7 @@ HOST_GO_TARGET_ENV = \
>  # 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)
> +ifeq ($(BR2_TOOLCHAIN_HAS_THREADS):$(BR2_STATIC_LIBS),y:)
>  HOST_GO_CGO_ENABLED = 1
>  else
>  HOST_GO_CGO_ENABLED = 0
> --
> 2.38.1
>
>
Yann E. MORIN Nov. 22, 2022, 5:21 p.m. UTC | #2
Anisse, All,

On 2022-11-21 23:49 +0100, Anisse Astier spake thusly:
> The go stdlib "plugin" package relies on dlfcn.h which isn't available
> when we have BR2_STATIC_LIBS=y.
> 
> 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>
> 
> Signed-off-by: Anisse Astier <anisse@astier.eu>
> ---
>  package/go/Config.in.host | 1 +
>  package/go/go.mk          | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/package/go/Config.in.host b/package/go/Config.in.host
> index ded02d3b3a..9e79a7dfd5 100644
> --- a/package/go/Config.in.host
> +++ b/package/go/Config.in.host
> @@ -23,6 +23,7 @@ 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
> +	depends on !BR2_STATIC_LIBS

Why don't we move the dependency on threads to this symbol, and...

>  # 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 fd4caa2e5a..d54be8cd78 100644
> --- a/package/go/go.mk
> +++ b/package/go/go.mk
> @@ -87,7 +87,7 @@ HOST_GO_TARGET_ENV = \
>  # 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)
> +ifeq ($(BR2_TOOLCHAIN_HAS_THREADS):$(BR2_STATIC_LIBS),y:)

... then this condition would be just:
    ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS),y)

I am not fond of the current situation, where parts of the conditions
are in Config.in, and the rest in go.mk.

Regards,
Yann E. MORIN.

>  HOST_GO_CGO_ENABLED = 1
>  else
>  HOST_GO_CGO_ENABLED = 0
> -- 
> 2.38.1
>
diff mbox series

Patch

diff --git a/package/go/Config.in.host b/package/go/Config.in.host
index ded02d3b3a..9e79a7dfd5 100644
--- a/package/go/Config.in.host
+++ b/package/go/Config.in.host
@@ -23,6 +23,7 @@  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
+	depends on !BR2_STATIC_LIBS
 
 # 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 fd4caa2e5a..d54be8cd78 100644
--- a/package/go/go.mk
+++ b/package/go/go.mk
@@ -87,7 +87,7 @@  HOST_GO_TARGET_ENV = \
 # 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)
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS):$(BR2_STATIC_LIBS),y:)
 HOST_GO_CGO_ENABLED = 1
 else
 HOST_GO_CGO_ENABLED = 0