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[] = {
// native Plan 9 compilers don't like non-standard prototypes
// so let gcc catch them.
"-Wstrict-prototypes",
"-Wextra",
"-Wunused",
"-Wuninitialized",
"-Wno-sign-compare",
"-Wno-missing-braces",
"-Wno-parentheses",
"-Wno-unknown-pragmas",
"-Wno-switch",
"-Wno-comment",
"-Wno-missing-field-initializers",
"-Werror",
"-fno-common",
"-ggdb",
......@@ -620,6 +624,8 @@ install(char *dir)
for(i=0; i<nelem(proto_gccargs); i++)
vadd(&gccargs, proto_gccargs[i]);
if(clang) {
// disable ASCII art in clang errors, if possible
vadd(&gccargs, "-fno-caret-diagnostics");
// clang is too smart about unused command-line arguments
vadd(&gccargs, "-Qunused-arguments");
}
......
......@@ -656,6 +656,8 @@ main(int argc, char **argv)
setvbuf(stdout, nil, _IOLBF, 0);
setvbuf(stderr, nil, _IOLBF, 0);
setenv("TERM", "dumb", 1); // disable escape codes in clang errors
binit(&b);
slash = "/";
......
......@@ -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") {
// 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")
}
......
......@@ -45,6 +45,9 @@ func mkEnv() []envVar {
{"GORACE", os.Getenv("GORACE")},
{"GOROOT", goroot},
{"GOTOOLDIR", toolDir},
// disable escape codes in clang errors
{"TERM", "dumb"},
}
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