aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-09-10 02:48:24 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-09-10 02:48:24 +0000
commitc96fc0812393c3e2744232c1f6e248776628397f (patch)
tree50a15ac8527d9faca731fd6589e21f35c950b300 /libgo
parent5447e8e2e249a12b0f22ccfb171ccc8fff9fcadc (diff)
downloadgcc-c96fc0812393c3e2744232c1f6e248776628397f.zip
gcc-c96fc0812393c3e2744232c1f6e248776628397f.tar.gz
gcc-c96fc0812393c3e2744232c1f6e248776628397f.tar.bz2
cmd/go: look for tool build ID before hashing entire file
Also fix the key used to store the ID. This is a significant speedup in cmd/go run time. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194257 From-SVN: r275559
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/cmd/go/internal/work/buildid.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/libgo/go/cmd/go/internal/work/buildid.go b/libgo/go/cmd/go/internal/work/buildid.go
index 1f6d1e8..5ff9337 100644
--- a/libgo/go/cmd/go/internal/work/buildid.go
+++ b/libgo/go/cmd/go/internal/work/buildid.go
@@ -291,14 +291,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