Skip to contentSkip to conversation

go: Update patch due to build errors

PATCH In review Ryan Eatmon 3 participants 6 messages Nov 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 go: Update patch due to build errors

The previous version of this patch was a little too zealous in cleaning up the envvironment. Some of the variable 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 it results in a panic related to accessing a value out of range.

The 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 compiler name anyway so it should remain.

---
 ...ent-based-hash-generation-less-pedan.patch | 30 ++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)
meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch +16 -14
index 17fa9d9831..43be5cd2e8 100644
@@ -74,7 +74,7 @@ index c88b315..a06455c 100644
 +		cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true)
  
 -		ccExe := b.ccExe()
-+		ccExe := filterCompilerFlags(b.ccExe())
++		ccExe := filterCompilerFlags(b.ccExe(), true)
  		fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
  		// Include the C compiler tool ID so that if the C
  		// compiler changes we rebuild the package.
@@ -83,7 +83,7 @@ index c88b315..a06455c 100644
  		}
  		if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
 -			cxxExe := b.cxxExe()
-+			cxxExe := filterCompilerFlags(b.cxxExe())
++			cxxExe := filterCompilerFlags(b.cxxExe(), true)
  			fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags)
  			if cxxID, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
  				fmt.Fprintf(h, "CXX ID=%q\n", cxxID)
@@ -91,7 +91,7 @@ index c88b315..a06455c 100644
  		}
  		if len(p.FFiles) > 0 {
 -			fcExe := b.fcExe()
-+			fcExe := filterCompilerFlags(b.fcExe())
++			fcExe := filterCompilerFlags(b.fcExe(), true)
  			fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags)
  			if fcID, err := b.gccToolID(fcExe[0], "f95"); err == nil {
  				fmt.Fprintf(h, "FC ID=%q\n", fcID)
@@ -104,20 +104,22 @@ index c88b315..a06455c 100644
  	}
  
  	// Configuration specific to compiler toolchain.
-@@ -2705,8 +2707,23 @@ func envList(key, def string) []string {
+@@ -2705,8 +2707,25 @@ func envList(key, def string) []string {
  	return args
  }
  
 +var filterFlags = os.Getenv("CGO_PEDANTIC") == ""
 +
-+func filterCompilerFlags(flags []string) []string {
++func filterCompilerFlags(flags []string, keepfirst bool) []string {
 +	var newflags []string
++   var realkeepfirst bool = keepfirst
 +	if !filterFlags {
 +		return flags
 +	}
 +	for _, flag := range flags {
-+		if strings.HasPrefix(flag, "-m") {
++		if strings.HasPrefix(flag, "-m") || realkeepfirst {
 +			newflags = append(newflags, flag)
++           realkeepfirst = false
 +		}
 +	}
 +	return newflags
@@ -129,21 +131,21 @@ index c88b315..a06455c 100644
  	defaults := "-g -O2"
  
  	if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
-@@ -2724,6 +2741,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
+@@ -2724,6 +2743,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
  	if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
  		return
  	}
 +	if filtered {
-+		cppflags = filterCompilerFlags(cppflags)
-+		cflags = filterCompilerFlags(cflags)
-+		cxxflags = filterCompilerFlags(cxxflags)
-+		fflags = filterCompilerFlags(fflags)
-+		ldflags = filterCompilerFlags(ldflags)
++		cppflags = filterCompilerFlags(cppflags, false)
++		cflags = filterCompilerFlags(cflags, false)
++		cxxflags = filterCompilerFlags(cxxflags, false)
++		fflags = filterCompilerFlags(fflags, false)
++		ldflags = filterCompilerFlags(ldflags, false)
 +	}
  
  	return
  }
-@@ -2739,7 +2763,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
+@@ -2739,7 +2765,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
  
  func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) {
  	p := a.Package
@@ -152,7 +154,7 @@ index c88b315..a06455c 100644
  	if err != nil {
  		return nil, nil, err
  	}
-@@ -3246,7 +3270,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
+@@ -3246,7 +3272,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
  
  // Run SWIG on one SWIG input file.
  func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) {
Signature · 1 line
2.17.1
#1 lore raw

What build errors is this addressing and how can they be observed?

Alex

Quoted 125 lines · Ryan Eatmon via lists.openembedded.org

The previous version of this patch was a little too zealous in cleaning up the envvironment. Some of the variable 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 it results in a panic related to accessing a value out of range.

The 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 compiler name anyway so it should remain.

---
 ...ent-based-hash-generation-less-pedan.patch | 30 ++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)
meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch +16 -15
index 17fa9d9831..43be5cd2e8 100644
@@ -74,7 +74,7 @@ index c88b315..a06455c 100644
 +              cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true)
 
 -              ccExe := b.ccExe()
-+              ccExe := filterCompilerFlags(b.ccExe())
++              ccExe := filterCompilerFlags(b.ccExe(), true)
                fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
                // Include the C compiler tool ID so that if the C
                // compiler changes we rebuild the package.
@@ -83,7 +83,7 @@ index c88b315..a06455c 100644
                }
                if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
 -                      cxxExe := b.cxxExe()
-+                      cxxExe := filterCompilerFlags(b.cxxExe())
++                      cxxExe := filterCompilerFlags(b.cxxExe(), true)
                        fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags)
                        if cxxID, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
                                fmt.Fprintf(h, "CXX ID=%q\n", cxxID)
@@ -91,7 +91,7 @@ index c88b315..a06455c 100644
                }
                if len(p.FFiles) > 0 {
 -                      fcExe := b.fcExe()
-+                      fcExe := filterCompilerFlags(b.fcExe())
++                      fcExe := filterCompilerFlags(b.fcExe(), true)
                        fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags)
                        if fcID, err := b.gccToolID(fcExe[0], "f95"); err == nil {
                                fmt.Fprintf(h, "FC ID=%q\n", fcID)
@@ -104,20 +104,22 @@ index c88b315..a06455c 100644
        }
 
        // Configuration specific to compiler toolchain.
-@@ -2705,8 +2707,23 @@ func envList(key, def string) []string {
+@@ -2705,8 +2707,25 @@ func envList(key, def string) []string {
        return args
  }
 
 +var filterFlags = os.Getenv("CGO_PEDANTIC") == ""
 +
-+func filterCompilerFlags(flags []string) []string {
++func filterCompilerFlags(flags []string, keepfirst bool) []string {
 +      var newflags []string
++   var realkeepfirst bool = keepfirst
 +      if !filterFlags {
 +              return flags
 +      }
 +      for _, flag := range flags {
-+              if strings.HasPrefix(flag, "-m") {
++              if strings.HasPrefix(flag, "-m") || realkeepfirst {
 +                      newflags = append(newflags, flag)
++           realkeepfirst = false
 +              }
 +      }
 +      return newflags
@@ -129,21 +131,21 @@ index c88b315..a06455c 100644
        defaults := "-g -O2"
 
        if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
-@@ -2724,6 +2741,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
+@@ -2724,6 +2743,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
        if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
                return
        }
 +      if filtered {
-+              cppflags = filterCompilerFlags(cppflags)
-+              cflags = filterCompilerFlags(cflags)
-+              cxxflags = filterCompilerFlags(cxxflags)
-+              fflags = filterCompilerFlags(fflags)
-+              ldflags = filterCompilerFlags(ldflags)
++              cppflags = filterCompilerFlags(cppflags, false)
++              cflags = filterCompilerFlags(cflags, false)
++              cxxflags = filterCompilerFlags(cxxflags, false)
++              fflags = filterCompilerFlags(fflags, false)
++              ldflags = filterCompilerFlags(ldflags, false)
 +      }
 
        return
  }
-@@ -2739,7 +2763,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
+@@ -2739,7 +2765,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
 
  func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) {
        p := a.Package
@@ -152,7 +154,7 @@ index c88b315..a06455c 100644
        if err != nil {
                return nil, nil, err
        }
-@@ -3246,7 +3270,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
+@@ -3246,7 +3272,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
 
  // Run SWIG on one SWIG input file.
  func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) {
--

2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#173944): https://lists.openembedded.org/g/openembedded-core/message/173944
Mute This Topic: https://lists.openembedded.org/mt/95320460/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

Apologies. I'll happily submit a patch v2 that further explains it if we want to move forward with this patch.

There was a discussion back in September related to some of the TI machines and the riscv64 machine failing with a panic on recipes in meta-virtualization that use go.

https://lists.openembedded.org/g/openembedded-core/topic/94022663

I'm seeing these panics as well as I start testing the meta-ti/meta-arago layers against master so I need to figure it out.

That discussion was trying to just remove the offending patch but there was a lot of concern related to the reproducibility issue that the patch was addressing. So I took the time to understand why the panic was occurring when this patch was in place and updated the patch to *hopefully* address them both.

This patch needs to be tested to make sure that reproducibility issue is still working.

Quoted 131 lines · Alexander Kanavin

What build errors is this addressing and how can they be observed?

Alex

Quoted 125 lines · Ryan Eatmon via lists.openembedded.org

The previous version of this patch was a little too zealous in cleaning up the envvironment. Some of the variable 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 it results in a panic related to accessing a value out of range.

The 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 compiler name anyway so it should remain.

---
  ...ent-based-hash-generation-less-pedan.patch | 30 ++++++++++---------
  1 file changed, 16 insertions(+), 14 deletions(-)
meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch +16 -15
index 17fa9d9831..43be5cd2e8 100644
@@ -74,7 +74,7 @@ index c88b315..a06455c 100644
  +              cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true)
 
  -              ccExe := b.ccExe()
-+              ccExe := filterCompilerFlags(b.ccExe())
++              ccExe := filterCompilerFlags(b.ccExe(), true)
                 fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
                 // Include the C compiler tool ID so that if the C
                 // compiler changes we rebuild the package.
@@ -83,7 +83,7 @@ index c88b315..a06455c 100644
                 }
                 if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
  -                      cxxExe := b.cxxExe()
-+                      cxxExe := filterCompilerFlags(b.cxxExe())
++                      cxxExe := filterCompilerFlags(b.cxxExe(), true)
                         fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags)
                         if cxxID, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
                                 fmt.Fprintf(h, "CXX ID=%q\n", cxxID)
@@ -91,7 +91,7 @@ index c88b315..a06455c 100644
                 }
                 if len(p.FFiles) > 0 {
  -                      fcExe := b.fcExe()
-+                      fcExe := filterCompilerFlags(b.fcExe())
++                      fcExe := filterCompilerFlags(b.fcExe(), true)
                         fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags)
                         if fcID, err := b.gccToolID(fcExe[0], "f95"); err == nil {
                                 fmt.Fprintf(h, "FC ID=%q\n", fcID)
@@ -104,20 +104,22 @@ index c88b315..a06455c 100644
         }
 
         // Configuration specific to compiler toolchain.
-@@ -2705,8 +2707,23 @@ func envList(key, def string) []string {
+@@ -2705,8 +2707,25 @@ func envList(key, def string) []string {
         return args
   }
 
  +var filterFlags = os.Getenv("CGO_PEDANTIC") == ""
  +
-+func filterCompilerFlags(flags []string) []string {
++func filterCompilerFlags(flags []string, keepfirst bool) []string {
  +      var newflags []string
++   var realkeepfirst bool = keepfirst
  +      if !filterFlags {
  +              return flags
  +      }
  +      for _, flag := range flags {
-+              if strings.HasPrefix(flag, "-m") {
++              if strings.HasPrefix(flag, "-m") || realkeepfirst {
  +                      newflags = append(newflags, flag)
++           realkeepfirst = false
  +              }
  +      }
  +      return newflags
@@ -129,21 +131,21 @@ index c88b315..a06455c 100644
         defaults := "-g -O2"
 
         if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
-@@ -2724,6 +2741,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
+@@ -2724,6 +2743,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
         if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
                 return
         }
  +      if filtered {
-+              cppflags = filterCompilerFlags(cppflags)
-+              cflags = filterCompilerFlags(cflags)
-+              cxxflags = filterCompilerFlags(cxxflags)
-+              fflags = filterCompilerFlags(fflags)
-+              ldflags = filterCompilerFlags(ldflags)
++              cppflags = filterCompilerFlags(cppflags, false)
++              cflags = filterCompilerFlags(cflags, false)
++              cxxflags = filterCompilerFlags(cxxflags, false)
++              fflags = filterCompilerFlags(fflags, false)
++              ldflags = filterCompilerFlags(ldflags, false)
  +      }
 
         return
   }
-@@ -2739,7 +2763,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
+@@ -2739,7 +2765,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
 
   func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) {
         p := a.Package
@@ -152,7 +154,7 @@ index c88b315..a06455c 100644
         if err != nil {
                 return nil, nil, err
         }
-@@ -3246,7 +3270,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
+@@ -3246,7 +3272,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
 
   // Run SWIG on one SWIG input file.
   func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) {
--

2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#173944): https://lists.openembedded.org/g/openembedded-core/message/173944
Mute This Topic: https://lists.openembedded.org/mt/95320460/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
Ryan Eatmon                [email protected]
-----------------------------------------
Texas Instruments, Inc.  -  LCPD  -  MGTS
#3 lore raw
In reply to Alexander Kanavin
Quoted 1 line · Alexander Kanavin

What build errors is this addressing and how can they be observed?

https://bugzilla.yoctoproject.org/show_bug.cgi?id=14976

Quoted 121 lines
Quoted 119 lines · Ryan Eatmon via lists.openembedded.org

The previous version of this patch was a little too zealous in cleaning up the envvironment. Some of the variable 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 it results in a panic related to accessing a value out of range.

The 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 compiler name anyway so it should remain.

---
 ...ent-based-hash-generation-less-pedan.patch | 30 ++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)
meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch +16 -15
index 17fa9d9831..43be5cd2e8 100644
@@ -74,7 +74,7 @@ index c88b315..a06455c 100644
 +              cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true)
 
 -              ccExe := b.ccExe()
-+              ccExe := filterCompilerFlags(b.ccExe())
++              ccExe := filterCompilerFlags(b.ccExe(), true)
                fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
                // Include the C compiler tool ID so that if the C
                // compiler changes we rebuild the package.
@@ -83,7 +83,7 @@ index c88b315..a06455c 100644
                }
                if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
 -                      cxxExe := b.cxxExe()
-+                      cxxExe := filterCompilerFlags(b.cxxExe())
++                      cxxExe := filterCompilerFlags(b.cxxExe(), true)
                        fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags)
                        if cxxID, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
                                fmt.Fprintf(h, "CXX ID=%q\n", cxxID)
@@ -91,7 +91,7 @@ index c88b315..a06455c 100644
                }
                if len(p.FFiles) > 0 {
 -                      fcExe := b.fcExe()
-+                      fcExe := filterCompilerFlags(b.fcExe())
++                      fcExe := filterCompilerFlags(b.fcExe(), true)
                        fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags)
                        if fcID, err := b.gccToolID(fcExe[0], "f95"); err == nil {
                                fmt.Fprintf(h, "FC ID=%q\n", fcID)
@@ -104,20 +104,22 @@ index c88b315..a06455c 100644
        }
 
        // Configuration specific to compiler toolchain.
-@@ -2705,8 +2707,23 @@ func envList(key, def string) []string {
+@@ -2705,8 +2707,25 @@ func envList(key, def string) []string {
        return args
  }
 
 +var filterFlags = os.Getenv("CGO_PEDANTIC") == ""
 +
-+func filterCompilerFlags(flags []string) []string {
++func filterCompilerFlags(flags []string, keepfirst bool) []string {
 +      var newflags []string
++   var realkeepfirst bool = keepfirst
 +      if !filterFlags {
 +              return flags
 +      }
 +      for _, flag := range flags {
-+              if strings.HasPrefix(flag, "-m") {
++              if strings.HasPrefix(flag, "-m") || realkeepfirst {
 +                      newflags = append(newflags, flag)
++           realkeepfirst = false
 +              }
 +      }
 +      return newflags
@@ -129,21 +131,21 @@ index c88b315..a06455c 100644
        defaults := "-g -O2"
 
        if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
-@@ -2724,6 +2741,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
+@@ -2724,6 +2743,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
        if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
                return
        }
 +      if filtered {
-+              cppflags = filterCompilerFlags(cppflags)
-+              cflags = filterCompilerFlags(cflags)
-+              cxxflags = filterCompilerFlags(cxxflags)
-+              fflags = filterCompilerFlags(fflags)
-+              ldflags = filterCompilerFlags(ldflags)
++              cppflags = filterCompilerFlags(cppflags, false)
++              cflags = filterCompilerFlags(cflags, false)
++              cxxflags = filterCompilerFlags(cxxflags, false)
++              fflags = filterCompilerFlags(fflags, false)
++              ldflags = filterCompilerFlags(ldflags, false)
 +      }
 
        return
  }
-@@ -2739,7 +2763,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
+@@ -2739,7 +2765,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
 
  func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) {
        p := a.Package
@@ -152,7 +154,7 @@ index c88b315..a06455c 100644
        if err != nil {
                return nil, nil, err
        }
-@@ -3246,7 +3270,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
+@@ -3246,7 +3272,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
 
  // Run SWIG on one SWIG input file.
  func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) {
--

2.17.1

#4 lore raw

Ok then you need to place all of this and the bug link into the commit message, and then you can run the reproducibility test locally, no?

Alex

Quoted 137 lines · Denys Dmytriyenko
Quoted 1 line · Alexander Kanavin

What build errors is this addressing and how can they be observed?

https://bugzilla.yoctoproject.org/show_bug.cgi?id=14976

Quoted 113 lines
Quoted 111 lines · Ryan Eatmon via lists.openembedded.org

The previous version of this patch was a little too zealous in cleaning up the envvironment. Some of the variable 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 it results in a panic related to accessing a value out of range.

The 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 compiler name anyway so it should remain.

---
 ...ent-based-hash-generation-less-pedan.patch | 30 ++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)
meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch +16 -14
index 17fa9d9831..43be5cd2e8 100644
@@ -74,7 +74,7 @@ index c88b315..a06455c 100644
 +              cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true)
 
 -              ccExe := b.ccExe()
-+              ccExe := filterCompilerFlags(b.ccExe())
++              ccExe := filterCompilerFlags(b.ccExe(), true)
                fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
                // Include the C compiler tool ID so that if the C
                // compiler changes we rebuild the package.
@@ -83,7 +83,7 @@ index c88b315..a06455c 100644
                }
                if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
 -                      cxxExe := b.cxxExe()
-+                      cxxExe := filterCompilerFlags(b.cxxExe())
++                      cxxExe := filterCompilerFlags(b.cxxExe(), true)
                        fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags)
                        if cxxID, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
                                fmt.Fprintf(h, "CXX ID=%q\n", cxxID)
@@ -91,7 +91,7 @@ index c88b315..a06455c 100644
                }
                if len(p.FFiles) > 0 {
 -                      fcExe := b.fcExe()
-+                      fcExe := filterCompilerFlags(b.fcExe())
++                      fcExe := filterCompilerFlags(b.fcExe(), true)
                        fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags)
                        if fcID, err := b.gccToolID(fcExe[0], "f95"); err == nil {
                                fmt.Fprintf(h, "FC ID=%q\n", fcID)
@@ -104,20 +104,22 @@ index c88b315..a06455c 100644
        }
 
        // Configuration specific to compiler toolchain.
-@@ -2705,8 +2707,23 @@ func envList(key, def string) []string {
+@@ -2705,8 +2707,25 @@ func envList(key, def string) []string {
        return args
  }
 
 +var filterFlags = os.Getenv("CGO_PEDANTIC") == ""
 +
-+func filterCompilerFlags(flags []string) []string {
++func filterCompilerFlags(flags []string, keepfirst bool) []string {
 +      var newflags []string
++   var realkeepfirst bool = keepfirst
 +      if !filterFlags {
 +              return flags
 +      }
 +      for _, flag := range flags {
-+              if strings.HasPrefix(flag, "-m") {
++              if strings.HasPrefix(flag, "-m") || realkeepfirst {
 +                      newflags = append(newflags, flag)
++           realkeepfirst = false
 +              }
 +      }
 +      return newflags
@@ -129,21 +131,21 @@ index c88b315..a06455c 100644
        defaults := "-g -O2"
 
        if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
-@@ -2724,6 +2741,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
+@@ -2724,6 +2743,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
        if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
                return
        }
 +      if filtered {
-+              cppflags = filterCompilerFlags(cppflags)
-+              cflags = filterCompilerFlags(cflags)
-+              cxxflags = filterCompilerFlags(cxxflags)
-+              fflags = filterCompilerFlags(fflags)
-+              ldflags = filterCompilerFlags(ldflags)
++              cppflags = filterCompilerFlags(cppflags, false)
++              cflags = filterCompilerFlags(cflags, false)
++              cxxflags = filterCompilerFlags(cxxflags, false)
++              fflags = filterCompilerFlags(fflags, false)
++              ldflags = filterCompilerFlags(ldflags, false)
 +      }
 
        return
  }
-@@ -2739,7 +2763,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
+@@ -2739,7 +2765,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
 
  func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) {
        p := a.Package
@@ -152,7 +154,7 @@ index c88b315..a06455c 100644
        if err != nil {
                return nil, nil, err
        }
-@@ -3246,7 +3270,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
+@@ -3246,7 +3272,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
 
Quoted 8 lines
Quoted 8 lines
meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch +0 -1
  // Run SWIG on one SWIG input file.
  func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) {
--

2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#173949): https://lists.openembedded.org/g/openembedded-core/message/173949
Mute This Topic: https://lists.openembedded.org/mt/95320460/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#5 lore raw

Will do. Thanks.

Quoted 143 lines · Alexander Kanavin

Ok then you need to place all of this and the bug link into the commit message, and then you can run the reproducibility test locally, no?

Alex

Quoted 137 lines · Denys Dmytriyenko
Quoted 1 line · Alexander Kanavin

What build errors is this addressing and how can they be observed?

https://bugzilla.yoctoproject.org/show_bug.cgi?id=14976

Quoted 113 lines
Quoted 111 lines · Ryan Eatmon via lists.openembedded.org

The previous version of this patch was a little too zealous in cleaning up the envvironment. Some of the variable 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 it results in a panic related to accessing a value out of range.

The 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 compiler name anyway so it should remain.

---
  ...ent-based-hash-generation-less-pedan.patch | 30 ++++++++++---------
  1 file changed, 16 insertions(+), 14 deletions(-)
meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch +16 -14
index 17fa9d9831..43be5cd2e8 100644
@@ -74,7 +74,7 @@ index c88b315..a06455c 100644
  +              cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true)
 
  -              ccExe := b.ccExe()
-+              ccExe := filterCompilerFlags(b.ccExe())
++              ccExe := filterCompilerFlags(b.ccExe(), true)
                 fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
                 // Include the C compiler tool ID so that if the C
                 // compiler changes we rebuild the package.
@@ -83,7 +83,7 @@ index c88b315..a06455c 100644
                 }
                 if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
  -                      cxxExe := b.cxxExe()
-+                      cxxExe := filterCompilerFlags(b.cxxExe())
++                      cxxExe := filterCompilerFlags(b.cxxExe(), true)
                         fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags)
                         if cxxID, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
                                 fmt.Fprintf(h, "CXX ID=%q\n", cxxID)
@@ -91,7 +91,7 @@ index c88b315..a06455c 100644
                 }
                 if len(p.FFiles) > 0 {
  -                      fcExe := b.fcExe()
-+                      fcExe := filterCompilerFlags(b.fcExe())
++                      fcExe := filterCompilerFlags(b.fcExe(), true)
                         fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags)
                         if fcID, err := b.gccToolID(fcExe[0], "f95"); err == nil {
                                 fmt.Fprintf(h, "FC ID=%q\n", fcID)
@@ -104,20 +104,22 @@ index c88b315..a06455c 100644
         }
 
         // Configuration specific to compiler toolchain.
-@@ -2705,8 +2707,23 @@ func envList(key, def string) []string {
+@@ -2705,8 +2707,25 @@ func envList(key, def string) []string {
         return args
   }
 
  +var filterFlags = os.Getenv("CGO_PEDANTIC") == ""
  +
-+func filterCompilerFlags(flags []string) []string {
++func filterCompilerFlags(flags []string, keepfirst bool) []string {
  +      var newflags []string
++   var realkeepfirst bool = keepfirst
  +      if !filterFlags {
  +              return flags
  +      }
  +      for _, flag := range flags {
-+              if strings.HasPrefix(flag, "-m") {
++              if strings.HasPrefix(flag, "-m") || realkeepfirst {
  +                      newflags = append(newflags, flag)
++           realkeepfirst = false
  +              }
  +      }
  +      return newflags
@@ -129,21 +131,21 @@ index c88b315..a06455c 100644
         defaults := "-g -O2"
 
         if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
-@@ -2724,6 +2741,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
+@@ -2724,6 +2743,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
         if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
                 return
         }
  +      if filtered {
-+              cppflags = filterCompilerFlags(cppflags)
-+              cflags = filterCompilerFlags(cflags)
-+              cxxflags = filterCompilerFlags(cxxflags)
-+              fflags = filterCompilerFlags(fflags)
-+              ldflags = filterCompilerFlags(ldflags)
++              cppflags = filterCompilerFlags(cppflags, false)
++              cflags = filterCompilerFlags(cflags, false)
++              cxxflags = filterCompilerFlags(cxxflags, false)
++              fflags = filterCompilerFlags(fflags, false)
++              ldflags = filterCompilerFlags(ldflags, false)
  +      }
 
         return
   }
-@@ -2739,7 +2763,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
+@@ -2739,7 +2765,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
 
   func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) {
         p := a.Package
@@ -152,7 +154,7 @@ index c88b315..a06455c 100644
         if err != nil {
                 return nil, nil, err
         }
-@@ -3246,7 +3270,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
+@@ -3246,7 +3272,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
 
Quoted 8 lines
Quoted 8 lines
meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch +0 -1
   // Run SWIG on one SWIG input file.
   func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) {
--

2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#173949): https://lists.openembedded.org/g/openembedded-core/message/173949
Mute This Topic: https://lists.openembedded.org/mt/95320460/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
Ryan Eatmon                [email protected]
-----------------------------------------
Texas Instruments, Inc.  -  LCPD  -  MGTS