Skip to content

Commit 61318d7

Browse files
cmd/go: add GOMIPS value to build id for mipsle
Strip a trailing "le" from the GOARCH value when calculating the GOxxx environment variable that affects it. Fixes golang#27260 Change-Id: I081f30d5dc19281901551823f4f56be028b5f71a Reviewed-on: https://go-review.googlesource.com/131379 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 3ca3e89 commit 61318d7

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/cmd/go/internal/work/exec.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
224224
if len(p.SFiles) > 0 {
225225
fmt.Fprintf(h, "asm %q %q %q\n", b.toolID("asm"), forcedAsmflags, p.Internal.Asmflags)
226226
}
227-
fmt.Fprintf(h, "GO$GOARCH=%s\n", os.Getenv("GO"+strings.ToUpper(cfg.BuildContext.GOARCH))) // GO386, GOARM, etc
227+
// GO386, GOARM, GOMIPS, etc.
228+
baseArch := strings.TrimSuffix(cfg.BuildContext.GOARCH, "le")
229+
fmt.Fprintf(h, "GO$GOARCH=%s\n", os.Getenv("GO"+strings.ToUpper(baseArch)))
228230

229231
// TODO(rsc): Convince compiler team not to add more magic environment variables,
230232
// or perhaps restrict the environment variables passed to subprocesses.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Set up fresh GOCACHE.
2+
env GOCACHE=$WORK/gocache
3+
mkdir $GOCACHE
4+
5+
# Building for mipsle without setting GOMIPS will use floating point registers.
6+
env GOARCH=mipsle
7+
env GOOS=linux
8+
go build -gcflags=-S f.go
9+
stderr ADDD.F[0-9]+,.F[0-9]+,.F[0-9]+
10+
11+
# Clean cache
12+
go clean -cache
13+
14+
# Building with GOMIPS=softfloat will not use floating point registers
15+
env GOMIPS=softfloat
16+
go build -gcflags=-S f.go
17+
! stderr ADDD.F[0-9]+,.F[0-9]+,.F[0-9]+
18+
19+
# Clean cache
20+
go clean -cache
21+
22+
# Build without setting GOMIPS
23+
env GOMIPS=
24+
go build -gcflags=-S f.go
25+
stderr ADDD.F[0-9]+,.F[0-9]+,.F[0-9]+
26+
27+
# Building with GOMIPS should still not use floating point registers.
28+
env GOMIPS=softfloat
29+
go build -gcflags=-S f.go
30+
! stderr ADDD.F[0-9]+,.F[0-9]+,.F[0-9]+
31+
32+
-- f.go --
33+
package f
34+
35+
func F(x float64) float64 {
36+
return x + x
37+
}

0 commit comments

Comments
 (0)