Commit 4378746a authored by Russ Cox's avatar Russ Cox

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/17940Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent fcbf04f9
......@@ -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)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment