diff options
author | Yvan Roux <yvan.roux@linaro.org> | 2016-08-22 15:07:28 +0200 |
---|---|---|
committer | Yvan Roux <yvan.roux@linaro.org> | 2016-08-22 15:07:28 +0200 |
commit | 34c4e6e08c214dbc961f9fae30ec020b5adc3589 (patch) | |
tree | 403f940f37964d4c9814be5d0c649cfe4a96a606 /libgo/go | |
parent | ae1f46b14da7a3b3cdb81e9d1c164eeaefb05e10 (diff) |
Merge branches/gcc-6-branch rev 239654.
Change-Id: I21e71f9dc10e3bedc0760cd5cc6b8d36234e3d41
Diffstat (limited to 'libgo/go')
-rw-r--r-- | libgo/go/cmd/go/build.go | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/libgo/go/cmd/go/build.go b/libgo/go/cmd/go/build.go index 4382cf72ed7..864fb879013 100644 --- a/libgo/go/cmd/go/build.go +++ b/libgo/go/cmd/go/build.go @@ -2632,10 +2632,9 @@ func (gccgoToolchain) pack(b *builder, p *Package, objDir, afile string, ofiles func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions []*action, mainpkg string, ofiles []string) error { // gccgo needs explicit linking with all package dependencies, // and all LDFLAGS from cgo dependencies. - apackagesSeen := make(map[*Package]bool) + apackagePathsSeen := make(map[string]bool) afiles := []string{} shlibs := []string{} - xfiles := []string{} ldflags := b.gccArchArgs() cgoldflags := []string{} usesCgo := false @@ -2647,9 +2646,18 @@ func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions 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 @@ -2714,10 +2722,10 @@ func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions // rather than the 'build' location (which may not exist any // more). We still need to traverse the dependencies of the // build action though so saying - // if apackagesSeen[a.p] { return } + // if apackagePathsSeen[a.p.ImportPath] { return } // doesn't work. - if !apackagesSeen[a.p] { - apackagesSeen[a.p] = true + if !apackagePathsSeen[a.p.ImportPath] { + apackagePathsSeen[a.p.ImportPath] = true target := a.target if len(a.p.CgoFiles) > 0 { target, err = readAndRemoveCgoFlags(target) @@ -2725,17 +2733,7 @@ func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions return } } - if a.p.fake && a.p.external { - // external _tests, if present must come before - // internal _tests. Store these on a separate list - // and place them at the head after this loop. - xfiles = append(xfiles, target) - } else if a.p.fake { - // move _test files to the top of the link order - afiles = append([]string{target}, afiles...) - } else { - afiles = append(afiles, target) - } + afiles = append(afiles, target) } } if strings.HasSuffix(a.target, ".so") { @@ -2755,7 +2753,6 @@ func (tools gccgoToolchain) ld(b *builder, root *action, out string, allactions return err } } - afiles = append(xfiles, afiles...) for _, a := range allactions { // Gather CgoLDFLAGS, but not from standard packages. |