"go/parser"
"go/token"
"os"
- "runtime"
"strconv"
"strings"
"unicode"
case 2:
k = kf[1]
switch kf[0] {
- case runtime.GOOS:
- case runtime.GOARCH:
- case runtime.GOOS + "/" + runtime.GOARCH:
+ case goos:
+ case goarch:
+ case goos + "/" + goarch:
default:
continue NextLine
}
// gccMachine returns the gcc -m flag to use, either "-m32" or "-m64".
func (p *Package) gccMachine() []string {
- switch runtime.GOARCH {
+ switch goarch {
case "amd64":
return []string{"-m64"}
case "386":
"os"
"path/filepath"
"reflect"
+ "runtime"
"strings"
)
var dynobj = flag.String("dynimport", "", "if non-empty, print dynamic import data for that file")
+var goarch, goos string
+
func main() {
flag.Usage = usage
flag.Parse()
goFiles := args[i:]
- arch := os.Getenv("GOARCH")
- if arch == "" {
- fatalf("$GOARCH is not set")
+ goarch = runtime.GOARCH
+ if s := os.Getenv("GOARCH"); s != "" {
+ goarch = s
+ }
+ goos = runtime.GOOS
+ if s := os.Getenv("GOOS"); s != "" {
+ goos = s
}
- ptrSize := ptrSizeMap[arch]
+ ptrSize := ptrSizeMap[goarch]
if ptrSize == 0 {
- fatalf("unknown $GOARCH %q", arch)
+ fatalf("unknown $GOARCH %q", goarch)
}
// Clear locale variables so gcc emits English errors [sic].