mirror of https://github.com/golang/go.git
cmd/go, cmd/dist: introduce GOMIPS environment variable
GOMIPS is a GOARCH=mips{,le} specific option, for a choice between
hard-float and soft-float. Valid values are 'hardfloat' (default) and
'softfloat'. It is passed to the assembler as
'GOMIPS_{hardfloat,softfloat}'.
Note: GOMIPS will later also be used for a choice of MIPS instruction
set (mips32/mips32r2).
Updates #18162
Change-Id: I35417db8625695f09d6ccc3042431dd2eaa756a6
Reviewed-on: https://go-review.googlesource.com/37954
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
4f5018594d
commit
12abacb555
|
|
@ -876,6 +876,12 @@ Addressing modes:
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The value of <code>GOMIPS</code> environment variable (<code>hardfloat</code> or
|
||||||
|
<code>softfloat</code>) is made available to assembly code by predefining either
|
||||||
|
<code>GOMIPS_hardfloat</code> or <code>GOMIPS_softfloat</code>.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3 id="unsupported_opcodes">Unsupported opcodes</h3>
|
<h3 id="unsupported_opcodes">Unsupported opcodes</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ var (
|
||||||
goos string
|
goos string
|
||||||
goarm string
|
goarm string
|
||||||
go386 string
|
go386 string
|
||||||
|
gomips string
|
||||||
goroot string
|
goroot string
|
||||||
goroot_final string
|
goroot_final string
|
||||||
goextlinkenabled string
|
goextlinkenabled string
|
||||||
|
|
@ -138,6 +139,12 @@ func xinit() {
|
||||||
}
|
}
|
||||||
go386 = b
|
go386 = b
|
||||||
|
|
||||||
|
b = os.Getenv("GOMIPS")
|
||||||
|
if b == "" {
|
||||||
|
b = "hardfloat"
|
||||||
|
}
|
||||||
|
gomips = b
|
||||||
|
|
||||||
if p := pathf("%s/src/all.bash", goroot); !isfile(p) {
|
if p := pathf("%s/src/all.bash", goroot); !isfile(p) {
|
||||||
fatalf("$GOROOT is not set correctly or not exported\n"+
|
fatalf("$GOROOT is not set correctly or not exported\n"+
|
||||||
"\tGOROOT=%s\n"+
|
"\tGOROOT=%s\n"+
|
||||||
|
|
@ -194,6 +201,7 @@ func xinit() {
|
||||||
os.Setenv("GOHOSTARCH", gohostarch)
|
os.Setenv("GOHOSTARCH", gohostarch)
|
||||||
os.Setenv("GOHOSTOS", gohostos)
|
os.Setenv("GOHOSTOS", gohostos)
|
||||||
os.Setenv("GOOS", goos)
|
os.Setenv("GOOS", goos)
|
||||||
|
os.Setenv("GOMIPS", gomips)
|
||||||
os.Setenv("GOROOT", goroot)
|
os.Setenv("GOROOT", goroot)
|
||||||
os.Setenv("GOROOT_FINAL", goroot_final)
|
os.Setenv("GOROOT_FINAL", goroot_final)
|
||||||
|
|
||||||
|
|
@ -804,6 +812,11 @@ func runInstall(dir string, ch chan struct{}) {
|
||||||
"-D", "GOOS_GOARCH_" + goos + "_" + goarch,
|
"-D", "GOOS_GOARCH_" + goos + "_" + goarch,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if goarch == "mips" || goarch == "mipsle" {
|
||||||
|
// Define GOMIPS_value from gomips.
|
||||||
|
compile = append(compile, "-D", "GOMIPS_"+gomips)
|
||||||
|
}
|
||||||
|
|
||||||
doclean := true
|
doclean := true
|
||||||
b := pathf("%s/%s", workdir, filepath.Base(p))
|
b := pathf("%s/%s", workdir, filepath.Base(p))
|
||||||
|
|
||||||
|
|
@ -1042,6 +1055,9 @@ func cmdenv() {
|
||||||
if goarch == "386" {
|
if goarch == "386" {
|
||||||
xprintf(format, "GO386", go386)
|
xprintf(format, "GO386", go386)
|
||||||
}
|
}
|
||||||
|
if goarch == "mips" || goarch == "mipsle" {
|
||||||
|
xprintf(format, "GOMIPS", gomips)
|
||||||
|
}
|
||||||
|
|
||||||
if *path {
|
if *path {
|
||||||
sep := ":"
|
sep := ":"
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ func mkzversion(dir, file string) {
|
||||||
// const defaultGOROOT = <goroot>
|
// const defaultGOROOT = <goroot>
|
||||||
// const defaultGO386 = <go386>
|
// const defaultGO386 = <go386>
|
||||||
// const defaultGOARM = <goarm>
|
// const defaultGOARM = <goarm>
|
||||||
|
// const defaultGOMIPS = <gomips>
|
||||||
// const defaultGOOS = runtime.GOOS
|
// const defaultGOOS = runtime.GOOS
|
||||||
// const defaultGOARCH = runtime.GOARCH
|
// const defaultGOARCH = runtime.GOARCH
|
||||||
// const defaultGO_EXTLINK_ENABLED = <goextlinkenabled>
|
// const defaultGO_EXTLINK_ENABLED = <goextlinkenabled>
|
||||||
|
|
@ -73,6 +74,7 @@ func mkzbootstrap(file string) {
|
||||||
fmt.Fprintf(&buf, "const defaultGOROOT = `%s`\n", goroot_final)
|
fmt.Fprintf(&buf, "const defaultGOROOT = `%s`\n", goroot_final)
|
||||||
fmt.Fprintf(&buf, "const defaultGO386 = `%s`\n", go386)
|
fmt.Fprintf(&buf, "const defaultGO386 = `%s`\n", go386)
|
||||||
fmt.Fprintf(&buf, "const defaultGOARM = `%s`\n", goarm)
|
fmt.Fprintf(&buf, "const defaultGOARM = `%s`\n", goarm)
|
||||||
|
fmt.Fprintf(&buf, "const defaultGOMIPS = `%s`\n", gomips)
|
||||||
fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n")
|
fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n")
|
||||||
fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n")
|
fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n")
|
||||||
fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled)
|
fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled)
|
||||||
|
|
|
||||||
|
|
@ -1199,6 +1199,9 @@
|
||||||
// GO386
|
// GO386
|
||||||
// For GOARCH=386, the floating point instruction set.
|
// For GOARCH=386, the floating point instruction set.
|
||||||
// Valid values are 387, sse2.
|
// Valid values are 387, sse2.
|
||||||
|
// GOMIPS
|
||||||
|
// For GOARCH=mips{,le}, whether to use floating point instructions.
|
||||||
|
// Valid values are hardfloat (default), softfloat.
|
||||||
//
|
//
|
||||||
// Special-purpose environment variables:
|
// Special-purpose environment variables:
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,9 @@ var (
|
||||||
GOROOTsrc = filepath.Join(GOROOT, "src")
|
GOROOTsrc = filepath.Join(GOROOT, "src")
|
||||||
|
|
||||||
// Used in envcmd.MkEnv and build ID computations.
|
// Used in envcmd.MkEnv and build ID computations.
|
||||||
GOARM = fmt.Sprint(objabi.GOARM)
|
GOARM = fmt.Sprint(objabi.GOARM)
|
||||||
GO386 = objabi.GO386
|
GO386 = objabi.GO386
|
||||||
|
GOMIPS = objabi.GOMIPS
|
||||||
)
|
)
|
||||||
|
|
||||||
// Update build context to use our computed GOROOT.
|
// Update build context to use our computed GOROOT.
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,8 @@ func MkEnv() []cfg.EnvVar {
|
||||||
env = append(env, cfg.EnvVar{Name: "GOARM", Value: cfg.GOARM})
|
env = append(env, cfg.EnvVar{Name: "GOARM", Value: cfg.GOARM})
|
||||||
case "386":
|
case "386":
|
||||||
env = append(env, cfg.EnvVar{Name: "GO386", Value: cfg.GO386})
|
env = append(env, cfg.EnvVar{Name: "GO386", Value: cfg.GO386})
|
||||||
|
case "mips", "mipsle":
|
||||||
|
env = append(env, cfg.EnvVar{Name: "GOMIPS", Value: cfg.GOMIPS})
|
||||||
}
|
}
|
||||||
|
|
||||||
cc := cfg.DefaultCC(cfg.Goos, cfg.Goarch)
|
cc := cfg.DefaultCC(cfg.Goos, cfg.Goarch)
|
||||||
|
|
|
||||||
|
|
@ -511,6 +511,9 @@ Architecture-specific environment variables:
|
||||||
GO386
|
GO386
|
||||||
For GOARCH=386, the floating point instruction set.
|
For GOARCH=386, the floating point instruction set.
|
||||||
Valid values are 387, sse2.
|
Valid values are 387, sse2.
|
||||||
|
GOMIPS
|
||||||
|
For GOARCH=mips{,le}, whether to use floating point instructions.
|
||||||
|
Valid values are hardfloat (default), softfloat.
|
||||||
|
|
||||||
Special-purpose environment variables:
|
Special-purpose environment variables:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,12 @@ func (gcToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.Goarch == "mips" || cfg.Goarch == "mipsle" {
|
||||||
|
// Define GOMIPS_value from cfg.GOMIPS.
|
||||||
|
args = append(args, "-D", "GOMIPS_"+cfg.GOMIPS)
|
||||||
|
}
|
||||||
|
|
||||||
var ofiles []string
|
var ofiles []string
|
||||||
for _, sfile := range sfiles {
|
for _, sfile := range sfiles {
|
||||||
ofile := a.Objdir + sfile[:len(sfile)-len(".s")] + ".o"
|
ofile := a.Objdir + sfile[:len(sfile)-len(".s")] + ".o"
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ var (
|
||||||
GOOS = envOr("GOOS", defaultGOOS)
|
GOOS = envOr("GOOS", defaultGOOS)
|
||||||
GO386 = envOr("GO386", defaultGO386)
|
GO386 = envOr("GO386", defaultGO386)
|
||||||
GOARM = goarm()
|
GOARM = goarm()
|
||||||
|
GOMIPS = gomips()
|
||||||
Version = version
|
Version = version
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -41,6 +42,15 @@ func goarm() int {
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func gomips() string {
|
||||||
|
switch v := envOr("GOMIPS", defaultGOMIPS); v {
|
||||||
|
case "hardfloat", "softfloat":
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
log.Fatalf("Invalid GOMIPS value. Must be hardfloat or softfloat.")
|
||||||
|
panic("unreachable")
|
||||||
|
}
|
||||||
|
|
||||||
func Getgoextlinkenabled() string {
|
func Getgoextlinkenabled() string {
|
||||||
return envOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED)
|
return envOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue