]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cmd/go: look for tool build ID before hashing entire file
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 10 Sep 2019 02:48:24 +0000 (02:48 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 10 Sep 2019 02:48:24 +0000 (02:48 +0000)
    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

gcc/go/gofrontend/MERGE
libgo/go/cmd/go/internal/work/buildid.go

index a762d6bf2f3999d3a77eca27517389644a2323d2..183dac5aae4551521d9dda3901675b40ff87e1a3 100644 (file)
@@ -1,4 +1,4 @@
-5c3f52ffbae7a9bb59bce63cd2cffdd8af8f4a92
+68038b4fdf1456482af986cb05dcf3121bd43ffc
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 1f6d1e8e779a3160165796e2adc9e43962cae690..5ff9337afec0ab4bc3aa1a8b9d3d3312abff9693 100644 (file)
@@ -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