Commit 5edf5197 authored by Jaroslavas Počepko's avatar Jaroslavas Počepko Committed by Russ Cox

cgo: cgo to use GOARCH from the environment, not runtime.GOARCH (otherwise it...

cgo: cgo to use GOARCH from the environment, not runtime.GOARCH (otherwise it results in necessity of having 8cgo and 6cgo)

R=rsc, adg
CC=golang-dev
https://golang.org/cl/4978061
parent ad7dea1e
...@@ -20,7 +20,6 @@ import ( ...@@ -20,7 +20,6 @@ import (
"go/parser" "go/parser"
"go/token" "go/token"
"os" "os"
"runtime"
"strconv" "strconv"
"strings" "strings"
"unicode" "unicode"
...@@ -91,9 +90,9 @@ NextLine: ...@@ -91,9 +90,9 @@ NextLine:
case 2: case 2:
k = kf[1] k = kf[1]
switch kf[0] { switch kf[0] {
case runtime.GOOS: case goos:
case runtime.GOARCH: case goarch:
case runtime.GOOS + "/" + runtime.GOARCH: case goos + "/" + goarch:
default: default:
continue NextLine continue NextLine
} }
...@@ -688,7 +687,7 @@ func (p *Package) gccName() (ret string) { ...@@ -688,7 +687,7 @@ func (p *Package) gccName() (ret string) {
// gccMachine returns the gcc -m flag to use, either "-m32" or "-m64". // gccMachine returns the gcc -m flag to use, either "-m32" or "-m64".
func (p *Package) gccMachine() []string { func (p *Package) gccMachine() []string {
switch runtime.GOARCH { switch goarch {
case "amd64": case "amd64":
return []string{"-m64"} return []string{"-m64"}
case "386": case "386":
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"runtime"
"strings" "strings"
) )
...@@ -122,6 +123,8 @@ var fset = token.NewFileSet() ...@@ -122,6 +123,8 @@ var fset = token.NewFileSet()
var dynobj = flag.String("dynimport", "", "if non-empty, print dynamic import data for that file") var dynobj = flag.String("dynimport", "", "if non-empty, print dynamic import data for that file")
var goarch, goos string
func main() { func main() {
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
...@@ -162,13 +165,17 @@ func main() { ...@@ -162,13 +165,17 @@ func main() {
goFiles := args[i:] goFiles := args[i:]
arch := os.Getenv("GOARCH") goarch = runtime.GOARCH
if arch == "" { if s := os.Getenv("GOARCH"); s != "" {
fatalf("$GOARCH is not set") goarch = s
}
goos = runtime.GOOS
if s := os.Getenv("GOOS"); s != "" {
goos = s
} }
ptrSize := ptrSizeMap[arch] ptrSize := ptrSizeMap[goarch]
if ptrSize == 0 { if ptrSize == 0 {
fatalf("unknown $GOARCH %q", arch) fatalf("unknown $GOARCH %q", goarch)
} }
// Clear locale variables so gcc emits English errors [sic]. // Clear locale variables so gcc emits English errors [sic].
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment