From 8969055428fc974bb05944c8af37fa636830cfe3 Mon Sep 17 00:00:00 2001 From: Jose Quaresma Date: Thu, 4 Apr 2024 11:16:57 +0100 Subject: go: keep the patches in order drop the old version no more used 0007-exec.go-do-not-write-linker-flags-into-buildids.patch that was replaced by the 0001-exec.go-filter-out-build-specific-paths-from-linker-.patch renamed now to 0007-exec.go-filter-out-build-specific-paths-from-linker-.patch (From OE-Core rev: 81b35091e4561b96212a1eedf0e579a8c3aa2b7d) Signed-off-by: Jose Quaresma Signed-off-by: Richard Purdie --- meta/recipes-devtools/go/go-1.22.1.inc | 2 +- ...ter-out-build-specific-paths-from-linker-.patch | 61 ---------------------- ...o-do-not-write-linker-flags-into-buildids.patch | 43 --------------- ...ter-out-build-specific-paths-from-linker-.patch | 61 ++++++++++++++++++++++ 4 files changed, 62 insertions(+), 105 deletions(-) delete mode 100644 meta/recipes-devtools/go/go/0001-exec.go-filter-out-build-specific-paths-from-linker-.patch delete mode 100644 meta/recipes-devtools/go/go/0007-exec.go-do-not-write-linker-flags-into-buildids.patch create mode 100644 meta/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch (limited to 'meta/recipes-devtools') diff --git a/meta/recipes-devtools/go/go-1.22.1.inc b/meta/recipes-devtools/go/go-1.22.1.inc index 4330853450..f1cf4beebb 100644 --- a/meta/recipes-devtools/go/go-1.22.1.inc +++ b/meta/recipes-devtools/go/go-1.22.1.inc @@ -11,8 +11,8 @@ SRC_URI += "\ file://0004-make.bash-override-CC-when-building-dist-and-go_boot.patch \ file://0005-cmd-dist-separate-host-and-target-builds.patch \ file://0006-cmd-go-make-GOROOT-precious-by-default.patch \ + file://0007-exec.go-filter-out-build-specific-paths-from-linker-.patch \ file://0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch \ file://0009-go-Filter-build-paths-on-staticly-linked-arches.patch \ - file://0001-exec.go-filter-out-build-specific-paths-from-linker-.patch \ " SRC_URI[main.sha256sum] = "79c9b91d7f109515a25fc3ecdaad125d67e6bdb54f6d4d98580f46799caea321" diff --git a/meta/recipes-devtools/go/go/0001-exec.go-filter-out-build-specific-paths-from-linker-.patch b/meta/recipes-devtools/go/go/0001-exec.go-filter-out-build-specific-paths-from-linker-.patch deleted file mode 100644 index c5bf28f54a..0000000000 --- a/meta/recipes-devtools/go/go/0001-exec.go-filter-out-build-specific-paths-from-linker-.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 083b5c74b12a1abeb11dd7f58a1cb1593d0000c0 Mon Sep 17 00:00:00 2001 -From: Changqing Li -Date: Tue, 27 Feb 2024 18:06:51 +0800 -Subject: [PATCH] exec.go: filter out build-specific paths from linker flags - -The flags can contain build-specific paths, breaking reproducibility. -Filter out options that have build-specific paths. - -Upstream-Status: Inappropriate [ Not perfect for upstream ] - -Signed-off-by: Changqing Li ---- - src/cmd/go/internal/work/exec.go | 25 ++++++++++++++++++++++++- - 1 file changed, 24 insertions(+), 1 deletion(-) - -diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go -index cde867b..e3ce17d 100644 ---- a/src/cmd/go/internal/work/exec.go -+++ b/src/cmd/go/internal/work/exec.go -@@ -1358,6 +1358,29 @@ func (b *Builder) linkActionID(a *Action) cache.ActionID { - return h.Sum() - } - -+func filterLinkerFlags(flags []string) []string { -+ var newflags []string -+ var skipflag bool -+ skipflag = false -+ for i, flag := range flags { -+ if skipflag == true { -+ skipflag = false -+ continue -+ } -+ if strings.HasPrefix(flag, "--sysroot") || strings.HasPrefix(flag, "-fmacro-prefix-map") || strings.HasPrefix(flag, "-fdebug-prefix-map") || strings.HasPrefix(flag, "-ffile-prefix-map") || strings.HasPrefix(flag, "-fcanon-prefix-map") || strings.HasPrefix(flag, "-fprofile-prefix-map") || strings.HasPrefix(flag, "-Wl,-rpath-link"){ -+ continue -+ } else if strings.HasPrefix(flag, "-extldflags") { -+ skipflag = true -+ newflags = append(newflags, flag) -+ var filterd_Extldflags []string = filterLinkerFlags(strings.Split(flags[i+1], " ")) -+ newflags = append(newflags, strings.Join(filterd_Extldflags, " ")) -+ } else { -+ newflags = append(newflags, flag) -+ } -+ } -+ return newflags -+} -+ - // printLinkerConfig prints the linker config into the hash h, - // as part of the computation of a linker-related action ID. - func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) { -@@ -1368,7 +1391,7 @@ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) { - case "gc": - fmt.Fprintf(h, "link %s %q %s\n", b.toolID("link"), forcedLdflags, ldBuildmode) - if p != nil { -- fmt.Fprintf(h, "linkflags %q\n", p.Internal.Ldflags) -+ fmt.Fprintf(h, "linkflags %q\n", filterLinkerFlags(p.Internal.Ldflags)) - } - - // GOARM, GOMIPS, etc. --- -2.25.1 - diff --git a/meta/recipes-devtools/go/go/0007-exec.go-do-not-write-linker-flags-into-buildids.patch b/meta/recipes-devtools/go/go/0007-exec.go-do-not-write-linker-flags-into-buildids.patch deleted file mode 100644 index 35f3a98d80..0000000000 --- a/meta/recipes-devtools/go/go/0007-exec.go-do-not-write-linker-flags-into-buildids.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 619991feab04f331d081a91243434ccd859f611d Mon Sep 17 00:00:00 2001 -From: Alexander Kanavin -Date: Mon, 23 Nov 2020 19:22:04 +0000 -Subject: [PATCH 7/9] exec.go: do not write linker flags into buildids - -The flags can contain build-specific paths, breaking reproducibility. - -To make this acceptable to upstream, we probably need to trim the flags, -removing those known to be buildhost-specific. - -Upstream-Status: Inappropriate [needs upstream discussion] - -Signed-off-by: Alexander Kanavin -Signed-off-by: Jose Quaresma ---- - src/cmd/go/internal/work/exec.go | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go -index 544df461a2..75df5a4aa8 100644 ---- a/src/cmd/go/internal/work/exec.go -+++ b/src/cmd/go/internal/work/exec.go -@@ -1374,7 +1374,7 @@ func (b *Builder) linkActionID(a *Action) cache.ActionID { - } - - // Toolchain-dependent configuration, shared with b.linkSharedActionID. -- b.printLinkerConfig(h, p) -+ //b.printLinkerConfig(h, p) - - // Input files. - for _, a1 := range a.Deps { -@@ -1720,7 +1720,7 @@ func (b *Builder) linkSharedActionID(a *Action) cache.ActionID { - fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch) - - // Toolchain-dependent configuration, shared with b.linkActionID. -- b.printLinkerConfig(h, nil) -+ //b.printLinkerConfig(h, nil) - - // Input files. - for _, a1 := range a.Deps { --- -2.44.0 - diff --git a/meta/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch b/meta/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch new file mode 100644 index 0000000000..c5bf28f54a --- /dev/null +++ b/meta/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch @@ -0,0 +1,61 @@ +From 083b5c74b12a1abeb11dd7f58a1cb1593d0000c0 Mon Sep 17 00:00:00 2001 +From: Changqing Li +Date: Tue, 27 Feb 2024 18:06:51 +0800 +Subject: [PATCH] exec.go: filter out build-specific paths from linker flags + +The flags can contain build-specific paths, breaking reproducibility. +Filter out options that have build-specific paths. + +Upstream-Status: Inappropriate [ Not perfect for upstream ] + +Signed-off-by: Changqing Li +--- + src/cmd/go/internal/work/exec.go | 25 ++++++++++++++++++++++++- + 1 file changed, 24 insertions(+), 1 deletion(-) + +diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go +index cde867b..e3ce17d 100644 +--- a/src/cmd/go/internal/work/exec.go ++++ b/src/cmd/go/internal/work/exec.go +@@ -1358,6 +1358,29 @@ func (b *Builder) linkActionID(a *Action) cache.ActionID { + return h.Sum() + } + ++func filterLinkerFlags(flags []string) []string { ++ var newflags []string ++ var skipflag bool ++ skipflag = false ++ for i, flag := range flags { ++ if skipflag == true { ++ skipflag = false ++ continue ++ } ++ if strings.HasPrefix(flag, "--sysroot") || strings.HasPrefix(flag, "-fmacro-prefix-map") || strings.HasPrefix(flag, "-fdebug-prefix-map") || strings.HasPrefix(flag, "-ffile-prefix-map") || strings.HasPrefix(flag, "-fcanon-prefix-map") || strings.HasPrefix(flag, "-fprofile-prefix-map") || strings.HasPrefix(flag, "-Wl,-rpath-link"){ ++ continue ++ } else if strings.HasPrefix(flag, "-extldflags") { ++ skipflag = true ++ newflags = append(newflags, flag) ++ var filterd_Extldflags []string = filterLinkerFlags(strings.Split(flags[i+1], " ")) ++ newflags = append(newflags, strings.Join(filterd_Extldflags, " ")) ++ } else { ++ newflags = append(newflags, flag) ++ } ++ } ++ return newflags ++} ++ + // printLinkerConfig prints the linker config into the hash h, + // as part of the computation of a linker-related action ID. + func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) { +@@ -1368,7 +1391,7 @@ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) { + case "gc": + fmt.Fprintf(h, "link %s %q %s\n", b.toolID("link"), forcedLdflags, ldBuildmode) + if p != nil { +- fmt.Fprintf(h, "linkflags %q\n", p.Internal.Ldflags) ++ fmt.Fprintf(h, "linkflags %q\n", filterLinkerFlags(p.Internal.Ldflags)) + } + + // GOARM, GOMIPS, etc. +-- +2.25.1 + -- cgit v1.2.3-54-g00ecf