summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRyan Eatmon <reatmon@ti.com>2022-11-29 08:12:02 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-05 22:28:12 +0000
commit058def277e0cd8e262ba8f3d5821ec5300de7466 (patch)
tree4a159b8170d555b55d034b683f0e5428a25e5a2c /meta
parent891dfba7a0b3f6f717bdb27a48ba724b6f50e0c3 (diff)
downloadpoky-058def277e0cd8e262ba8f3d5821ec5300de7466.tar.gz
go: Update reproducibility patch to fix panic errors
Based on a discussion on the mailing list [1], there are panic errors that occur on a few platforms caused by the patch. We cannot simply remove the original patch due to the reproducibility issues that it addresses, so this patch on the original patch fixes the cause of the panic errors. The previous version of this patch was a little too aggressive in cleaning up the environment. Some of the variables impacted by the filerCompilerFlags() function require at least one value to remain in the array. In this case, the values for ccExe, cxxExe, and fcExe require a value or later code that access them result in a panic related to accessing a value out of range. This updated patch adds a flag that requires keeping the first value so that at least one thing remains and the assignments for the Exes set that flag to true. The first item in the array should be the executable name, so leaving it should be safe. I have run the oe-selftest and everything passed in my setup. There is a bug report [2] filed for the issue that this patch addresses. [YOCTO #14976] [1] https://lists.openembedded.org/g/openembedded-core/topic/94022663 [2] https://bugzilla.yoctoproject.org/show_bug.cgi?id=14976 (From OE-Core rev: 9eaa3a813555dd016a65be63a258f9c0b548a115) Signed-off-by: Ryan Eatmon <reatmon@ti.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch30
1 files changed, 16 insertions, 14 deletions
diff --git a/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch b/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch
index 17fa9d9831..43be5cd2e8 100644
--- a/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch
+++ b/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch
@@ -74,7 +74,7 @@ index c88b315..a06455c 100644
74+ cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true) 74+ cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true)
75 75
76- ccExe := b.ccExe() 76- ccExe := b.ccExe()
77+ ccExe := filterCompilerFlags(b.ccExe()) 77+ ccExe := filterCompilerFlags(b.ccExe(), true)
78 fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags) 78 fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
79 // Include the C compiler tool ID so that if the C 79 // Include the C compiler tool ID so that if the C
80 // compiler changes we rebuild the package. 80 // compiler changes we rebuild the package.
@@ -83,7 +83,7 @@ index c88b315..a06455c 100644
83 } 83 }
84 if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 { 84 if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
85- cxxExe := b.cxxExe() 85- cxxExe := b.cxxExe()
86+ cxxExe := filterCompilerFlags(b.cxxExe()) 86+ cxxExe := filterCompilerFlags(b.cxxExe(), true)
87 fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags) 87 fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags)
88 if cxxID, err := b.gccToolID(cxxExe[0], "c++"); err == nil { 88 if cxxID, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
89 fmt.Fprintf(h, "CXX ID=%q\n", cxxID) 89 fmt.Fprintf(h, "CXX ID=%q\n", cxxID)
@@ -91,7 +91,7 @@ index c88b315..a06455c 100644
91 } 91 }
92 if len(p.FFiles) > 0 { 92 if len(p.FFiles) > 0 {
93- fcExe := b.fcExe() 93- fcExe := b.fcExe()
94+ fcExe := filterCompilerFlags(b.fcExe()) 94+ fcExe := filterCompilerFlags(b.fcExe(), true)
95 fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags) 95 fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags)
96 if fcID, err := b.gccToolID(fcExe[0], "f95"); err == nil { 96 if fcID, err := b.gccToolID(fcExe[0], "f95"); err == nil {
97 fmt.Fprintf(h, "FC ID=%q\n", fcID) 97 fmt.Fprintf(h, "FC ID=%q\n", fcID)
@@ -104,20 +104,22 @@ index c88b315..a06455c 100644
104 } 104 }
105 105
106 // Configuration specific to compiler toolchain. 106 // Configuration specific to compiler toolchain.
107@@ -2705,8 +2707,23 @@ func envList(key, def string) []string { 107@@ -2705,8 +2707,25 @@ func envList(key, def string) []string {
108 return args 108 return args
109 } 109 }
110 110
111+var filterFlags = os.Getenv("CGO_PEDANTIC") == "" 111+var filterFlags = os.Getenv("CGO_PEDANTIC") == ""
112+ 112+
113+func filterCompilerFlags(flags []string) []string { 113+func filterCompilerFlags(flags []string, keepfirst bool) []string {
114+ var newflags []string 114+ var newflags []string
115+ var realkeepfirst bool = keepfirst
115+ if !filterFlags { 116+ if !filterFlags {
116+ return flags 117+ return flags
117+ } 118+ }
118+ for _, flag := range flags { 119+ for _, flag := range flags {
119+ if strings.HasPrefix(flag, "-m") { 120+ if strings.HasPrefix(flag, "-m") || realkeepfirst {
120+ newflags = append(newflags, flag) 121+ newflags = append(newflags, flag)
122+ realkeepfirst = false
121+ } 123+ }
122+ } 124+ }
123+ return newflags 125+ return newflags
@@ -129,21 +131,21 @@ index c88b315..a06455c 100644
129 defaults := "-g -O2" 131 defaults := "-g -O2"
130 132
131 if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil { 133 if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
132@@ -2724,6 +2741,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l 134@@ -2724,6 +2743,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
133 if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil { 135 if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
134 return 136 return
135 } 137 }
136+ if filtered { 138+ if filtered {
137+ cppflags = filterCompilerFlags(cppflags) 139+ cppflags = filterCompilerFlags(cppflags, false)
138+ cflags = filterCompilerFlags(cflags) 140+ cflags = filterCompilerFlags(cflags, false)
139+ cxxflags = filterCompilerFlags(cxxflags) 141+ cxxflags = filterCompilerFlags(cxxflags, false)
140+ fflags = filterCompilerFlags(fflags) 142+ fflags = filterCompilerFlags(fflags, false)
141+ ldflags = filterCompilerFlags(ldflags) 143+ ldflags = filterCompilerFlags(ldflags, false)
142+ } 144+ }
143 145
144 return 146 return
145 } 147 }
146@@ -2739,7 +2763,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`) 148@@ -2739,7 +2765,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
147 149
148 func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) { 150 func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) {
149 p := a.Package 151 p := a.Package
@@ -152,7 +154,7 @@ index c88b315..a06455c 100644
152 if err != nil { 154 if err != nil {
153 return nil, nil, err 155 return nil, nil, err
154 } 156 }
155@@ -3246,7 +3270,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) { 157@@ -3246,7 +3272,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
156 158
157 // Run SWIG on one SWIG input file. 159 // Run SWIG on one SWIG input file.
158 func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) { 160 func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) {