Skip to content

Commit

Permalink
cmd/internal/obj: validate GOARM environment variable's value before use
Browse files Browse the repository at this point in the history
I was previously setting GOARM=arm5 (due to confusion with previously
seeing buildall.sh's temporary of "arm5" as a GOARCH and
misremembernig), but GOARM=arm5 was acting like GOARM=5 only on
accident. See https://go-review.googlesource.com/#/c/10023/

Instead, fail if GOARM is not a known value.

Change-Id: I9ba4fd7268df233d40b09f0431f37cd85a049847
Reviewed-on: https://go-review.googlesource.com/10024
Reviewed-by: Minux Ma <minux@golang.org>
  • Loading branch information
bradfitz committed May 13, 2015
1 parent fd5b8aa commit 5c7f944
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cmd/internal/obj/util.go
Expand Up @@ -213,10 +213,17 @@ func Getgoos() string {
}

func Getgoarm() string {
return envOr("GOARM", defaultGOARM)
switch v := envOr("GOARM", defaultGOARM); v {
case "5", "6", "7":
return v
}
// Fail here, rather than validate at multiple call sites.
log.Fatalf("Invalid GOARM value. Must be 5, 6, or 7.")
panic("unreachable")
}

func Getgo386() string {
// Validated by cmd/8g.
return envOr("GO386", defaultGO386)
}

Expand Down

0 comments on commit 5c7f944

Please sign in to comment.