mirror of
https://github.com/golang/go
synced 2024-11-24 11:20:07 -07:00
cmd/go: quote fragments in CGO_ env variables reported by 'go env'
These fields have been parsed as quoted fields since CL 334732, but we missed the unparsing side in 'go env'. Certain scripts (notably make.ba{sh,t}) expect to be able to set the environment to exactly what 'go env' reports, so for round-trip purposes it is important to match the marshaling and unmarshaling functions. (Noticed while debugging #52009.) Updates #41400 Change-Id: I0ff39b7a6e1328111c285c97cd23f79b723f3c73 Reviewed-on: https://go-review.googlesource.com/c/go/+/398058 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
a5f801f39d
commit
62bceae32d
@ -184,15 +184,23 @@ func ExtraEnvVarsCostly() []cfg.EnvVar {
|
||||
}
|
||||
cmd := b.GccCmd(".", "")
|
||||
|
||||
join := func(s []string) string {
|
||||
q, err := quoted.Join(s)
|
||||
if err != nil {
|
||||
return strings.Join(s, " ")
|
||||
}
|
||||
return q
|
||||
}
|
||||
|
||||
return []cfg.EnvVar{
|
||||
// Note: Update the switch in runEnv below when adding to this list.
|
||||
{Name: "CGO_CFLAGS", Value: strings.Join(cflags, " ")},
|
||||
{Name: "CGO_CPPFLAGS", Value: strings.Join(cppflags, " ")},
|
||||
{Name: "CGO_CXXFLAGS", Value: strings.Join(cxxflags, " ")},
|
||||
{Name: "CGO_FFLAGS", Value: strings.Join(fflags, " ")},
|
||||
{Name: "CGO_LDFLAGS", Value: strings.Join(ldflags, " ")},
|
||||
{Name: "CGO_CFLAGS", Value: join(cflags)},
|
||||
{Name: "CGO_CPPFLAGS", Value: join(cppflags)},
|
||||
{Name: "CGO_CXXFLAGS", Value: join(cxxflags)},
|
||||
{Name: "CGO_FFLAGS", Value: join(fflags)},
|
||||
{Name: "CGO_LDFLAGS", Value: join(ldflags)},
|
||||
{Name: "PKG_CONFIG", Value: b.PkgconfigCmd()},
|
||||
{Name: "GOGCCFLAGS", Value: strings.Join(cmd[3:], " ")},
|
||||
{Name: "GOGCCFLAGS", Value: join(cmd[3:])},
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user