1
0
mirror of https://github.com/golang/go synced 2024-11-12 07:00:21 -07:00

cmd/cgo: don't pass CGO_CFLAGS -g options to debug info generation

Fixes #26144

Change-Id: Ie69dab1bd819eaf158be11769903b2636bbcf516
Reviewed-on: https://go-review.googlesource.com/c/152165
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Nikhil Benesch <nikhil.benesch@gmail.com>
This commit is contained in:
Ian Lance Taylor 2018-12-03 16:02:10 -08:00
parent 89df035464
commit 8c5976f8b3
2 changed files with 11 additions and 2 deletions

View File

@ -91,7 +91,13 @@ func (p *Package) addToFlag(flag string, args []string) {
p.CgoFlags[flag] = append(p.CgoFlags[flag], args...) p.CgoFlags[flag] = append(p.CgoFlags[flag], args...)
if flag == "CFLAGS" { if flag == "CFLAGS" {
// We'll also need these when preprocessing for dwarf information. // We'll also need these when preprocessing for dwarf information.
p.GccOptions = append(p.GccOptions, args...) // However, discard any -g options: we need to be able
// to parse the debug info, so stick to what we expect.
for _, arg := range args {
if !strings.HasPrefix(arg, "-g") {
p.GccOptions = append(p.GccOptions, arg)
}
}
} }
} }

View File

@ -1038,7 +1038,10 @@ func (t *tester) cgoTest(dt *distTest) error {
"linux-386", "linux-amd64", "linux-arm", "linux-ppc64le", "linux-s390x", "linux-386", "linux-amd64", "linux-arm", "linux-ppc64le", "linux-s390x",
"netbsd-386", "netbsd-amd64": "netbsd-386", "netbsd-amd64":
t.addCmd(dt, "misc/cgo/test", t.goTest(), "-ldflags", "-linkmode=external") cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), "-ldflags", "-linkmode=external")
// A -g argument in CGO_CFLAGS should not affect how the test runs.
cmd.Env = append(os.Environ(), "CGO_CFLAGS=-g0")
t.addCmd(dt, "misc/cgo/testtls", t.goTest(), "-ldflags", "-linkmode=auto") t.addCmd(dt, "misc/cgo/testtls", t.goTest(), "-ldflags", "-linkmode=auto")
t.addCmd(dt, "misc/cgo/testtls", t.goTest(), "-ldflags", "-linkmode=external") t.addCmd(dt, "misc/cgo/testtls", t.goTest(), "-ldflags", "-linkmode=external")