aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2017-05-03 17:50:19 +0000
committerChris Broadfoot <cbro@golang.org>2017-05-23 20:03:04 +0000
commit243dee1737c82340064d166abd589dae5f4f0b38 (patch)
tree40d848b912e1d43202b62fb9a2b5023f10026c1c
parenta43c0d2dc83bc4f5baa0a91be28078fa892e5111 (diff)
downloadgo-243dee1737c82340064d166abd589dae5f4f0b38.tar.gz
go-243dee1737c82340064d166abd589dae5f4f0b38.zip
[release-branch.go1.8] cmd/go: if we get a C compiler dwarf2 warning, try without -g
Backport of CL 38072 Fixes #14705 Reviewed-on: https://go-review.googlesource.com/42500 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Change-Id: Ia6ce2a41434aef2f8745a6a862ea66608b1e25f7 Reviewed-on: https://go-review.googlesource.com/43995 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/cmd/go/build.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
index 98a650918a..cad578daed 100644
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -3073,6 +3073,26 @@ func (b *builder) ccompile(p *Package, outfile string, flags []string, file stri
desc := p.ImportPath
output, err := b.runOut(p.Dir, desc, nil, compiler, flags, "-o", outfile, "-c", file)
if len(output) > 0 {
+ // On FreeBSD 11, when we pass -g to clang 3.8 it
+ // invokes its internal assembler with -dwarf-version=2.
+ // When it sees .section .note.GNU-stack, it warns
+ // "DWARF2 only supports one section per compilation unit".
+ // This warning makes no sense, since the section is empty,
+ // but it confuses people.
+ // We work around the problem by detecting the warning
+ // and dropping -g and trying again.
+ if bytes.Contains(output, []byte("DWARF2 only supports one section per compilation unit")) {
+ newFlags := make([]string, 0, len(flags))
+ for _, f := range flags {
+ if !strings.HasPrefix(f, "-g") {
+ newFlags = append(newFlags, f)
+ }
+ }
+ if len(newFlags) < len(flags) {
+ return b.ccompile(p, outfile, newFlags, file, compiler)
+ }
+ }
+
b.showOutput(p.Dir, desc, b.processOutput(output))
if err != nil {
err = errPrintedOutput