diff options
| author | Ian Lance Taylor <iant@golang.org> | 2023-05-22 17:55:43 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-07-20 18:11:05 +0000 |
| commit | d3e3e11298eff0c113cec303054ec2f45075e95c (patch) | |
| tree | 58047eee728099681c9c743d148c598da16354fb /src | |
| parent | 80a7315c3400b011a0f89e63aca73031a9073c9a (diff) | |
| download | go-d3e3e11298eff0c113cec303054ec2f45075e95c.tar.xz | |
cmd/go: don't collect package CGOLDFLAGS when using gccgo
They are already collected via cmd/cgo.
The gccgo_link_c test is tweaked to do real linking as with this
change the cgo ldflags are not fully reflected in go build -n output,
since they now only come from the built archive.
Fixes #60287
Change-Id: Id433435fe8aeb9571327bf936e52a37f400cef4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/497117
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Andrey Bokhanko <andreybokhanko@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/go/internal/work/gccgo.go | 10 | ||||
| -rw-r--r-- | src/cmd/go/testdata/script/gccgo_link_c.txt | 3 |
2 files changed, 2 insertions, 11 deletions
diff --git a/src/cmd/go/internal/work/gccgo.go b/src/cmd/go/internal/work/gccgo.go index a048b7f4ee..69fc04a1ab 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 b9a4c70b7e..f6c702a167 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 |
