aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/cmd/cgo/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/cmd/cgo/main.go')
-rw-r--r--libgo/go/cmd/cgo/main.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/libgo/go/cmd/cgo/main.go b/libgo/go/cmd/cgo/main.go
index c47e991..40dc6d2 100644
--- a/libgo/go/cmd/cgo/main.go
+++ b/libgo/go/cmd/cgo/main.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Cgo; see gmp.go for an overview.
+// Cgo; see doc.go for an overview.
// TODO(rsc):
// Emit correct line number annotations.
@@ -17,9 +17,11 @@ import (
"go/ast"
"go/printer"
"go/token"
+ "internal/buildcfg"
"io"
"io/ioutil"
"os"
+ "os/exec"
"path/filepath"
"reflect"
"runtime"
@@ -249,7 +251,7 @@ var importRuntimeCgo = flag.Bool("import_runtime_cgo", true, "import runtime/cgo
var importSyscall = flag.Bool("import_syscall", true, "import syscall in generated code")
var trimpath = flag.String("trimpath", "", "applies supplied rewrites or trims prefixes to recorded source file paths")
-var goarch, goos string
+var goarch, goos, gomips, gomips64 string
func main() {
objabi.AddVersionFlag() // -V
@@ -306,6 +308,14 @@ func main() {
p := newPackage(args[:i])
+ // We need a C compiler to be available. Check this.
+ gccName := p.gccBaseCmd()[0]
+ _, err := exec.LookPath(gccName)
+ if err != nil {
+ fatalf("C compiler %q not found: %v", gccName, err)
+ os.Exit(2)
+ }
+
// Record CGO_LDFLAGS from the environment for external linking.
if ldflags := os.Getenv("CGO_LDFLAGS"); ldflags != "" {
args, err := splitQuoted(ldflags)
@@ -409,6 +419,9 @@ func newPackage(args []string) *Package {
if s := os.Getenv("GOOS"); s != "" {
goos = s
}
+ buildcfg.Check()
+ gomips = buildcfg.GOMIPS
+ gomips64 = buildcfg.GOMIPS64
ptrSize := ptrSizeMap[goarch]
if ptrSize == 0 {
fatalf("unknown ptrSize for $GOARCH %q", goarch)