openembedded-core.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
* [OE-core][PATCH 1/2] go: Drop the linkmode completely
@ 2024-04-19 17:53 Jose Quaresma
  2024-04-19 17:53 ` [OE-core][PATCH 2/2] Revert "goarch: disable dynamic linking globally" Jose Quaresma
  2024-04-19 18:17 ` [OE-core][PATCH 1/2] go: Drop the linkmode completely Khem Raj
  0 siblings, 2 replies; 7+ messages in thread
From: Jose Quaresma @ 2024-04-19 17:53 UTC (permalink / raw)
  To: openembedded-core; +Cc: Jose Quaresma

This will make possible to restore the default dynamic linking globally
which is what we had before the 1.20.X release.

Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
 meta/classes-recipe/go.bbclass          | 2 --
 meta/recipes-devtools/go/go-runtime.inc | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/meta/classes-recipe/go.bbclass b/meta/classes-recipe/go.bbclass
index cc3564c36a..d32509aa6d 100644
--- a/meta/classes-recipe/go.bbclass
+++ b/meta/classes-recipe/go.bbclass
@@ -48,8 +48,6 @@ GO_RPATH:class-native = "${@'-r ${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE
 GO_RPATH_LINK:class-native = "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}"
 GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS}"
 GO_LINKMODE ?= ""
-GO_LINKMODE:class-nativesdk = "--linkmode=external"
-GO_LINKMODE:class-native = "--linkmode=external"
 GO_EXTRA_LDFLAGS ?= ""
 GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}"
 # Use system loader. If uninative is used, the uninative loader will be patched automatically
diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
index 3f1e795dd9..413cf6d33f 100644
--- a/meta/recipes-devtools/go/go-runtime.inc
+++ b/meta/recipes-devtools/go/go-runtime.inc
@@ -15,7 +15,7 @@ export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-pr
 export GOCACHE = "${B}/.cache"
 
 GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
-GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"'
+GO_SHLIB_LDFLAGS ?= '-ldflags="-extldflags '${GO_EXTLDFLAGS}'"'
 
 do_configure() {
 	:
-- 
2.44.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [OE-core][PATCH 2/2] Revert "goarch: disable dynamic linking globally"
  2024-04-19 17:53 [OE-core][PATCH 1/2] go: Drop the linkmode completely Jose Quaresma
@ 2024-04-19 17:53 ` Jose Quaresma
  2024-04-19 18:17 ` [OE-core][PATCH 1/2] go: Drop the linkmode completely Khem Raj
  1 sibling, 0 replies; 7+ messages in thread
From: Jose Quaresma @ 2024-04-19 17:53 UTC (permalink / raw)
  To: openembedded-core; +Cc: Jose Quaresma

This reverts commit 827c60b79e7fcafd14e68870f6b69dcc48ac9c39.

Fixed with the drop of the linkmode

Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
 meta/classes-recipe/goarch.bbclass | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/meta/classes-recipe/goarch.bbclass b/meta/classes-recipe/goarch.bbclass
index 6899ec28e4..1ebe03864f 100644
--- a/meta/classes-recipe/goarch.bbclass
+++ b/meta/classes-recipe/goarch.bbclass
@@ -38,13 +38,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 = ""
-GO_DYNLINK:aarch64 = ""
-GO_DYNLINK:x86 = ""
-GO_DYNLINK:x86-64 = ""
-GO_DYNLINK:powerpc64 = ""
-GO_DYNLINK:powerpc64le = ""
-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.44.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [OE-core][PATCH 1/2] go: Drop the linkmode completely
  2024-04-19 17:53 [OE-core][PATCH 1/2] go: Drop the linkmode completely Jose Quaresma
  2024-04-19 17:53 ` [OE-core][PATCH 2/2] Revert "goarch: disable dynamic linking globally" Jose Quaresma
@ 2024-04-19 18:17 ` Khem Raj
  2024-04-19 18:28   ` Jose Quaresma
  1 sibling, 1 reply; 7+ messages in thread
From: Khem Raj @ 2024-04-19 18:17 UTC (permalink / raw)
  To: quaresma.jose; +Cc: openembedded-core, Jose Quaresma

On Fri, Apr 19, 2024 at 10:53 AM Jose Quaresma via
lists.openembedded.org
<quaresma.jose=gmail.com@lists.openembedded.org> wrote:
>
> This will make possible to restore the default dynamic linking globally
> which is what we had before the 1.20.X release.
>

Looks good overall. how do we support the static linking if user wanted ?

> Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
> ---
>  meta/classes-recipe/go.bbclass          | 2 --
>  meta/recipes-devtools/go/go-runtime.inc | 2 +-
>  2 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/meta/classes-recipe/go.bbclass b/meta/classes-recipe/go.bbclass
> index cc3564c36a..d32509aa6d 100644
> --- a/meta/classes-recipe/go.bbclass
> +++ b/meta/classes-recipe/go.bbclass
> @@ -48,8 +48,6 @@ GO_RPATH:class-native = "${@'-r ${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE
>  GO_RPATH_LINK:class-native = "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}"
>  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS}"
>  GO_LINKMODE ?= ""
> -GO_LINKMODE:class-nativesdk = "--linkmode=external"
> -GO_LINKMODE:class-native = "--linkmode=external"
>  GO_EXTRA_LDFLAGS ?= ""
>  GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}"
>  # Use system loader. If uninative is used, the uninative loader will be patched automatically
> diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
> index 3f1e795dd9..413cf6d33f 100644
> --- a/meta/recipes-devtools/go/go-runtime.inc
> +++ b/meta/recipes-devtools/go/go-runtime.inc
> @@ -15,7 +15,7 @@ export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-pr
>  export GOCACHE = "${B}/.cache"
>
>  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
> -GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"'
> +GO_SHLIB_LDFLAGS ?= '-ldflags="-extldflags '${GO_EXTLDFLAGS}'"'
>
>  do_configure() {
>         :
> --
> 2.44.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#198558): https://lists.openembedded.org/g/openembedded-core/message/198558
> Mute This Topic: https://lists.openembedded.org/mt/105623011/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OE-core][PATCH 1/2] go: Drop the linkmode completely
  2024-04-19 18:17 ` [OE-core][PATCH 1/2] go: Drop the linkmode completely Khem Raj
@ 2024-04-19 18:28   ` Jose Quaresma
  2024-04-19 20:43     ` Khem Raj
  0 siblings, 1 reply; 7+ messages in thread
From: Jose Quaresma @ 2024-04-19 18:28 UTC (permalink / raw)
  To: Khem Raj; +Cc: openembedded-core, Jose Quaresma

[-- Attachment #1: Type: text/plain, Size: 3199 bytes --]

Khem Raj <raj.khem@gmail.com> escreveu (sexta, 19/04/2024 à(s) 19:17):

> On Fri, Apr 19, 2024 at 10:53 AM Jose Quaresma via
> lists.openembedded.org
> <quaresma.jose=gmail.com@lists.openembedded.org> wrote:
> >
> > This will make possible to restore the default dynamic linking globally
> > which is what we had before the 1.20.X release.
> >
>
> Looks good overall. how do we support the static linking if user wanted ?
>

To disable the dynamic linking, which is the default, we need to unset the
GO_DYNLINK
but this needs to be done with a machine arch override otherwise has no
effect.

GO_DYNLINK:machine_arch = ""

As an example the below patch enables the static linkiging for all the
architectures
https://git.yoctoproject.org/poky/commit/meta/classes-recipe/goarch.bbclass?id=fd2e5e0b89d9c69acc9f813f07cd052630596ad5

Jose


> > Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
> > ---
> >  meta/classes-recipe/go.bbclass          | 2 --
> >  meta/recipes-devtools/go/go-runtime.inc | 2 +-
> >  2 files changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/meta/classes-recipe/go.bbclass
> b/meta/classes-recipe/go.bbclass
> > index cc3564c36a..d32509aa6d 100644
> > --- a/meta/classes-recipe/go.bbclass
> > +++ b/meta/classes-recipe/go.bbclass
> > @@ -48,8 +48,6 @@ GO_RPATH:class-native = "${@'-r
> ${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE
> >  GO_RPATH_LINK:class-native =
> "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink'
> if d.getVar('GO_DYNLINK') else ''}"
> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK}
> ${LDFLAGS}"
> >  GO_LINKMODE ?= ""
> > -GO_LINKMODE:class-nativesdk = "--linkmode=external"
> > -GO_LINKMODE:class-native = "--linkmode=external"
> >  GO_EXTRA_LDFLAGS ?= ""
> >  GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}"
> >  # Use system loader. If uninative is used, the uninative loader will be
> patched automatically
> > diff --git a/meta/recipes-devtools/go/go-runtime.inc
> b/meta/recipes-devtools/go/go-runtime.inc
> > index 3f1e795dd9..413cf6d33f 100644
> > --- a/meta/recipes-devtools/go/go-runtime.inc
> > +++ b/meta/recipes-devtools/go/go-runtime.inc
> > @@ -15,7 +15,7 @@ export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f:
> not f.startswith('-fdebug-pr
> >  export GOCACHE = "${B}/.cache"
> >
> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
> > -GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags
> '${GO_EXTLDFLAGS}'"'
> > +GO_SHLIB_LDFLAGS ?= '-ldflags="-extldflags '${GO_EXTLDFLAGS}'"'
> >
> >  do_configure() {
> >         :
> > --
> > 2.44.0
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#198558):
> https://lists.openembedded.org/g/openembedded-core/message/198558
> > Mute This Topic: https://lists.openembedded.org/mt/105623011/1997914
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> raj.khem@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>


-- 
Best regards,

José Quaresma

[-- Attachment #2: Type: text/html, Size: 5228 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OE-core][PATCH 1/2] go: Drop the linkmode completely
  2024-04-19 18:28   ` Jose Quaresma
@ 2024-04-19 20:43     ` Khem Raj
  2024-04-22 11:47       ` Jose Quaresma
  0 siblings, 1 reply; 7+ messages in thread
From: Khem Raj @ 2024-04-19 20:43 UTC (permalink / raw)
  To: Jose Quaresma; +Cc: Jose Quaresma, openembedded-core

[-- Attachment #1: Type: text/plain, Size: 3537 bytes --]

On Fri, Apr 19, 2024 at 11:28 AM Jose Quaresma <quaresma.jose@gmail.com>
wrote:

>
>
> Khem Raj <raj.khem@gmail.com> escreveu (sexta, 19/04/2024 à(s) 19:17):
>
>> On Fri, Apr 19, 2024 at 10:53 AM Jose Quaresma via
>> lists.openembedded.org
>> <quaresma.jose=gmail.com@lists.openembedded.org> wrote:
>> >
>> > This will make possible to restore the default dynamic linking globally
>> > which is what we had before the 1.20.X release.
>> >
>>
>> Looks good overall. how do we support the static linking if user wanted ?
>>
>
> To disable the dynamic linking, which is the default, we need to unset the
> GO_DYNLINK
> but this needs to be done with a machine arch override otherwise has no
> effect.
>
> GO_DYNLINK:machine_arch = ""
>
> As an example the below patch enables the static linkiging for all the
> architectures
>
> https://git.yoctoproject.org/poky/commit/meta/classes-recipe/goarch.bbclass?id=fd2e5e0b89d9c69acc9f813f07cd052630596ad5
>
>

I wonder if it makes sense to have a variable for doing static linking now
that dynamic linking is default anyway and remove it


> Jose
>
>
>> > Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
>> > ---
>> >  meta/classes-recipe/go.bbclass          | 2 --
>> >  meta/recipes-devtools/go/go-runtime.inc | 2 +-
>> >  2 files changed, 1 insertion(+), 3 deletions(-)
>> >
>> > diff --git a/meta/classes-recipe/go.bbclass
>> b/meta/classes-recipe/go.bbclass
>> > index cc3564c36a..d32509aa6d 100644
>> > --- a/meta/classes-recipe/go.bbclass
>> > +++ b/meta/classes-recipe/go.bbclass
>> > @@ -48,8 +48,6 @@ GO_RPATH:class-native = "${@'-r
>> ${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE
>> >  GO_RPATH_LINK:class-native =
>> "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink'
>> if d.getVar('GO_DYNLINK') else ''}"
>> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK}
>> ${LDFLAGS}"
>> >  GO_LINKMODE ?= ""
>> > -GO_LINKMODE:class-nativesdk = "--linkmode=external"
>> > -GO_LINKMODE:class-native = "--linkmode=external"
>> >  GO_EXTRA_LDFLAGS ?= ""
>> >  GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}"
>> >  # Use system loader. If uninative is used, the uninative loader will
>> be patched automatically
>> > diff --git a/meta/recipes-devtools/go/go-runtime.inc
>> b/meta/recipes-devtools/go/go-runtime.inc
>> > index 3f1e795dd9..413cf6d33f 100644
>> > --- a/meta/recipes-devtools/go/go-runtime.inc
>> > +++ b/meta/recipes-devtools/go/go-runtime.inc
>> > @@ -15,7 +15,7 @@ export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f:
>> not f.startswith('-fdebug-pr
>> >  export GOCACHE = "${B}/.cache"
>> >
>> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
>> > -GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags
>> '${GO_EXTLDFLAGS}'"'
>> > +GO_SHLIB_LDFLAGS ?= '-ldflags="-extldflags '${GO_EXTLDFLAGS}'"'
>> >
>> >  do_configure() {
>> >         :
>> > --
>> > 2.44.0
>> >
>> >
>> > -=-=-=-=-=-=-=-=-=-=-=-
>> > Links: You receive all messages sent to this group.
>> > View/Reply Online (#198558):
>> https://lists.openembedded.org/g/openembedded-core/message/198558
>> > Mute This Topic: https://lists.openembedded.org/mt/105623011/1997914
>> > Group Owner: openembedded-core+owner@lists.openembedded.org
>> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
>> raj.khem@gmail.com]
>> > -=-=-=-=-=-=-=-=-=-=-=-
>> >
>>
>
>
> --
> Best regards,
>
> José Quaresma
>

[-- Attachment #2: Type: text/html, Size: 6058 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OE-core][PATCH 1/2] go: Drop the linkmode completely
  2024-04-19 20:43     ` Khem Raj
@ 2024-04-22 11:47       ` Jose Quaresma
  2024-04-22 15:38         ` Khem Raj
  0 siblings, 1 reply; 7+ messages in thread
From: Jose Quaresma @ 2024-04-22 11:47 UTC (permalink / raw)
  To: Khem Raj; +Cc: Jose Quaresma, openembedded-core

[-- Attachment #1: Type: text/plain, Size: 4719 bytes --]

Khem Raj <raj.khem@gmail.com> escreveu (sexta, 19/04/2024 à(s) 21:43):

>
>
> On Fri, Apr 19, 2024 at 11:28 AM Jose Quaresma <quaresma.jose@gmail.com>
> wrote:
>
>>
>>
>> Khem Raj <raj.khem@gmail.com> escreveu (sexta, 19/04/2024 à(s) 19:17):
>>
>>> On Fri, Apr 19, 2024 at 10:53 AM Jose Quaresma via
>>> lists.openembedded.org
>>> <quaresma.jose=gmail.com@lists.openembedded.org> wrote:
>>> >
>>> > This will make possible to restore the default dynamic linking globally
>>> > which is what we had before the 1.20.X release.
>>> >
>>>
>>> Looks good overall. how do we support the static linking if user wanted ?
>>>
>>
>> To disable the dynamic linking, which is the default, we need to unset
>> the GO_DYNLINK
>> but this needs to be done with a machine arch override otherwise has no
>> effect.
>>
>> GO_DYNLINK:machine_arch = ""
>>
>> As an example the below patch enables the static linkiging for all the
>> architectures
>>
>> https://git.yoctoproject.org/poky/commit/meta/classes-recipe/goarch.bbclass?id=fd2e5e0b89d9c69acc9f813f07cd052630596ad5
>>
>>
>
> I wonder if it makes sense to have a variable for doing static linking now
> that dynamic linking is default anyway and remove it
>

To do this, we would have to remove all the logic based on the GO_DYNLINK and
add this new variable to the static linking.

Just to clarify, the default upstream golang linking is the static way but
in OE we prefer the dynamic linking maybe because
the binary size but I did some tests and surprisingly the result can even
be better in terms of binary size when we link statically
as can be see on this https://github.com/foundriesio/lmp-manifest/pull/425

This toolchain is also a bit particular in the sense that the go-runtime
conditions all other packages afterwards.
For example, by having a static go-runtime we are conditioning everything
to be linked in the same way,
the opposite is no longer true and we can have the go-runtime dynamically
but then have packages linked statically.
The reason is because the /usr/lib/go/pkg/linux_amd64_dynlink/libstd.so
only exists when the go-runtime is dynamically linked.

Jose


>
>
>> Jose
>>
>>
>>> > Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
>>> > ---
>>> >  meta/classes-recipe/go.bbclass          | 2 --
>>> >  meta/recipes-devtools/go/go-runtime.inc | 2 +-
>>> >  2 files changed, 1 insertion(+), 3 deletions(-)
>>> >
>>> > diff --git a/meta/classes-recipe/go.bbclass
>>> b/meta/classes-recipe/go.bbclass
>>> > index cc3564c36a..d32509aa6d 100644
>>> > --- a/meta/classes-recipe/go.bbclass
>>> > +++ b/meta/classes-recipe/go.bbclass
>>> > @@ -48,8 +48,6 @@ GO_RPATH:class-native = "${@'-r
>>> ${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE
>>> >  GO_RPATH_LINK:class-native =
>>> "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink'
>>> if d.getVar('GO_DYNLINK') else ''}"
>>> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}
>>> ${GO_RPATH_LINK} ${LDFLAGS}"
>>> >  GO_LINKMODE ?= ""
>>> > -GO_LINKMODE:class-nativesdk = "--linkmode=external"
>>> > -GO_LINKMODE:class-native = "--linkmode=external"
>>> >  GO_EXTRA_LDFLAGS ?= ""
>>> >  GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}"
>>> >  # Use system loader. If uninative is used, the uninative loader will
>>> be patched automatically
>>> > diff --git a/meta/recipes-devtools/go/go-runtime.inc
>>> b/meta/recipes-devtools/go/go-runtime.inc
>>> > index 3f1e795dd9..413cf6d33f 100644
>>> > --- a/meta/recipes-devtools/go/go-runtime.inc
>>> > +++ b/meta/recipes-devtools/go/go-runtime.inc
>>> > @@ -15,7 +15,7 @@ export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f:
>>> not f.startswith('-fdebug-pr
>>> >  export GOCACHE = "${B}/.cache"
>>> >
>>> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
>>> > -GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags
>>> '${GO_EXTLDFLAGS}'"'
>>> > +GO_SHLIB_LDFLAGS ?= '-ldflags="-extldflags '${GO_EXTLDFLAGS}'"'
>>> >
>>> >  do_configure() {
>>> >         :
>>> > --
>>> > 2.44.0
>>> >
>>> >
>>> > -=-=-=-=-=-=-=-=-=-=-=-
>>> > Links: You receive all messages sent to this group.
>>> > View/Reply Online (#198558):
>>> https://lists.openembedded.org/g/openembedded-core/message/198558
>>> > Mute This Topic: https://lists.openembedded.org/mt/105623011/1997914
>>> > Group Owner: openembedded-core+owner@lists.openembedded.org
>>> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
>>> [raj.khem@gmail.com]
>>> > -=-=-=-=-=-=-=-=-=-=-=-
>>> >
>>>
>>
>>
>> --
>> Best regards,
>>
>> José Quaresma
>>
>

-- 
Best regards,

José Quaresma

[-- Attachment #2: Type: text/html, Size: 8139 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OE-core][PATCH 1/2] go: Drop the linkmode completely
  2024-04-22 11:47       ` Jose Quaresma
@ 2024-04-22 15:38         ` Khem Raj
  0 siblings, 0 replies; 7+ messages in thread
From: Khem Raj @ 2024-04-22 15:38 UTC (permalink / raw)
  To: Jose Quaresma; +Cc: Jose Quaresma, openembedded-core

[-- Attachment #1: Type: text/plain, Size: 5114 bytes --]

On Mon, Apr 22, 2024 at 1:47 PM Jose Quaresma <quaresma.jose@gmail.com>
wrote:

>
>
> Khem Raj <raj.khem@gmail.com> escreveu (sexta, 19/04/2024 à(s) 21:43):
>
>>
>>
>> On Fri, Apr 19, 2024 at 11:28 AM Jose Quaresma <quaresma.jose@gmail.com>
>> wrote:
>>
>>>
>>>
>>> Khem Raj <raj.khem@gmail.com> escreveu (sexta, 19/04/2024 à(s) 19:17):
>>>
>>>> On Fri, Apr 19, 2024 at 10:53 AM Jose Quaresma via
>>>> lists.openembedded.org
>>>> <quaresma.jose=gmail.com@lists.openembedded.org> wrote:
>>>> >
>>>> > This will make possible to restore the default dynamic linking
>>>> globally
>>>> > which is what we had before the 1.20.X release.
>>>> >
>>>>
>>>> Looks good overall. how do we support the static linking if user wanted
>>>> ?
>>>>
>>>
>>> To disable the dynamic linking, which is the default, we need to unset
>>> the GO_DYNLINK
>>> but this needs to be done with a machine arch override otherwise has no
>>> effect.
>>>
>>> GO_DYNLINK:machine_arch = ""
>>>
>>> As an example the below patch enables the static linkiging for all the
>>> architectures
>>>
>>> https://git.yoctoproject.org/poky/commit/meta/classes-recipe/goarch.bbclass?id=fd2e5e0b89d9c69acc9f813f07cd052630596ad5
>>>
>>>
>>
>> I wonder if it makes sense to have a variable for doing static linking
>> now that dynamic linking is default anyway and remove it
>>
>
> To do this, we would have to remove all the logic based on the GO_DYNLINK and
> add this new variable to the static linking.
>
> Just to clarify, the default upstream golang linking is the static way but
> in OE we prefer the dynamic linking maybe because
> the binary size but I did some tests and surprisingly the result can even
> be better in terms of binary size when we link statically
> as can be see on this https://github.com/foundriesio/lmp-manifest/pull/425
>

Yeah that’s ok for build time sizes but I wonder how does it do at runtime
since this will use go runtime as dynamic libs


> This toolchain is also a bit particular in the sense that the go-runtime
> conditions all other packages afterwards.
> For example, by having a static go-runtime we are conditioning everything
> to be linked in the same way,
> the opposite is no longer true and we can have the go-runtime dynamically
> but then have packages linked statically.
> The reason is because the /usr/lib/go/pkg/linux_amd64_dynlink/libstd.so
> only exists when the go-runtime is dynamically linked.
>
>
> Jose
>
>
>>
>>
>>> Jose
>>>
>>>
>>>> > Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
>>>> > ---
>>>> >  meta/classes-recipe/go.bbclass          | 2 --
>>>> >  meta/recipes-devtools/go/go-runtime.inc | 2 +-
>>>> >  2 files changed, 1 insertion(+), 3 deletions(-)
>>>> >
>>>> > diff --git a/meta/classes-recipe/go.bbclass
>>>> b/meta/classes-recipe/go.bbclass
>>>> > index cc3564c36a..d32509aa6d 100644
>>>> > --- a/meta/classes-recipe/go.bbclass
>>>> > +++ b/meta/classes-recipe/go.bbclass
>>>> > @@ -48,8 +48,6 @@ GO_RPATH:class-native = "${@'-r
>>>> ${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE
>>>> >  GO_RPATH_LINK:class-native =
>>>> "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink'
>>>> if d.getVar('GO_DYNLINK') else ''}"
>>>> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}
>>>> ${GO_RPATH_LINK} ${LDFLAGS}"
>>>> >  GO_LINKMODE ?= ""
>>>> > -GO_LINKMODE:class-nativesdk = "--linkmode=external"
>>>> > -GO_LINKMODE:class-native = "--linkmode=external"
>>>> >  GO_EXTRA_LDFLAGS ?= ""
>>>> >  GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}"
>>>> >  # Use system loader. If uninative is used, the uninative loader will
>>>> be patched automatically
>>>> > diff --git a/meta/recipes-devtools/go/go-runtime.inc
>>>> b/meta/recipes-devtools/go/go-runtime.inc
>>>> > index 3f1e795dd9..413cf6d33f 100644
>>>> > --- a/meta/recipes-devtools/go/go-runtime.inc
>>>> > +++ b/meta/recipes-devtools/go/go-runtime.inc
>>>> > @@ -15,7 +15,7 @@ export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f:
>>>> not f.startswith('-fdebug-pr
>>>> >  export GOCACHE = "${B}/.cache"
>>>> >
>>>> >  GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
>>>> > -GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags
>>>> '${GO_EXTLDFLAGS}'"'
>>>> > +GO_SHLIB_LDFLAGS ?= '-ldflags="-extldflags '${GO_EXTLDFLAGS}'"'
>>>> >
>>>> >  do_configure() {
>>>> >         :
>>>> > --
>>>> > 2.44.0
>>>> >
>>>> >
>>>> > -=-=-=-=-=-=-=-=-=-=-=-
>>>> > Links: You receive all messages sent to this group.
>>>> > View/Reply Online (#198558):
>>>> https://lists.openembedded.org/g/openembedded-core/message/198558
>>>> > Mute This Topic: https://lists.openembedded.org/mt/105623011/1997914
>>>> > Group Owner: openembedded-core+owner@lists.openembedded.org
>>>> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
>>>> [raj.khem@gmail.com]
>>>> > -=-=-=-=-=-=-=-=-=-=-=-
>>>> >
>>>>
>>>
>>>
>>> --
>>> Best regards,
>>>
>>> José Quaresma
>>>
>>
>
> --
> Best regards,
>
> José Quaresma
>

[-- Attachment #2: Type: text/html, Size: 8964 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-22 15:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-19 17:53 [OE-core][PATCH 1/2] go: Drop the linkmode completely Jose Quaresma
2024-04-19 17:53 ` [OE-core][PATCH 2/2] Revert "goarch: disable dynamic linking globally" Jose Quaresma
2024-04-19 18:17 ` [OE-core][PATCH 1/2] go: Drop the linkmode completely Khem Raj
2024-04-19 18:28   ` Jose Quaresma
2024-04-19 20:43     ` Khem Raj
2024-04-22 11:47       ` Jose Quaresma
2024-04-22 15:38         ` Khem Raj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).