]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: write combined dwarf file to same directory as output file
authorRuss Cox <rsc@golang.org>
Wed, 22 Jul 2015 22:02:52 +0000 (18:02 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 23 Jul 2015 03:52:20 +0000 (03:52 +0000)
Fixes #11681.

Change-Id: I679d71ed25ac585af7d43611be01c1a0c4807871
Reviewed-on: https://go-review.googlesource.com/12554
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/link/internal/ld/lib.go

index 74e4445b86c0b1f749357f593ffb6d1d53334d5b..bd0fbc567da79287fd6234015ea899bb76b9b603 100644 (file)
@@ -1083,16 +1083,16 @@ func hostlink() {
                                Ctxt.Cursym = nil
                                Exitf("%s: running dsymutil failed: %v\n%s", os.Args[0], err, out)
                        }
-                       combinedOutput := fmt.Sprintf("%s/go.combined", tmpdir)
+                       // For os.Rename to work reliably, must be in same directory as outfile.
+                       combinedOutput := outfile + "~"
                        if err := machoCombineDwarf(outfile, dsym, combinedOutput); err != nil {
                                Ctxt.Cursym = nil
                                Exitf("%s: combining dwarf failed: %v", os.Args[0], err)
                        }
-                       origOutput := fmt.Sprintf("%s/go.orig", tmpdir)
-                       os.Rename(outfile, origOutput)
+                       os.Remove(outfile)
                        if err := os.Rename(combinedOutput, outfile); err != nil {
                                Ctxt.Cursym = nil
-                               Exitf("%s: rename(%s, %s) failed: %v", os.Args[0], combinedOutput, outfile, err)
+                               Exitf("%s: %v", os.Args[0], err)
                        }
                }
        }