Skip to content

Commit 5f319b7

Browse files
committed
cmd/link: don't let dsymutil delete our temp directory
To work around #59026, where dsymutil may not clean up its temp directory at exit, we set DSYMUTIL_REPRODUCER_PATH to our temp directory so it uses that, and we can delete it at the end. In Xcode 16 beta, dsymutil deletes the DSYMUTIL_REPRODUCER_PATH directory even if it is not empty. We still need our tmpdir at the point, so give a subdirectory to dsymutil instead. For #68088. Change-Id: I18759cc39512819bbd0511793ce917eae72245d6 Reviewed-on: https://go-review.googlesource.com/c/go/+/593659 Reviewed-by: Than McIntosh <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent a2e90be commit 5f319b7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • src/cmd/link/internal/ld

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,15 @@ func (ctxt *Link) hostlink() {
20092009
cmd := exec.Command(dsymutilCmd, "-f", *flagOutfile, "-o", dsym)
20102010
// dsymutil may not clean up its temp directory at exit.
20112011
// Set DSYMUTIL_REPRODUCER_PATH to work around. see issue 59026.
2012-
cmd.Env = append(os.Environ(), "DSYMUTIL_REPRODUCER_PATH="+*flagTmpdir)
2012+
// dsymutil (Apple LLVM version 16.0.0) deletes the directory
2013+
// even if it is not empty. We still need our tmpdir, so give a
2014+
// subdirectory to dsymutil.
2015+
dsymDir := filepath.Join(*flagTmpdir, "dsymutil")
2016+
err := os.MkdirAll(dsymDir, 0777)
2017+
if err != nil {
2018+
Exitf("fail to create temp dir: %v", err)
2019+
}
2020+
cmd.Env = append(os.Environ(), "DSYMUTIL_REPRODUCER_PATH="+dsymDir)
20132021
if ctxt.Debugvlog != 0 {
20142022
ctxt.Logf("host link dsymutil:")
20152023
for _, v := range cmd.Args {

0 commit comments

Comments
 (0)