summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go/go/filter-build-paths.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/go/go/filter-build-paths.patch')
-rw-r--r--meta/recipes-devtools/go/go/filter-build-paths.patch53
1 files changed, 31 insertions, 22 deletions
diff --git a/meta/recipes-devtools/go/go/filter-build-paths.patch b/meta/recipes-devtools/go/go/filter-build-paths.patch
index caf727714e..a1aa37c2a4 100644
--- a/meta/recipes-devtools/go/go/filter-build-paths.patch
+++ b/meta/recipes-devtools/go/go/filter-build-paths.patch
@@ -1,3 +1,8 @@
+From 3bdbce685c688a27eece36ccc8be9b50b4849498 Mon Sep 17 00:00:00 2001
+From: Richard Purdie <richard.purdie@linuxfoundation.org>
+Date: Sat, 2 Jul 2022 23:08:13 +0100
+Subject: [PATCH] go: Filter build paths on staticly linked arches
+
Filter out build time paths from ldflags and other flags variables when they're
embedded in the go binary so that builds are reproducible regardless of build
location. This codepath is hit for statically linked go binaries such as those
@@ -6,11 +11,15 @@ on mips/ppc.
Upstream-Status: Pending
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-Index: go/src/cmd/go/internal/load/pkg.go
-===================================================================
---- go.orig/src/cmd/go/internal/load/pkg.go
-+++ go/src/cmd/go/internal/load/pkg.go
-@@ -2225,6 +2225,17 @@ func (p *Package) collectDeps() {
+---
+ src/cmd/go/internal/load/pkg.go | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
+index 046f508..353cbc4 100644
+--- a/src/cmd/go/internal/load/pkg.go
++++ b/src/cmd/go/internal/load/pkg.go
+@@ -2256,6 +2256,17 @@ func (p *Package) collectDeps() {
// to their VCS information (vcsStatusError).
var vcsStatusCache par.Cache
@@ -28,21 +37,21 @@ Index: go/src/cmd/go/internal/load/pkg.go
// setBuildInfo gathers build information, formats it as a string to be
// embedded in the binary, then sets p.Internal.BuildInfo to that string.
// setBuildInfo should only be called on a main package with no errors.
-@@ -2329,7 +2340,7 @@ func (p *Package) setBuildInfo(includeVC
- appendSetting("-gcflags", BuildGcflags.String())
- }
- if BuildLdflags.present {
-- appendSetting("-ldflags", BuildLdflags.String())
-+ appendSetting("-ldflags", filterCompilerFlags(BuildLdflags.String()))
- }
- if cfg.BuildMSan {
- appendSetting("-msan", "true")
-@@ -2347,7 +2358,7 @@ func (p *Package) setBuildInfo(includeVC
- appendSetting("CGO_ENABLED", cgo)
- if cfg.BuildContext.CgoEnabled {
- for _, name := range []string{"CGO_CFLAGS", "CGO_CPPFLAGS", "CGO_CXXFLAGS", "CGO_LDFLAGS"} {
-- appendSetting(name, cfg.Getenv(name))
-+ appendSetting(name, filterCompilerFlags(cfg.Getenv(name)))
- }
+@@ -2353,7 +2364,7 @@ func (p *Package) setBuildInfo(includeVCS bool) {
+ if gcflags := BuildGcflags.String(); gcflags != "" && cfg.BuildContext.Compiler == "gc" {
+ appendSetting("-gcflags", gcflags)
+ }
+- if ldflags := BuildLdflags.String(); ldflags != "" {
++ if ldflags := filterCompilerFlags(BuildLdflags.String()); ldflags != "" {
+ // https://go.dev/issue/52372: only include ldflags if -trimpath is not set,
+ // since it can include system paths through various linker flags (notably
+ // -extar, -extld, and -extldflags).
+@@ -2392,7 +2403,7 @@ func (p *Package) setBuildInfo(includeVCS bool) {
+ // subset of flags that are known not to be paths?
+ if cfg.BuildContext.CgoEnabled && !cfg.BuildTrimpath {
+ for _, name := range []string{"CGO_CFLAGS", "CGO_CPPFLAGS", "CGO_CXXFLAGS", "CGO_LDFLAGS"} {
+- appendSetting(name, cfg.Getenv(name))
++ appendSetting(name, filterCompilerFlags(cfg.Getenv(name)))
}
- appendSetting("GOARCH", cfg.BuildContext.GOARCH)
+ }
+ appendSetting("GOARCH", cfg.BuildContext.GOARCH)