diff --git a/src/cmd/go/internal/work/gccgo.go b/src/cmd/go/internal/work/gccgo.go index a048b7f4eec..69fc04a1abd 100644 --- a/src/cmd/go/internal/work/gccgo.go +++ b/src/cmd/go/internal/work/gccgo.go @@ -386,16 +386,9 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string } for _, a := range allactions { - // Gather CgoLDFLAGS, but not from standard packages. - // The go tool can dig up runtime/cgo from GOROOT and - // think that it should use its CgoLDFLAGS, but gccgo - // doesn't use runtime/cgo. if a.Package == nil { continue } - if !a.Package.Standard { - cgoldflags = append(cgoldflags, a.Package.CgoLDFLAGS...) - } if len(a.Package.CgoFiles) > 0 { usesCgo = true } @@ -425,9 +418,6 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string ldflags = append(ldflags, cgoldflags...) ldflags = append(ldflags, envList("CGO_LDFLAGS", "")...) - if root.Package != nil { - ldflags = append(ldflags, root.Package.CgoLDFLAGS...) - } if cfg.Goos != "aix" { ldflags = str.StringList("-Wl,-(", ldflags, "-Wl,-)") } diff --git a/src/cmd/go/testdata/script/gccgo_link_c.txt b/src/cmd/go/testdata/script/gccgo_link_c.txt index b9a4c70b7ee..f6c702a1670 100644 --- a/src/cmd/go/testdata/script/gccgo_link_c.txt +++ b/src/cmd/go/testdata/script/gccgo_link_c.txt @@ -4,8 +4,9 @@ [!cgo] skip [!exec:gccgo] skip -go build -n -compiler gccgo +! go build -x -compiler gccgo stderr 'gccgo.*\-L [^ ]*alibpath \-lalib' # make sure that Go-inline "#cgo LDFLAGS:" ("-L alibpath -lalib") passed to gccgo linking stage +! stderr 'gccgo.*-lalib.*-lalib' # make sure -lalib is only passed once -- go.mod -- module m