This patch updates gccgo to the final version of the gccgo pkg-config support committed to the gc repository. The patch to gc is https://golang.org/cl/18790, by Michael Hudson-Doyle. This fixes https://golang.org/issue/11739. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
I will commit this to the GCC 6 branch when that is open for bug fixes. Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 234958) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -ff29ea8e4e69eb94958aef4388da09a61b2b52b6 +97b358f525584e45fa2e3d83fc7d3a091900927a The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/cmd/go/build.go =================================================================== --- libgo/go/cmd/go/build.go (revision 234304) +++ libgo/go/cmd/go/build.go (working copy) @@ -2647,9 +2647,18 @@ func (tools gccgoToolchain) ld(b *builde if err != nil { return err } + const ldflagsPrefix = "_CGO_LDFLAGS=" for _, line := range strings.Split(string(flags), "\n") { - if strings.HasPrefix(line, "_CGO_LDFLAGS=") { - cgoldflags = append(cgoldflags, strings.Fields(line[13:])...) + if strings.HasPrefix(line, ldflagsPrefix) { + newFlags := strings.Fields(line[len(ldflagsPrefix):]) + for _, flag := range newFlags { + // Every _cgo_flags file has -g and -O2 in _CGO_LDFLAGS + // but they don't mean anything to the linker so filter + // them out. + if flag != "-g" && !strings.HasPrefix(flag, "-O") { + cgoldflags = append(cgoldflags, flag) + } + } } } return nil