]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: show output from failed compiler execution
authorRuss Cox <rsc@golang.org>
Thu, 17 Dec 2015 02:09:03 +0000 (21:09 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 17 Dec 2015 03:14:11 +0000 (03:14 +0000)
Maybe it will say something that helps the user understand the problem.

Note that we can't use os/exec.ExitError's new Stderr field because
cmd/dist is compiled with Go 1.4.

Fixes #13099.

Change-Id: I4b5910434bf324d1b85107002a64684d8ba14dc8
Reviewed-on: https://go-review.googlesource.com/17940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/dist/build.go

index 54e3fdf0409159241d1d6bd61a3014c44a66a0ad..634c52c3b0fe554fab7ef18de9a626849ea81bb5 100644 (file)
@@ -1102,11 +1102,15 @@ func checkCC() {
        if !needCC() {
                return
        }
-       if _, err := exec.Command(defaultcc, "--help").Output(); err != nil {
+       if output, err := exec.Command(defaultcc, "--help").CombinedOutput(); err != nil {
+               outputHdr := ""
+               if len(output) > 0 {
+                       outputHdr = "\nCommand output:\n\n"
+               }
                fatal("cannot invoke C compiler %q: %v\n\n"+
                        "Go needs a system C compiler for use with cgo.\n"+
                        "To set a C compiler, export CC=the-compiler.\n"+
-                       "To disable cgo, export CGO_ENABLED=0.\n", defaultcc, err)
+                       "To disable cgo, export CGO_ENABLED=0.\n%s%s", defaultcc, err, outputHdr, output)
        }
 }