]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: make C compiler warnings fatal on builders
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 10 May 2016 20:03:42 +0000 (13:03 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 30 Aug 2016 05:25:59 +0000 (05:25 +0000)
Fixes #14698

Change-Id: I82fa781bf136c30e900d8e910ff576ba8b218acb
Reviewed-on: https://go-review.googlesource.com/23005
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/build.go

index e19cc5d38bb6dbe5be7bed5c306c842f16ce3df7..6e7f54d99697fd1c5331ea56cbb4cb7085bbe5b6 100644 (file)
@@ -3000,9 +3000,19 @@ func (b *builder) gfortran(p *Package, out string, flags []string, ffile string)
 }
 
 // ccompile runs the given C or C++ compiler and creates an object from a single source file.
-func (b *builder) ccompile(p *Package, out string, flags []string, file string, compiler []string) error {
+func (b *builder) ccompile(p *Package, outfile string, flags []string, file string, compiler []string) error {
        file = mkAbs(p.Dir, file)
-       return b.run(p.Dir, p.ImportPath, nil, compiler, flags, "-o", out, "-c", file)
+       desc := p.ImportPath
+       output, err := b.runOut(p.Dir, desc, nil, compiler, flags, "-o", outfile, "-c", file)
+       if len(output) > 0 {
+               b.showOutput(p.Dir, desc, b.processOutput(output))
+               if err != nil {
+                       err = errPrintedOutput
+               } else if os.Getenv("GO_BUILDER_NAME") != "" {
+                       return errors.New("C compiler warning promoted to error on Go builders")
+               }
+       }
+       return err
 }
 
 // gccld runs the gcc linker to create an executable from a set of object files.