From: Russ Cox Date: Thu, 17 Dec 2015 02:09:03 +0000 (-0500) Subject: cmd/dist: show output from failed compiler execution X-Git-Tag: go1.6beta1~39 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4378746a4b4160d5851d1daa68383a514aadad6f;p=gostls13.git cmd/dist: show output from failed compiler execution 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 --- diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 54e3fdf040..634c52c3b0 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -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) } }