mirror of
https://github.com/golang/go
synced 2024-11-17 03:14:50 -07:00
cmd/go: replace some calls to base.AppendPWD with cmd.Environ
With #50599 implemented, base.AppendPWD is redundant if cmd.Env would otherwise be nil, and calls to os.Environ followed by base.AppendPWD can be replaced by a simpler call to cmd.Environ. Updates #50599. Change-Id: I94a22e2a4cc8e83c815ac41702ea0b1ee5034ecc Reviewed-on: https://go-review.googlesource.com/c/go/+/401534 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
a4bbcd4b1f
commit
824b0a34b7
@ -22,7 +22,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"cmd/go/internal/base"
|
||||
"cmd/go/internal/cfg"
|
||||
"cmd/go/internal/search"
|
||||
"cmd/go/internal/str"
|
||||
@ -657,7 +656,6 @@ func (v *Cmd) run1(dir string, cmdline string, keyval []string, verbose bool) ([
|
||||
|
||||
cmd := exec.Command(v.Cmd, args...)
|
||||
cmd.Dir = dir
|
||||
cmd.Env = base.AppendPWD(os.Environ(), cmd.Dir)
|
||||
if cfg.BuildX {
|
||||
fmt.Fprintf(os.Stderr, "cd %s\n", dir)
|
||||
fmt.Fprintf(os.Stderr, "%s %s\n", v.Cmd, strings.Join(args, " "))
|
||||
|
@ -2116,11 +2116,10 @@ func (b *Builder) runOut(a *Action, dir string, env []string, cmdargs ...any) ([
|
||||
cmd.Stderr = &buf
|
||||
cleanup := passLongArgsInResponseFiles(cmd)
|
||||
defer cleanup()
|
||||
cmd.Env = os.Environ()
|
||||
if dir != "." {
|
||||
cmd.Dir = dir
|
||||
cmd.Env = base.AppendPWD(cmd.Env, dir)
|
||||
}
|
||||
cmd.Env = cmd.Environ() // Pre-allocate with correct PWD.
|
||||
|
||||
// Add the TOOLEXEC_IMPORTPATH environment variable for -toolexec tools.
|
||||
// It doesn't really matter if -toolexec isn't being used.
|
||||
@ -2609,8 +2608,7 @@ func (b *Builder) gccSupportsFlag(compiler []string, flag string) bool {
|
||||
}
|
||||
cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
|
||||
cmd.Dir = b.WorkDir
|
||||
cmd.Env = base.AppendPWD(os.Environ(), cmd.Dir)
|
||||
cmd.Env = append(cmd.Env, "LC_ALL=C")
|
||||
cmd.Env = append(cmd.Environ(), "LC_ALL=C")
|
||||
out, _ := cmd.CombinedOutput()
|
||||
// GCC says "unrecognized command line option".
|
||||
// clang says "unknown argument".
|
||||
|
Loading…
Reference in New Issue
Block a user