aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-12-16 21:09:03 -0500
committerRuss Cox <rsc@golang.org>2015-12-17 03:14:11 +0000
commit4378746a4b4160d5851d1daa68383a514aadad6f (patch)
tree23575c9b12bfcb389def356f9e9fd6488e20fece
parentfcbf04f9b93b4cd8addd05c2ed784118eb50a46c (diff)
downloadgo-4378746a4b4160d5851d1daa68383a514aadad6f.tar.gz
go-4378746a4b4160d5851d1daa68383a514aadad6f.zip
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 <bradfitz@golang.org>
-rw-r--r--src/cmd/dist/build.go8
1 files changed, 6 insertions, 2 deletions
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)
}
}