]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: for gccgo, look for tool build ID before hashing entire file
authorIan Lance Taylor <iant@golang.org>
Tue, 10 Sep 2019 02:54:41 +0000 (19:54 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 10 Sep 2019 14:25:46 +0000 (14:25 +0000)
Also fix the key used to store the ID.

This is a significant speedup in cmd/go run time when using an
unreleased toolchain. For example, the TestGoBuildTestOnly cmd/go test
goes from 15 seconds to 1 second.

Change-Id: Ibfd697d55084db059c6b563f70f71f635e935391
Reviewed-on: https://go-review.googlesource.com/c/go/+/194441
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/work/buildid.go

index bf485d75adceb586046b886486807bf9cae6b8ee..27bde8c6151e4a8df31173563ccfe1d2c8d42a53 100644 (file)
@@ -292,14 +292,19 @@ func (b *Builder) gccgoToolID(name, language string) (string, error) {
                                exe = lp
                        }
                }
-               if _, err := os.Stat(exe); err != nil {
-                       return "", fmt.Errorf("%s: can not find compiler %q: %v; output %q", name, exe, err, out)
+               id, err = buildid.ReadFile(exe)
+               if err != nil {
+                       return "", err
+               }
+
+               // If we can't find a build ID, use a hash.
+               if id == "" {
+                       id = b.fileHash(exe)
                }
-               id = b.fileHash(exe)
        }
 
        b.id.Lock()
-       b.toolIDCache[name] = id
+       b.toolIDCache[key] = id
        b.id.Unlock()
 
        return id, nil