Skip to content

Commit c485b58

Browse files
committed
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
1 parent c758841 commit c485b58

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

src/cmd/dist/build.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,16 @@ static char *proto_gccargs[] = {
407407
// native Plan 9 compilers don't like non-standard prototypes
408408
// so let gcc catch them.
409409
"-Wstrict-prototypes",
410+
"-Wextra",
411+
"-Wunused",
412+
"-Wuninitialized",
410413
"-Wno-sign-compare",
411414
"-Wno-missing-braces",
412415
"-Wno-parentheses",
413416
"-Wno-unknown-pragmas",
414417
"-Wno-switch",
415418
"-Wno-comment",
419+
"-Wno-missing-field-initializers",
416420
"-Werror",
417421
"-fno-common",
418422
"-ggdb",
@@ -620,6 +624,8 @@ install(char *dir)
620624
for(i=0; i<nelem(proto_gccargs); i++)
621625
vadd(&gccargs, proto_gccargs[i]);
622626
if(clang) {
627+
// disable ASCII art in clang errors, if possible
628+
vadd(&gccargs, "-fno-caret-diagnostics");
623629
// clang is too smart about unused command-line arguments
624630
vadd(&gccargs, "-Qunused-arguments");
625631
}

src/cmd/dist/unix.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,8 @@ main(int argc, char **argv)
656656
setvbuf(stdout, nil, _IOLBF, 0);
657657
setvbuf(stderr, nil, _IOLBF, 0);
658658

659+
setenv("TERM", "dumb", 1); // disable escape codes in clang errors
660+
659661
binit(&b);
660662

661663
slash = "/";

src/cmd/go/build.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1811,8 +1811,10 @@ func (b *builder) ccompilerCmd(envvar, defcmd, objdir string) []string {
18111811
}
18121812
}
18131813

1814-
// clang is too smart about command-line arguments
18151814
if strings.Contains(a[0], "clang") {
1815+
// disable ASCII art in clang errors, if possible
1816+
a = append(a, "-fno-caret-diagnostics")
1817+
// clang is too smart about command-line arguments
18161818
a = append(a, "-Qunused-arguments")
18171819
}
18181820

src/cmd/go/env.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ func mkEnv() []envVar {
4545
{"GORACE", os.Getenv("GORACE")},
4646
{"GOROOT", goroot},
4747
{"GOTOOLDIR", toolDir},
48+
49+
// disable escape codes in clang errors
50+
{"TERM", "dumb"},
4851
}
4952

5053
if goos != "plan9" {

0 commit comments

Comments
 (0)