diff mbox series

[2/2] go.bbclass: set buildid to empty string to improve reproducibility

Message ID 20251208091148.368769-2-changqing.li@windriver.com
State New
Headers show
Series [1/2] go.bbclass: change GOTMPDIR to improve reproducibility | expand

Commit Message

Changqing Li Dec. 8, 2025, 9:11 a.m. UTC
From: Changqing Li <changqing.li@windriver.com>

Seems there are other things making Go BuildID not reproducible, set
buildid to empty string to improve reproducibility, open a new issue
[1], and refer an old issue [2].

Refer:
[1] https://github.com/golang/go/issues/76743
[2] https://github.com/golang/go/issues/34186

Signed-off-by: Changqing Li <changqing.li@windriver.com>
---
 meta/classes-recipe/go.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Kjellerstedt Dec. 8, 2025, 7:14 p.m. UTC | #1
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Changqing Li via lists.openembedded.org
> Sent: den 8 december 2025 10:12
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH 2/2] go.bbclass: set buildid to empty string to improve reproducibility
> 
> From: Changqing Li <changqing.li@windriver.com>
> 
> Seems there are other things making Go BuildID not reproducible, set
> buildid to empty string to improve reproducibility, open a new issue
> [1], and refer an old issue [2].
> 
> Refer:
> [1] https://github.com/golang/go/issues/76743
> [2] https://github.com/golang/go/issues/34186
> 
> Signed-off-by: Changqing Li <changqing.li@windriver.com>
> ---
>  meta/classes-recipe/go.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes-recipe/go.bbclass b/meta/classes-recipe/go.bbclass
> index ed986ff5d4..2593368af7 100644
> --- a/meta/classes-recipe/go.bbclass
> +++ b/meta/classes-recipe/go.bbclass
> @@ -50,7 +50,7 @@ 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_EXTRA_LDFLAGS ?= ""
> +GO_EXTRA_LDFLAGS ?= "-buildid="

Adding it to GO_EXTRA_LDFLAGS will probably not have the intended effect 
as some recipes already set that variable and thus will not receive this 
option. You should probably add a new variable for it instead, like the 
other options that are set in GO_LDFLAGS.

>  GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}"
>  # Use system loader. If uninative is used, the uninative loader will be patched automatically
>  GO_LINUXLOADER:class-native = ""
> --
> 2.34.1

//Peter
Changqing Li Dec. 9, 2025, 2:30 a.m. UTC | #2
On 12/9/25 03:14, Peter Kjellerstedt wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
>> -----Original Message-----
>> From:openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Changqing Li via lists.openembedded.org
>> Sent: den 8 december 2025 10:12
>> To:openembedded-core@lists.openembedded.org
>> Subject: [OE-core] [PATCH 2/2] go.bbclass: set buildid to empty string to improve reproducibility
>>
>> From: Changqing Li<changqing.li@windriver.com>
>>
>> Seems there are other things making Go BuildID not reproducible, set
>> buildid to empty string to improve reproducibility, open a new issue
>> [1], and refer an old issue [2].
>>
>> Refer:
>> [1]https://github.com/golang/go/issues/76743
>> [2]https://github.com/golang/go/issues/34186
>>
>> Signed-off-by: Changqing Li<changqing.li@windriver.com>
>> ---
>>   meta/classes-recipe/go.bbclass | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/meta/classes-recipe/go.bbclass b/meta/classes-recipe/go.bbclass
>> index ed986ff5d4..2593368af7 100644
>> --- a/meta/classes-recipe/go.bbclass
>> +++ b/meta/classes-recipe/go.bbclass
>> @@ -50,7 +50,7 @@ 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_EXTRA_LDFLAGS ?= ""
>> +GO_EXTRA_LDFLAGS ?= "-buildid="
> Adding it to GO_EXTRA_LDFLAGS will probably not have the intended effect
> as some recipes already set that variable and thus will not receive this
> option. You should probably add a new variable for it instead, like the
> other options that are set in GO_LDFLAGS.

Good suggestion.  Maybe I can add a varibale GO_BUILDID ?= "-buildid="

//Changqing

>>   GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}"
>>   # Use system loader. If uninative is used, the uninative loader will be patched automatically
>>   GO_LINUXLOADER:class-native = ""
>> --
>> 2.34.1
> //Peter
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/go.bbclass b/meta/classes-recipe/go.bbclass
index ed986ff5d4..2593368af7 100644
--- a/meta/classes-recipe/go.bbclass
+++ b/meta/classes-recipe/go.bbclass
@@ -50,7 +50,7 @@  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_EXTRA_LDFLAGS ?= ""
+GO_EXTRA_LDFLAGS ?= "-buildid="
 GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}"
 # Use system loader. If uninative is used, the uninative loader will be patched automatically
 GO_LINUXLOADER:class-native = ""