diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 0219beeb10a..df838961008 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1874,9 +1874,10 @@ func (ctxt *Link) hostlink() { ctxt.Logf("\n") } - out, err := exec.Command(argv[0], argv[1:]...).CombinedOutput() + cmd := exec.Command(argv[0], argv[1:]...) + out, err := cmd.CombinedOutput() if err != nil { - Exitf("running %s failed: %v\n%s", argv[0], err, out) + Exitf("running %s failed: %v\n%s\n%s", argv[0], err, cmd, out) } // Filter out useless linker warnings caused by bugs outside Go. @@ -1959,7 +1960,7 @@ func (ctxt *Link) hostlink() { ctxt.Logf("\n") } if out, err := cmd.CombinedOutput(); err != nil { - Exitf("%s: running dsymutil failed: %v\n%s", os.Args[0], err, out) + Exitf("%s: running dsymutil failed: %v\n%s\n%s", os.Args[0], err, cmd, out) } // Remove STAB (symbolic debugging) symbols after we are done with them (by dsymutil). // They contain temporary file paths and make the build not reproducible. @@ -1978,8 +1979,9 @@ func (ctxt *Link) hostlink() { } ctxt.Logf("\n") } - if out, err := exec.Command(stripCmd, stripArgs...).CombinedOutput(); err != nil { - Exitf("%s: running strip failed: %v\n%s", os.Args[0], err, out) + cmd = exec.Command(stripCmd, stripArgs...) + if out, err := cmd.CombinedOutput(); err != nil { + Exitf("%s: running strip failed: %v\n%s\n%s", os.Args[0], err, cmd, out) } // Skip combining if `dsymutil` didn't generate a file. See #11994. if _, err := os.Stat(dsym); os.IsNotExist(err) {