]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: print failed external command invocation
authorCherry Mui <cherryyz@google.com>
Fri, 26 Jan 2024 17:08:00 +0000 (12:08 -0500)
committerCherry Mui <cherryyz@google.com>
Fri, 26 Jan 2024 19:03:08 +0000 (19:03 +0000)
When the invocation of the external linker, dsymutil or strip
command fails, print the command we invoked.

For #65292.

Change-Id: Icdb5f9ee942ebda4276f6373c3fbbf5222088d0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/558856
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/cmd/link/internal/ld/lib.go

index 0219beeb10a05c62a0fb8f93b94ef19f459594e3..df83896100872f9065acc5b8f951c7f6d9bf1fae 100644 (file)
@@ -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) {