Skip to content

Commit 750e911

Browse files
Bryan C. Millsgopherbot
authored andcommitted
cmd/compile/internal/importer,go/internal/gcimporter: use the 'go' command from build.Default.GOROOT in lookupGorootExport
Also set GOROOT explicitly in case it is set to something else in the caller's environment. Fixes #59598. Change-Id: I5599ed1183b23187fc3b976786f3c320d42ef4f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/484756 Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent dd53a43 commit 750e911

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/cmd/compile/internal/importer/gcimporter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ func lookupGorootExport(pkgDir string) (string, bool) {
3939
)
4040
f, _ = exportMap.LoadOrStore(pkgDir, func() (string, bool) {
4141
listOnce.Do(func() {
42-
cmd := exec.Command("go", "list", "-export", "-f", "{{.Export}}", pkgDir)
42+
cmd := exec.Command(filepath.Join(build.Default.GOROOT, "bin", "go"), "list", "-export", "-f", "{{.Export}}", pkgDir)
4343
cmd.Dir = build.Default.GOROOT
44+
cmd.Env = append(os.Environ(), "PWD="+cmd.Dir, "GOROOT="+build.Default.GOROOT)
4445
var output []byte
4546
output, err := cmd.Output()
4647
if err != nil {

src/go/internal/gcimporter/gcimporter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ func lookupGorootExport(pkgDir string) (string, bool) {
4343
)
4444
f, _ = exportMap.LoadOrStore(pkgDir, func() (string, bool) {
4545
listOnce.Do(func() {
46-
cmd := exec.Command("go", "list", "-export", "-f", "{{.Export}}", pkgDir)
46+
cmd := exec.Command(filepath.Join(build.Default.GOROOT, "bin", "go"), "list", "-export", "-f", "{{.Export}}", pkgDir)
4747
cmd.Dir = build.Default.GOROOT
48+
cmd.Env = append(cmd.Environ(), "GOROOT="+build.Default.GOROOT)
4849
var output []byte
4950
output, err := cmd.Output()
5051
if err != nil {

0 commit comments

Comments
 (0)