diff options
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r-- | meta/recipes-devtools/go/go-1.22.0.inc | 2 | ||||
-rw-r--r-- | meta/recipes-devtools/go/go/0001-exec.go-filter-out-build-specific-paths-from-linker-.patch | 61 |
2 files changed, 62 insertions, 1 deletions
diff --git a/meta/recipes-devtools/go/go-1.22.0.inc b/meta/recipes-devtools/go/go-1.22.0.inc index 230ada5e4b..5b94051fc2 100644 --- a/meta/recipes-devtools/go/go-1.22.0.inc +++ b/meta/recipes-devtools/go/go-1.22.0.inc | |||
@@ -11,8 +11,8 @@ SRC_URI += "\ | |||
11 | file://0004-make.bash-override-CC-when-building-dist-and-go_boot.patch \ | 11 | file://0004-make.bash-override-CC-when-building-dist-and-go_boot.patch \ |
12 | file://0005-cmd-dist-separate-host-and-target-builds.patch \ | 12 | file://0005-cmd-dist-separate-host-and-target-builds.patch \ |
13 | file://0006-cmd-go-make-GOROOT-precious-by-default.patch \ | 13 | file://0006-cmd-go-make-GOROOT-precious-by-default.patch \ |
14 | file://0007-exec.go-do-not-write-linker-flags-into-buildids.patch \ | ||
15 | file://0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch \ | 14 | file://0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch \ |
16 | file://0009-go-Filter-build-paths-on-staticly-linked-arches.patch \ | 15 | file://0009-go-Filter-build-paths-on-staticly-linked-arches.patch \ |
16 | file://0001-exec.go-filter-out-build-specific-paths-from-linker-.patch \ | ||
17 | " | 17 | " |
18 | SRC_URI[main.sha256sum] = "4d196c3d41a0d6c1dfc64d04e3cc1f608b0c436bd87b7060ce3e23234e1f4d5c" | 18 | SRC_URI[main.sha256sum] = "4d196c3d41a0d6c1dfc64d04e3cc1f608b0c436bd87b7060ce3e23234e1f4d5c" |
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 new file mode 100644 index 0000000000..c5bf28f54a --- /dev/null +++ b/meta/recipes-devtools/go/go/0001-exec.go-filter-out-build-specific-paths-from-linker-.patch | |||
@@ -0,0 +1,61 @@ | |||
1 | From 083b5c74b12a1abeb11dd7f58a1cb1593d0000c0 Mon Sep 17 00:00:00 2001 | ||
2 | From: Changqing Li <changqing.li@windriver.com> | ||
3 | Date: Tue, 27 Feb 2024 18:06:51 +0800 | ||
4 | Subject: [PATCH] exec.go: filter out build-specific paths from linker flags | ||
5 | |||
6 | The flags can contain build-specific paths, breaking reproducibility. | ||
7 | Filter out options that have build-specific paths. | ||
8 | |||
9 | Upstream-Status: Inappropriate [ Not perfect for upstream ] | ||
10 | |||
11 | Signed-off-by: Changqing Li <changqing.li@windriver.com> | ||
12 | --- | ||
13 | src/cmd/go/internal/work/exec.go | 25 ++++++++++++++++++++++++- | ||
14 | 1 file changed, 24 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go | ||
17 | index cde867b..e3ce17d 100644 | ||
18 | --- a/src/cmd/go/internal/work/exec.go | ||
19 | +++ b/src/cmd/go/internal/work/exec.go | ||
20 | @@ -1358,6 +1358,29 @@ func (b *Builder) linkActionID(a *Action) cache.ActionID { | ||
21 | return h.Sum() | ||
22 | } | ||
23 | |||
24 | +func filterLinkerFlags(flags []string) []string { | ||
25 | + var newflags []string | ||
26 | + var skipflag bool | ||
27 | + skipflag = false | ||
28 | + for i, flag := range flags { | ||
29 | + if skipflag == true { | ||
30 | + skipflag = false | ||
31 | + continue | ||
32 | + } | ||
33 | + 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"){ | ||
34 | + continue | ||
35 | + } else if strings.HasPrefix(flag, "-extldflags") { | ||
36 | + skipflag = true | ||
37 | + newflags = append(newflags, flag) | ||
38 | + var filterd_Extldflags []string = filterLinkerFlags(strings.Split(flags[i+1], " ")) | ||
39 | + newflags = append(newflags, strings.Join(filterd_Extldflags, " ")) | ||
40 | + } else { | ||
41 | + newflags = append(newflags, flag) | ||
42 | + } | ||
43 | + } | ||
44 | + return newflags | ||
45 | +} | ||
46 | + | ||
47 | // printLinkerConfig prints the linker config into the hash h, | ||
48 | // as part of the computation of a linker-related action ID. | ||
49 | func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) { | ||
50 | @@ -1368,7 +1391,7 @@ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) { | ||
51 | case "gc": | ||
52 | fmt.Fprintf(h, "link %s %q %s\n", b.toolID("link"), forcedLdflags, ldBuildmode) | ||
53 | if p != nil { | ||
54 | - fmt.Fprintf(h, "linkflags %q\n", p.Internal.Ldflags) | ||
55 | + fmt.Fprintf(h, "linkflags %q\n", filterLinkerFlags(p.Internal.Ldflags)) | ||
56 | } | ||
57 | |||
58 | // GOARM, GOMIPS, etc. | ||
59 | -- | ||
60 | 2.25.1 | ||
61 | |||