]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/go, cmd/dist: introduce GOMIPS environment variable
authorVladimir Stefanovic <vladimir.stefanovic@imgtec.com>
Mon, 22 May 2017 16:23:31 +0000 (18:23 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 30 Nov 2017 16:57:08 +0000 (16:57 +0000)
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>
doc/asm.html
src/cmd/dist/build.go
src/cmd/dist/buildruntime.go
src/cmd/go/alldocs.go
src/cmd/go/internal/cfg/cfg.go
src/cmd/go/internal/envcmd/env.go
src/cmd/go/internal/help/helpdoc.go
src/cmd/go/internal/work/gc.go
src/cmd/internal/objabi/util.go

index 79dc7df322fadb6a58b2674d5aadbb8a0db55e6f..e3e17f85f58748b03b363e0617e26d49fd35c11c 100644 (file)
@@ -876,6 +876,12 @@ Addressing modes:
 
 </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>
 
 <p>
index c8a9dcb5f69c7b1c0d71b589af9cc304cae0fdb5..e80d466d35240aeee7a04d6a9fc7172b1a3a0cdc 100644 (file)
@@ -30,6 +30,7 @@ var (
        goos             string
        goarm            string
        go386            string
+       gomips           string
        goroot           string
        goroot_final     string
        goextlinkenabled string
@@ -138,6 +139,12 @@ func xinit() {
        }
        go386 = b
 
+       b = os.Getenv("GOMIPS")
+       if b == "" {
+               b = "hardfloat"
+       }
+       gomips = b
+
        if p := pathf("%s/src/all.bash", goroot); !isfile(p) {
                fatalf("$GOROOT is not set correctly or not exported\n"+
                        "\tGOROOT=%s\n"+
@@ -194,6 +201,7 @@ func xinit() {
        os.Setenv("GOHOSTARCH", gohostarch)
        os.Setenv("GOHOSTOS", gohostos)
        os.Setenv("GOOS", goos)
+       os.Setenv("GOMIPS", gomips)
        os.Setenv("GOROOT", goroot)
        os.Setenv("GOROOT_FINAL", goroot_final)
 
@@ -804,6 +812,11 @@ func runInstall(dir string, ch chan struct{}) {
                        "-D", "GOOS_GOARCH_" + goos + "_" + goarch,
                }
 
+               if goarch == "mips" || goarch == "mipsle" {
+                       // Define GOMIPS_value from gomips.
+                       compile = append(compile, "-D", "GOMIPS_"+gomips)
+               }
+
                doclean := true
                b := pathf("%s/%s", workdir, filepath.Base(p))
 
@@ -1042,6 +1055,9 @@ func cmdenv() {
        if goarch == "386" {
                xprintf(format, "GO386", go386)
        }
+       if goarch == "mips" || goarch == "mipsle" {
+               xprintf(format, "GOMIPS", gomips)
+       }
 
        if *path {
                sep := ":"
index 8dd095b82d7d64181e34243c7b11d40e1785e843..2f10fd0237dd8df48ef694c2c162bfdb640f8a70 100644 (file)
@@ -46,6 +46,7 @@ func mkzversion(dir, file string) {
 //     const defaultGOROOT = <goroot>
 //     const defaultGO386 = <go386>
 //     const defaultGOARM = <goarm>
+//     const defaultGOMIPS = <gomips>
 //     const defaultGOOS = runtime.GOOS
 //     const defaultGOARCH = runtime.GOARCH
 //     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 defaultGO386 = `%s`\n", go386)
        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 defaultGOARCH = runtime.GOARCH\n")
        fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled)
index 50d5ac5ae8e20ab1c8f449d031284a3a01ce6e0a..918e1a1e1757bcc57013b60177ccda9dc4bd8f51 100644 (file)
 //     GO386
 //             For GOARCH=386, the floating point instruction set.
 //             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:
 //
index 491eed6a5fc484262166011a89dd4fdc0bbac3f0..dfab20a8de35270274682bc9b10d7228cb9f2c23 100644 (file)
@@ -83,8 +83,9 @@ var (
        GOROOTsrc = filepath.Join(GOROOT, "src")
 
        // Used in envcmd.MkEnv and build ID computations.
-       GOARM = fmt.Sprint(objabi.GOARM)
-       GO386 = objabi.GO386
+       GOARM  = fmt.Sprint(objabi.GOARM)
+       GO386  = objabi.GO386
+       GOMIPS = objabi.GOMIPS
 )
 
 // Update build context to use our computed GOROOT.
index f756e3b60722749737041d49bbcce8f93ea127da..fa19bebe218fcf8fc130cba5f123d8dcd330dd51 100644 (file)
@@ -76,6 +76,8 @@ func MkEnv() []cfg.EnvVar {
                env = append(env, cfg.EnvVar{Name: "GOARM", Value: cfg.GOARM})
        case "386":
                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)
index 76f3137c1263a5babf5789873536e1ed4e23bff9..43144db593ab43b638f97171802a90a5a53988ab 100644 (file)
@@ -511,6 +511,9 @@ Architecture-specific environment variables:
        GO386
                For GOARCH=386, the floating point instruction set.
                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:
 
index e1dd30026bd1fdaa4c7bed5d52d35a1efdc7abe2..4a181d9730095ad5be56a288e6fd4657c152c84d 100644 (file)
@@ -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
        for _, sfile := range sfiles {
                ofile := a.Objdir + sfile[:len(sfile)-len(".s")] + ".o"
index 1da05021f50855feb95b63424edfb4d915198942..f8949e05a2b360fb14cbe73df044e88211199415 100644 (file)
@@ -24,6 +24,7 @@ var (
        GOOS    = envOr("GOOS", defaultGOOS)
        GO386   = envOr("GO386", defaultGO386)
        GOARM   = goarm()
+       GOMIPS  = gomips()
        Version = version
 )
 
@@ -41,6 +42,15 @@ func goarm() int {
        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 {
        return envOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED)
 }