Skip to contentSkip to conversation

Allow global override of golang GO_DYNLINK

PATCH In review [email protected] 2 participants 3 messages Aug 19, 2021 – Aug 20, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow global override of golang GO_DYNLINK

Small golang applications create massive memory overhead if go-runtime is deployed. So it is helpfull to be able to disable the GO_DYNLINK option on a per distro/local.conf basis by making it a ?= instead of =.

---
 meta/classes/goarch.bbclass | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
meta/classes/goarch.bbclass +7 -7
index 48dc48dabf..92fec16b82 100644
@@ -32,13 +32,13 @@ BASE_GOARM:armv5 = '5'
 # Go supports dynamic linking on a limited set of architectures.
 # See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go
 GO_DYNLINK = ""
-GO_DYNLINK:arm = "1"
-GO_DYNLINK:aarch64 = "1"
-GO_DYNLINK:x86 = "1"
-GO_DYNLINK:x86-64 = "1"
-GO_DYNLINK:powerpc64 = "1"
-GO_DYNLINK:powerpc64le = "1"
-GO_DYNLINK:class-native = ""
+GO_DYNLINK:arm ?= "1"
+GO_DYNLINK:aarch64 ?= "1"
+GO_DYNLINK:x86 ?= "1"
+GO_DYNLINK:x86-64 ?= "1"
+GO_DYNLINK:powerpc64 ?= "1"
+GO_DYNLINK:powerpc64le ?= "1"
+GO_DYNLINK:class-native ?= ""
 GO_DYNLINK:class-nativesdk = ""
 
 # define here because everybody inherits this class
Signature · 1 line
2.32.0
#1 lore raw
Quoted 4 lines · Oliver Kranz

Small golang applications create massive memory overhead if go-runtime is deployed. So it is helpfull to be able to disable the GO_DYNLINK option on a per distro/local.conf basis by making it a ?= instead of =.

I wonder if we should make static as default and let users go for dynamic link if they wish to

Quoted 39 lines
---
 meta/classes/goarch.bbclass | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
meta/classes/goarch.bbclass +0 -0
index 48dc48dabf..92fec16b82 100644
@@ -32,13 +32,13 @@ BASE_GOARM:armv5 = '5'
 # Go supports dynamic linking on a limited set of architectures.
 # See the supportsDynlink function in

go/src/cmd/compile/internal/gc/main.go
GO_DYNLINK = ""

meta/classes/goarch.bbclass +7 -8
-GO_DYNLINK:arm = "1"
-GO_DYNLINK:aarch64 = "1"
-GO_DYNLINK:x86 = "1"
-GO_DYNLINK:x86-64 = "1"
-GO_DYNLINK:powerpc64 = "1"
-GO_DYNLINK:powerpc64le = "1"
-GO_DYNLINK:class-native = ""
+GO_DYNLINK:arm ?= "1"
+GO_DYNLINK:aarch64 ?= "1"
+GO_DYNLINK:x86 ?= "1"
+GO_DYNLINK:x86-64 ?= "1"
+GO_DYNLINK:powerpc64 ?= "1"
+GO_DYNLINK:powerpc64le ?= "1"
+GO_DYNLINK:class-native ?= ""
 GO_DYNLINK:class-nativesdk = ""
 
 # define here because everybody inherits this class
--

2.32.0

#2 lore raw
Quoted 10 lines · Khem Raj
Quoted 4 lines · Oliver Kranz

Small golang applications create massive memory overhead if go-runtime is deployed. So it is helpfull to be able to disable the GO_DYNLINK option on a per distro/local.conf basis by making it a ?= instead of =.

I wonder if we should make static as default and let users go for dynamic link if they wish to

I like the idea, but i was not sure if changing the default behavior on my very fist patch is a good idea.

In my tests with a hello-word and a private project on core-image-minimal, i could observe:

GO_DYNLINK:x86-64 = "1" -> ""
Packagesize +950%
Imagesize -63%

It may be different if a lot of golang applications are deployed but it would take some time to benefit from +30MB shared go-runtime. And i still try to check how CGO is affected by DYNLINK. But all that could be handled by the recipe which generates a "too big" binary and we could behave like golang on the host with the option of DYNLINK.

As i am new here, should i send another patch? or how is this handled?

Quoted 40 lines
Quoted 39 lines
---
  meta/classes/goarch.bbclass | 14 +++++++-------
  1 file changed, 7 insertions(+), 7 deletions(-)
meta/classes/goarch.bbclass +0 -0
index 48dc48dabf..92fec16b82 100644
@@ -32,13 +32,13 @@ BASE_GOARM:armv5 = '5'
  # Go supports dynamic linking on a limited set of architectures.
  # See the supportsDynlink function in

go/src/cmd/compile/internal/gc/main.go
GO_DYNLINK = ""

meta/classes/goarch.bbclass +7 -8
-GO_DYNLINK:arm = "1"
-GO_DYNLINK:aarch64 = "1"
-GO_DYNLINK:x86 = "1"
-GO_DYNLINK:x86-64 = "1"
-GO_DYNLINK:powerpc64 = "1"
-GO_DYNLINK:powerpc64le = "1"
-GO_DYNLINK:class-native = ""
+GO_DYNLINK:arm ?= "1"
+GO_DYNLINK:aarch64 ?= "1"
+GO_DYNLINK:x86 ?= "1"
+GO_DYNLINK:x86-64 ?= "1"
+GO_DYNLINK:powerpc64 ?= "1"
+GO_DYNLINK:powerpc64le ?= "1"
+GO_DYNLINK:class-native ?= ""
  GO_DYNLINK:class-nativesdk = ""
 
  # define here because everybody inherits this class
--

2.32.0