]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.11] cmd/go: add GOMIPS value to build id for mipsle
authorIan Lance Taylor <iant@golang.org>
Mon, 27 Aug 2018 03:38:43 +0000 (20:38 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 27 Sep 2018 22:04:44 +0000 (22:04 +0000)
Strip a trailing "le" from the GOARCH value when calculating the GOxxx
environment variable that affects it.

Updates #27260
Fixes #27420

Change-Id: I081f30d5dc19281901551823f4f56be028b5f71a
Reviewed-on: https://go-review.googlesource.com/131379
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit 61318d7ffe8a49e9dedc5aa8195a164a3821465c)
Reviewed-on: https://go-review.googlesource.com/138176
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/internal/work/exec.go
src/cmd/go/testdata/script/build_cache_gomips.txt [new file with mode: 0644]

index 42fa0e64ac0072cb23a8a4a2f8d5a3b92e5b5b65..12e15276f4cc382e70e0303b3669e10b549cdb74 100644 (file)
@@ -224,7 +224,9 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
                if len(p.SFiles) > 0 {
                        fmt.Fprintf(h, "asm %q %q %q\n", b.toolID("asm"), forcedAsmflags, p.Internal.Asmflags)
                }
-               fmt.Fprintf(h, "GO$GOARCH=%s\n", os.Getenv("GO"+strings.ToUpper(cfg.BuildContext.GOARCH))) // GO386, GOARM, etc
+               // GO386, GOARM, GOMIPS, etc.
+               baseArch := strings.TrimSuffix(cfg.BuildContext.GOARCH, "le")
+               fmt.Fprintf(h, "GO$GOARCH=%s\n", os.Getenv("GO"+strings.ToUpper(baseArch)))
 
                // TODO(rsc): Convince compiler team not to add more magic environment variables,
                // or perhaps restrict the environment variables passed to subprocesses.
diff --git a/src/cmd/go/testdata/script/build_cache_gomips.txt b/src/cmd/go/testdata/script/build_cache_gomips.txt
new file mode 100644 (file)
index 0000000..c77acc3
--- /dev/null
@@ -0,0 +1,37 @@
+# Set up fresh GOCACHE.
+env GOCACHE=$WORK/gocache
+mkdir $GOCACHE
+
+# Building for mipsle without setting GOMIPS will use floating point registers.
+env GOARCH=mipsle
+env GOOS=linux
+go build -gcflags=-S f.go
+stderr ADDD.F[0-9]+,.F[0-9]+,.F[0-9]+
+
+# Clean cache
+go clean -cache
+
+# Building with GOMIPS=softfloat will not use floating point registers
+env GOMIPS=softfloat
+go build -gcflags=-S f.go
+! stderr ADDD.F[0-9]+,.F[0-9]+,.F[0-9]+
+
+# Clean cache
+go clean -cache
+
+# Build without setting GOMIPS
+env GOMIPS=
+go build -gcflags=-S f.go
+stderr ADDD.F[0-9]+,.F[0-9]+,.F[0-9]+
+
+# Building with GOMIPS should still not use floating point registers.
+env GOMIPS=softfloat
+go build -gcflags=-S f.go
+! stderr ADDD.F[0-9]+,.F[0-9]+,.F[0-9]+
+
+-- f.go --
+package f
+
+func F(x float64) float64 {
+     return x + x
+}