cmd/cgo: only write _cgo_flags for gccgo

We only use it for gccgo. Also only write out LDFLAGS,
as that is all that cmd/go uses.

Fixes #60642

Change-Id: I6ccc419a17a433583d9868dd63aa7ec41c2b22c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/524556
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
Ian Lance Taylor 2023-08-30 14:06:45 -07:00 committed by Gopher Robot
parent 51ed3cb702
commit bdccd923e9
4 changed files with 14 additions and 15 deletions

View file

@ -104,10 +104,8 @@ func (f *File) ProcessCgoDirectives() {
f.Preamble = strings.Join(linesOut, "\n")
}
// addToFlag appends args to flag. All flags are later written out onto the
// _cgo_flags file for the build system to use.
// addToFlag appends args to flag.
func (p *Package) addToFlag(flag string, args []string) {
p.CgoFlags[flag] = append(p.CgoFlags[flag], args...)
if flag == "CFLAGS" {
// We'll also need these when preprocessing for dwarf information.
// However, discard any -g options: we need to be able
@ -118,6 +116,9 @@ func (p *Package) addToFlag(flag string, args []string) {
}
}
}
if flag == "LDFLAGS" {
p.LdFlags = append(p.LdFlags, args...)
}
}
// splitQuoted splits the string s around each instance of one or more consecutive