This patch to libgo fixes a couple of small bugs in the go tool.

Pass the -fdebug-prefix-map and -gno-record-gcc-switches compiler
options to gccgo to generate consistent results.

Fix the vendoring code to look for /vendor/, not just /vendor, to
avoid being confused by something like vendor/vendor.org.

Tested by the cmd/go tests in a followup patch.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE     (revision 249197)
+++ gcc/go/gofrontend/MERGE     (working copy)
@@ -1,4 +1,4 @@
-6b08348d905bf84a91b8d693ee01b30e8bf18ccf
+bc785455a35bfa7d4b0a66781c7c3ef08a24a845
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/cmd/go/build.go
===================================================================
--- libgo/go/cmd/go/build.go    (revision 249125)
+++ libgo/go/cmd/go/build.go    (working copy)
@@ -2692,6 +2692,8 @@ func (tools gccgoToolchain) gc(b *builde
        ofile = obj + out
        gcargs := []string{"-g"}
        gcargs = append(gcargs, b.gccArchArgs()...)
+       gcargs = append(gcargs, "-fdebug-prefix-map="+b.work+"=/tmp/go-build")
+       gcargs = append(gcargs, "-gno-record-gcc-switches")
        if pkgpath := gccgoPkgpath(p); pkgpath != "" {
                gcargs = append(gcargs, "-fgo-pkgpath="+pkgpath)
        }
@@ -2707,14 +2709,14 @@ func (tools gccgoToolchain) gc(b *builde
 
        for _, path := range p.Imports {
                // If this is a new vendor path, add it to the list of 
importArgs
-               if i := strings.LastIndex(path, "/vendor"); i >= 0 {
+               if i := strings.LastIndex(path, "/vendor/"); i >= 0 {
                        for _, dir := range savedirs {
                                // Check if the vendor path is already included 
in dir
-                               if strings.HasSuffix(dir, 
path[:i+len("/vendor")]) {
+                               if strings.HasSuffix(dir, 
path[:i+len("/vendor/")]) {
                                        continue
                                }
                                // Make sure this vendor path is not already in 
the list for importArgs
-                               vendorPath := dir + "/" + 
path[:i+len("/vendor")]
+                               vendorPath := dir + "/" + 
path[:i+len("/vendor/")]
                                for _, imp := range importArgs {
                                        if imp == "-I" {
                                                continue
@@ -2788,7 +2790,12 @@ func (gccgoToolchain) pack(b *builder, p
        for _, f := range ofiles {
                absOfiles = append(absOfiles, mkAbs(objDir, f))
        }
-       return b.run(p.Dir, p.ImportPath, nil, "ar", "rc", mkAbs(objDir, 
afile), absOfiles)
+       absAfile := mkAbs(objDir, afile)
+       // Try with D modifier first, then without if that fails.
+       if b.run(p.Dir, p.ImportPath, nil, "ar", "rcD", absAfile, absOfiles) != 
nil {
+               return b.run(p.Dir, p.ImportPath, nil, "ar", "rc", absAfile, 
absOfiles)
+       }
+       return nil
 }
 
 func (tools gccgoToolchain) link(b *builder, root *action, out string, 
allactions []*action, mainpkg string, ofiles []string, buildmode, desc string) 
error {
@@ -3080,6 +3087,12 @@ func (tools gccgoToolchain) cc(b *builde
                defs = append(defs, "-fsplit-stack")
        }
        defs = tools.maybePIC(defs)
+       if b.gccSupportsFlag("-fdebug-prefix-map=a=b") {
+               defs = append(defs, 
"-fdebug-prefix-map="+b.work+"=/tmp/go-build")
+       }
+       if b.gccSupportsFlag("-gno-record-gcc-switches") {
+               defs = append(defs, "-gno-record-gcc-switches")
+       }
        return b.run(p.Dir, p.ImportPath, nil, envList("CC", defaultCC), 
"-Wall", "-g",
                "-I", objdir, "-I", inc, "-o", ofile, defs, "-c", cfile)
 }

Reply via email to