mirror of
https://github.com/golang/go
synced 2024-11-18 10:04:43 -07:00
cmd/guru: if built with gccgo, switch to gc mode if GOROOT is valid
The gccgo compiler does not provide a gc-style GOROOT with standard library sources. The effect is that guru may not fully work when using gccgo. However, it can fully work if the GOROOT environment variable points to valid gc-style GOROOT. In that case, make it work by telling the go/build package to use gc mode. Change-Id: Iadff8be61be8cc9a7ff2ca0a067b116b62895451 Reviewed-on: https://go-review.googlesource.com/117997 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
f96157268c
commit
2475cf16d3
@ -19,6 +19,8 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -38,6 +40,14 @@ var (
|
||||
|
||||
func init() {
|
||||
flag.Var((*buildutil.TagsFlag)(&build.Default.BuildTags), "tags", buildutil.TagsFlagDoc)
|
||||
|
||||
// gccgo does not provide a GOROOT with standard library sources.
|
||||
// If we have one in the environment, force gc mode.
|
||||
if build.Default.Compiler == "gccgo" {
|
||||
if _, err := os.Stat(filepath.Join(runtime.GOROOT(), "src", "runtime", "runtime.go")); err == nil {
|
||||
build.Default.Compiler = "gc"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const useHelp = "Run 'guru -help' for more information.\n"
|
||||
|
Loading…
Reference in New Issue
Block a user