]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/go/internal/load/pkg.go
[dev.fuzz] all: merge master (d137b74) into dev.fuzz
[gostls13.git] / src / cmd / go / internal / load / pkg.go
index a3b96702ce52863c76fec052b8873f9c8b14bf2d..193a27a713b80abf55cbadcc81d06a0f3c0c94a0 100644 (file)
@@ -210,6 +210,7 @@ type PackageInternal struct {
        BuildInfo         string               // add this info to package main
        TestmainGo        *[]byte              // content for _testmain.go
        Embed             map[string][]string  // //go:embed comment mapping
+       FlagsSet          bool                 // whether the flags have been set
        OrigImportPath    string               // original import path before adding '_test' suffix
 
        Asmflags   []string // -asmflags for this package
@@ -2627,6 +2628,14 @@ func (e *mainPackageError) ImportPath() string {
 
 func setToolFlags(pkgs ...*Package) {
        for _, p := range PackageList(pkgs) {
+               // TODO(jayconrod,katiehockman): See if there's a better way to do this.
+               if p.Internal.FlagsSet {
+                       // The flags have already been set, so don't re-run this and
+                       // potentially clear existing flags.
+                       continue
+               } else {
+                       p.Internal.FlagsSet = true
+               }
                p.Internal.Asmflags = BuildAsmflags.For(p)
                p.Internal.Gcflags = BuildGcflags.For(p)
                p.Internal.Ldflags = BuildLdflags.For(p)