Skip to content

Commit

Permalink
cmd/dist, cmd/go: enable more warnings, make clang errors legible
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rsc committed Jul 19, 2013
1 parent c758841 commit c485b58
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/cmd/dist/build.c
Expand Up @@ -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",
Expand Down Expand Up @@ -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");
}
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/dist/unix.c
Expand Up @@ -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 = "/";
Expand Down
4 changes: 3 additions & 1 deletion src/cmd/go/build.go
Expand Up @@ -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")
}

Expand Down
3 changes: 3 additions & 0 deletions src/cmd/go/env.go
Expand Up @@ -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" {
Expand Down

0 comments on commit c485b58

Please sign in to comment.