From: Austin Clements Date: Thu, 24 Aug 2023 19:14:44 +0000 (-0400) Subject: cmd/go: clarify promotion of C warnings to errors X-Git-Tag: go1.22rc1~1107 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e63be91667aeaafe2ce32c4da69f89097e074bbc;p=gostls13.git cmd/go: clarify promotion of C warnings to errors CL 23005 (back in 2016!) added logic to promote C compiler warnings to errors when running on the Go builders. CL 437298 kept the logic to promote warnings to errors on the builders, but dropped the explanatory message, I believe unintentionally. Indeed, now there isn't even a comment in the code explaining what's going on. This CL adds back an explanatory message to the printed output, which also serves as a explanation in the code as to why we're checking $GO_BUILDER_NAME. Change-Id: I769c55d213f96f73d20a41ab926fb91e71a5a22c Reviewed-on: https://go-review.googlesource.com/c/go/+/522775 Run-TryBot: Austin Clements Reviewed-by: Bryan Mills Auto-Submit: Austin Clements TryBot-Result: Gopher Robot --- diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 64b0aae267..0312a58fc5 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -2683,7 +2683,11 @@ func (b *Builder) ccompile(a *Action, p *load.Package, outfile string, flags []s } } - if err != nil || os.Getenv("GO_BUILDER_NAME") != "" { + if err == nil && os.Getenv("GO_BUILDER_NAME") != "" { + output = append(output, "C compiler warning promoted to error on Go builders\n"...) + err = errors.New("warning promoted to error") + } + if err != nil { err = formatOutput(b.WorkDir, p.Dir, p.ImportPath, p.Desc(), b.processOutput(output)) } else { b.showOutput(a, p.Dir, p.Desc(), b.processOutput(output))