Commit c485b589 authored by Russ Cox's avatar Russ Cox

cmd/dist, cmd/go: enable more warnings, make clang errors legible

This does not change the default compiler on OS X to clang.
It appears that for now we can keep using gcc as long as we
enable a few more warning settings that are on-by-default
elsewhere.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/11610044
parent c7588418
...@@ -407,12 +407,16 @@ static char *proto_gccargs[] = { ...@@ -407,12 +407,16 @@ static char *proto_gccargs[] = {
// native Plan 9 compilers don't like non-standard prototypes // native Plan 9 compilers don't like non-standard prototypes
// so let gcc catch them. // so let gcc catch them.
"-Wstrict-prototypes", "-Wstrict-prototypes",
"-Wextra",
"-Wunused",
"-Wuninitialized",
"-Wno-sign-compare", "-Wno-sign-compare",
"-Wno-missing-braces", "-Wno-missing-braces",
"-Wno-parentheses", "-Wno-parentheses",
"-Wno-unknown-pragmas", "-Wno-unknown-pragmas",
"-Wno-switch", "-Wno-switch",
"-Wno-comment", "-Wno-comment",
"-Wno-missing-field-initializers",
"-Werror", "-Werror",
"-fno-common", "-fno-common",
"-ggdb", "-ggdb",
...@@ -620,6 +624,8 @@ install(char *dir) ...@@ -620,6 +624,8 @@ install(char *dir)
for(i=0; i<nelem(proto_gccargs); i++) for(i=0; i<nelem(proto_gccargs); i++)
vadd(&gccargs, proto_gccargs[i]); vadd(&gccargs, proto_gccargs[i]);
if(clang) { if(clang) {
// disable ASCII art in clang errors, if possible
vadd(&gccargs, "-fno-caret-diagnostics");
// clang is too smart about unused command-line arguments // clang is too smart about unused command-line arguments
vadd(&gccargs, "-Qunused-arguments"); vadd(&gccargs, "-Qunused-arguments");
} }
......
...@@ -656,6 +656,8 @@ main(int argc, char **argv) ...@@ -656,6 +656,8 @@ main(int argc, char **argv)
setvbuf(stdout, nil, _IOLBF, 0); setvbuf(stdout, nil, _IOLBF, 0);
setvbuf(stderr, nil, _IOLBF, 0); setvbuf(stderr, nil, _IOLBF, 0);
setenv("TERM", "dumb", 1); // disable escape codes in clang errors
binit(&b); binit(&b);
slash = "/"; slash = "/";
......
...@@ -1811,8 +1811,10 @@ func (b *builder) ccompilerCmd(envvar, defcmd, objdir string) []string { ...@@ -1811,8 +1811,10 @@ func (b *builder) ccompilerCmd(envvar, defcmd, objdir string) []string {
} }
} }
// clang is too smart about command-line arguments
if strings.Contains(a[0], "clang") { if strings.Contains(a[0], "clang") {
// disable ASCII art in clang errors, if possible
a = append(a, "-fno-caret-diagnostics")
// clang is too smart about command-line arguments
a = append(a, "-Qunused-arguments") a = append(a, "-Qunused-arguments")
} }
......
...@@ -45,6 +45,9 @@ func mkEnv() []envVar { ...@@ -45,6 +45,9 @@ func mkEnv() []envVar {
{"GORACE", os.Getenv("GORACE")}, {"GORACE", os.Getenv("GORACE")},
{"GOROOT", goroot}, {"GOROOT", goroot},
{"GOTOOLDIR", toolDir}, {"GOTOOLDIR", toolDir},
// disable escape codes in clang errors
{"TERM", "dumb"},
} }
if goos != "plan9" { if goos != "plan9" {
......
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