cmd/go: don't require GOROOT to exist for gccgo

Change-Id: I97147ae5602a5457476d33b0fa72dc163463e293
Reviewed-on: https://go-review.googlesource.com/46590
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/libgo/go/cmd/go/main.go b/libgo/go/cmd/go/main.go
index d80ff2d..ceeac4d 100644
--- a/libgo/go/cmd/go/main.go
+++ b/libgo/go/cmd/go/main.go
@@ -155,8 +155,13 @@
 	}
 
 	if fi, err := os.Stat(goroot); err != nil || !fi.IsDir() {
-		fmt.Fprintf(os.Stderr, "go: cannot find GOROOT directory: %v\n", goroot)
-		os.Exit(2)
+		// For gccgo this is fine, carry on.
+		// Note that this check is imperfect as we have not yet
+		// parsed the -compiler flag.
+		if runtime.Compiler != "gccgo" {
+			fmt.Fprintf(os.Stderr, "go: cannot find GOROOT directory: %v\n", goroot)
+			os.Exit(2)
+		}
 	}
 
 	// Set environment (GOOS, GOARCH, etc) explicitly.