Commit 1279f21f by Ian Lance Taylor

cmd/go: gccgo: consistent results, fix vendoring

    
    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 CL.
    
    Reviewed-on: https://go-review.googlesource.com/45695

From-SVN: r249198
parent 8ba20d7e
6b08348d905bf84a91b8d693ee01b30e8bf18ccf bc785455a35bfa7d4b0a66781c7c3ef08a24a845
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -2692,6 +2692,8 @@ func (tools gccgoToolchain) gc(b *builder, p *Package, archive, obj string, asmh ...@@ -2692,6 +2692,8 @@ func (tools gccgoToolchain) gc(b *builder, p *Package, archive, obj string, asmh
ofile = obj + out ofile = obj + out
gcargs := []string{"-g"} gcargs := []string{"-g"}
gcargs = append(gcargs, b.gccArchArgs()...) 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 != "" { if pkgpath := gccgoPkgpath(p); pkgpath != "" {
gcargs = append(gcargs, "-fgo-pkgpath="+pkgpath) gcargs = append(gcargs, "-fgo-pkgpath="+pkgpath)
} }
...@@ -2707,14 +2709,14 @@ func (tools gccgoToolchain) gc(b *builder, p *Package, archive, obj string, asmh ...@@ -2707,14 +2709,14 @@ func (tools gccgoToolchain) gc(b *builder, p *Package, archive, obj string, asmh
for _, path := range p.Imports { for _, path := range p.Imports {
// If this is a new vendor path, add it to the list of importArgs // 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 { for _, dir := range savedirs {
// Check if the vendor path is already included in dir // 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 continue
} }
// Make sure this vendor path is not already in the list for importArgs // 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 { for _, imp := range importArgs {
if imp == "-I" { if imp == "-I" {
continue continue
...@@ -2788,7 +2790,12 @@ func (gccgoToolchain) pack(b *builder, p *Package, objDir, afile string, ofiles ...@@ -2788,7 +2790,12 @@ func (gccgoToolchain) pack(b *builder, p *Package, objDir, afile string, ofiles
for _, f := range ofiles { for _, f := range ofiles {
absOfiles = append(absOfiles, mkAbs(objDir, f)) 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 { 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 *builder, p *Package, objdir, ofile, cfile stri ...@@ -3080,6 +3087,12 @@ func (tools gccgoToolchain) cc(b *builder, p *Package, objdir, ofile, cfile stri
defs = append(defs, "-fsplit-stack") defs = append(defs, "-fsplit-stack")
} }
defs = tools.maybePIC(defs) 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", return b.run(p.Dir, p.ImportPath, nil, envList("CC", defaultCC), "-Wall", "-g",
"-I", objdir, "-I", inc, "-o", ofile, defs, "-c", cfile) "-I", objdir, "-I", inc, "-o", ofile, defs, "-c", cfile)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment