aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/cfg/cfg.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2018-05-02 16:42:58 -0700
committerIan Lance Taylor <iant@golang.org>2018-05-04 00:46:12 +0000
commit498c803c19caa94d9d37eb378deed786117bbeab (patch)
treeea14faf06006c7c0b2820b6d192e597cd87e4a0f /src/cmd/go/internal/cfg/cfg.go
parentb44ca1f3b39afab221891695a8079b16ab45c251 (diff)
downloadgo-498c803c19caa94d9d37eb378deed786117bbeab.tar.gz
go-498c803c19caa94d9d37eb378deed786117bbeab.zip
cmd/go, go/build: add support for gccgo tooldir
The gccgo toolchain does not put tools (cgo, vet, etc.) in $GOROOT/pkg/tool, but instead in a directory available at runtime.GCCGOTOOLDIR. Update the go/build package and the cmd/go tool to use this tool directory when using gccgo. Change-Id: Ib827336ff53601208300aceb77f76c2e1b069859 Reviewed-on: https://go-review.googlesource.com/111097 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/go/internal/cfg/cfg.go')
-rw-r--r--src/cmd/go/internal/cfg/cfg.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go
index 85494e34f0..3df5905d02 100644
--- a/src/cmd/go/internal/cfg/cfg.go
+++ b/src/cmd/go/internal/cfg/cfg.go
@@ -93,11 +93,14 @@ var (
// Update build context to use our computed GOROOT.
func init() {
BuildContext.GOROOT = GOROOT
- // Note that we must use runtime.GOOS and runtime.GOARCH here,
- // as the tool directory does not move based on environment variables.
- // This matches the initialization of ToolDir in go/build,
- // except for using GOROOT rather than runtime.GOROOT().
- build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
+ if runtime.Compiler != "gccgo" {
+ // Note that we must use runtime.GOOS and runtime.GOARCH here,
+ // as the tool directory does not move based on environment
+ // variables. This matches the initialization of ToolDir in
+ // go/build, except for using GOROOT rather than
+ // runtime.GOROOT.
+ build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
+ }
}
func findGOROOT() string {
@@ -105,6 +108,11 @@ func findGOROOT() string {
return filepath.Clean(env)
}
def := filepath.Clean(runtime.GOROOT())
+ if runtime.Compiler == "gccgo" {
+ // gccgo has no real GOROOT, and it certainly doesn't
+ // depend on the executable's location.
+ return def
+ }
exe, err := os.Executable()
if err == nil {
exe, err = filepath.Abs(exe)