]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/importer,go/internal/gcimporter: use the 'go' command from build...
authorBryan C. Mills <bcmills@google.com>
Fri, 14 Apr 2023 16:48:26 +0000 (16:48 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 14 Apr 2023 20:09:13 +0000 (20:09 +0000)
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 <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/compile/internal/importer/gcimporter.go
src/go/internal/gcimporter/gcimporter.go

index 5d948f03c8a33f928432f030b90f27227c50689e..490cdf94dfad5c0138a122eaed2c5a4804389411 100644 (file)
@@ -39,8 +39,9 @@ func lookupGorootExport(pkgDir string) (string, bool) {
                )
                f, _ = exportMap.LoadOrStore(pkgDir, func() (string, bool) {
                        listOnce.Do(func() {
-                               cmd := exec.Command("go", "list", "-export", "-f", "{{.Export}}", pkgDir)
+                               cmd := exec.Command(filepath.Join(build.Default.GOROOT, "bin", "go"), "list", "-export", "-f", "{{.Export}}", pkgDir)
                                cmd.Dir = build.Default.GOROOT
+                               cmd.Env = append(os.Environ(), "PWD="+cmd.Dir, "GOROOT="+build.Default.GOROOT)
                                var output []byte
                                output, err := cmd.Output()
                                if err != nil {
index 0b784de58407eb2c2b3cec51b310ffb1da981c67..93b33d1510b9b4b0e335ee04ccf174efb523a6f7 100644 (file)
@@ -43,8 +43,9 @@ func lookupGorootExport(pkgDir string) (string, bool) {
                )
                f, _ = exportMap.LoadOrStore(pkgDir, func() (string, bool) {
                        listOnce.Do(func() {
-                               cmd := exec.Command("go", "list", "-export", "-f", "{{.Export}}", pkgDir)
+                               cmd := exec.Command(filepath.Join(build.Default.GOROOT, "bin", "go"), "list", "-export", "-f", "{{.Export}}", pkgDir)
                                cmd.Dir = build.Default.GOROOT
+                               cmd.Env = append(cmd.Environ(), "GOROOT="+build.Default.GOROOT)
                                var output []byte
                                output, err := cmd.Output()
                                if err != nil {