]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: trim objdir, not just workdir, from object files
authorRuss Cox <rsc@golang.org>
Tue, 31 Oct 2017 19:14:49 +0000 (15:14 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 31 Oct 2017 23:49:28 +0000 (23:49 +0000)
Otherwise the new numbered directories like b028/ appear in the objects,
and they can change from run to run.

Fixes #22514.

Change-Id: I8d0cf65f3622e48b2547d5757febe0ee1301e2ed
Reviewed-on: https://go-review.googlesource.com/74791
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/cmd/go/internal/work/gc.go
src/runtime/race/output_test.go

index e76f9ba7985f2926807bd93d1633e39c540be316..651d20c21c57197333e81796267522892684b598 100644 (file)
@@ -106,7 +106,7 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, a
                }
        }
 
-       args := []interface{}{cfg.BuildToolexec, base.Tool("compile"), "-o", ofile, "-trimpath", b.WorkDir, gcflags, gcargs, "-D", p.Internal.LocalPrefix}
+       args := []interface{}{cfg.BuildToolexec, base.Tool("compile"), "-o", ofile, "-trimpath", trimDir(a.Objdir), gcflags, gcargs, "-D", p.Internal.LocalPrefix}
        if importcfg != nil {
                if err := b.writeFile(objdir+"importcfg", importcfg); err != nil {
                        return "", nil, err
@@ -204,11 +204,18 @@ CheckFlags:
        return c
 }
 
+func trimDir(dir string) string {
+       if len(dir) > 1 && dir[len(dir)-1] == filepath.Separator {
+               dir = dir[:len(dir)-1]
+       }
+       return dir
+}
+
 func (gcToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error) {
        p := a.Package
        // Add -I pkg/GOOS_GOARCH so #include "textflag.h" works in .s files.
        inc := filepath.Join(cfg.GOROOT, "pkg", "include")
-       args := []interface{}{cfg.BuildToolexec, base.Tool("asm"), "-trimpath", b.WorkDir, "-I", a.Objdir, "-I", inc, "-D", "GOOS_" + cfg.Goos, "-D", "GOARCH_" + cfg.Goarch, buildAsmflags}
+       args := []interface{}{cfg.BuildToolexec, base.Tool("asm"), "-trimpath", trimDir(a.Objdir), "-I", a.Objdir, "-I", inc, "-D", "GOOS_" + cfg.Goos, "-D", "GOARCH_" + cfg.Goarch, buildAsmflags}
        if p.ImportPath == "runtime" && cfg.Goarch == "386" {
                for _, arg := range buildAsmflags {
                        if arg == "-dynlink" {
index f5b6fea43e48ea392cfcaa4bddf61f5d01571fdf..ee6bf6b035c318fc1bfb5d59698f0e50cd0e80e4 100644 (file)
@@ -263,7 +263,7 @@ Previous write at 0x[0-9,a-f]+ by goroutine [0-9]:
   main\.goCallback\(\)
       .*/main\.go:27 \+0x[0-9,a-f]+
   main._cgoexpwrap_[0-9a-z]+_goCallback\(\)
-      .*/_cgo_gotypes\.go:[0-9]+ \+0x[0-9,a-f]+
+      .*_cgo_gotypes\.go:[0-9]+ \+0x[0-9,a-f]+
 
 Goroutine [0-9] \(running\) created at:
   runtime\.newextram\(\)