diff --git a/cmd/guru/main.go b/cmd/guru/main.go index 761828a090..8e4af004a9 100644 --- a/cmd/guru/main.go +++ b/cmd/guru/main.go @@ -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"