1
0
mirror of https://github.com/golang/go synced 2024-11-18 13:14:47 -07:00

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
This commit is contained in:
Russ Cox 2013-07-19 19:36:15 -04:00
parent c758841853
commit c485b58912
4 changed files with 14 additions and 1 deletions

View File

@ -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");
}

2
src/cmd/dist/unix.c vendored
View File

@ -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 = "/";

View File

@ -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")
}

View File

@ -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" {