]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist, cmd/go: enable more warnings, make clang errors legible
authorRuss Cox <rsc@golang.org>
Fri, 19 Jul 2013 23:36:15 +0000 (19:36 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 19 Jul 2013 23:36:15 +0000 (19:36 -0400)
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

src/cmd/dist/build.c
src/cmd/dist/unix.c
src/cmd/go/build.go
src/cmd/go/env.go

index ba32d3e69b3d53e859412e463740ed900f3b923c..f99aaa3c93399377ef940453cd95bc93dc43af65 100644 (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");
                }
index 86948b0b2bd0edb225803abdf6be489fab0c187d..3ab40f1b51fb686b83944483553f198372689d00 100644 (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 = "/";
index dd015eeac6d5d7bcebc26e1d582c5338898f026b..0c9e561538fc09086ac7530a39c90b8c85cb1661 100644 (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")
        }
 
index 00e03e9bdae7490d24b4e2667b5352211e77972c..539364af4e77c7fc9be5d63e44ab9bb8ab2c3bfb 100644 (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" {