aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2023-05-01 12:47:15 -0400
committerCherry Mui <cherryyz@google.com>2023-05-02 12:54:03 +0000
commita9a01ea280892e69c3722eebbc60d14c17a77e8d (patch)
treeca0677d3a38dd85130f1c935d6350383ffaf6708 /src/cmd
parent3494a726009d049887bb3fb95181f71e07b21da3 (diff)
downloadgo-a9a01ea280892e69c3722eebbc60d14c17a77e8d.tar.xz
cmd/link: work around dsymutils not cleaning temp file
Some versions of dsymutils, notably the one in clang 14.0.3, which is shipped in some versions of Xcode, have a bug that it creates a temporary directory but doesn't clean it up at exit. The temporary directory is created in DSYMUTIL_REPRODUCER_PATH (if set, otherwise TMPDIR). Work around the issue by setting DSYMUTIL_REPRODUCER_PATH to the linker's temporary directory, so the linker will clean it up at exit anyway. Fixes #59026. Change-Id: Ie3e90a2d6a01f90040dc2eac91e8e536ccdda5a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/490818 Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/link/internal/ld/lib.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 5b6575b3fb..03b13da37a 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1905,7 +1905,11 @@ func (ctxt *Link) hostlink() {
stripCmd := strings.TrimSuffix(string(out), "\n")
dsym := filepath.Join(*flagTmpdir, "go.dwarf")
- if out, err := exec.Command(dsymutilCmd, "-f", *flagOutfile, "-o", dsym).CombinedOutput(); err != nil {
+ cmd := exec.Command(dsymutilCmd, "-f", *flagOutfile, "-o", dsym)
+ // dsymutil may not clean up its temp directory at exit.
+ // Set DSYMUTIL_REPRODUCER_PATH to work around. see issue 59026.
+ cmd.Env = append(os.Environ(), "DSYMUTIL_REPRODUCER_PATH="+*flagTmpdir)
+ if out, err := cmd.CombinedOutput(); err != nil {
Exitf("%s: running dsymutil failed: %v\n%s", os.Args[0], err, out)
}
// Remove STAB (symbolic debugging) symbols after we are done with them (by dsymutil).