Skip to content

Commit a9a01ea

Browse files
committed
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>
1 parent 3494a72 commit a9a01ea

File tree

1 file changed

+5
-1
lines changed
  • src/cmd/link/internal/ld

1 file changed

+5
-1
lines changed

src/cmd/link/internal/ld/lib.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,11 @@ func (ctxt *Link) hostlink() {
19051905
stripCmd := strings.TrimSuffix(string(out), "\n")
19061906

19071907
dsym := filepath.Join(*flagTmpdir, "go.dwarf")
1908-
if out, err := exec.Command(dsymutilCmd, "-f", *flagOutfile, "-o", dsym).CombinedOutput(); err != nil {
1908+
cmd := exec.Command(dsymutilCmd, "-f", *flagOutfile, "-o", dsym)
1909+
// dsymutil may not clean up its temp directory at exit.
1910+
// Set DSYMUTIL_REPRODUCER_PATH to work around. see issue 59026.
1911+
cmd.Env = append(os.Environ(), "DSYMUTIL_REPRODUCER_PATH="+*flagTmpdir)
1912+
if out, err := cmd.CombinedOutput(); err != nil {
19091913
Exitf("%s: running dsymutil failed: %v\n%s", os.Args[0], err, out)
19101914
}
19111915
// Remove STAB (symbolic debugging) symbols after we are done with them (by dsymutil).

0 commit comments

Comments
 (0)