"os"
"path/filepath"
"regexp"
- "runtime"
"strings"
)
// isUnneededSSARewriteFile reports whether srcFile is a
// src/cmd/compile/internal/ssa/rewriteARCHNAME.go file for an
-// architecture that isn't for the current runtime.GOARCH.
+// architecture that isn't for the given GOARCH.
//
// When unneeded is true archCaps is the rewrite base filename without
// the "rewrite" prefix or ".go" suffix: AMD64, 386, ARM, ARM64, etc.
-func isUnneededSSARewriteFile(srcFile string) (archCaps string, unneeded bool) {
+func isUnneededSSARewriteFile(srcFile, goArch string) (archCaps string, unneeded bool) {
if !strings.Contains(srcFile, ssaRewriteFileSubstring) {
return "", false
}
archCaps = fileArch
fileArch = strings.ToLower(fileArch)
fileArch = strings.TrimSuffix(fileArch, "splitload")
- if fileArch == os.Getenv("GOHOSTARCH") {
+ if fileArch == goArch {
return "", false
}
- if fileArch == strings.TrimSuffix(runtime.GOARCH, "le") {
- return "", false
- }
- if fileArch == strings.TrimSuffix(os.Getenv("GOARCH"), "le") {
+ if fileArch == strings.TrimSuffix(goArch, "le") {
return "", false
}
return archCaps, true
func bootstrapRewriteFile(srcFile string) string {
// During bootstrap, generate dummy rewrite files for
// irrelevant architectures. We only need to build a bootstrap
- // binary that works for the current runtime.GOARCH.
+ // binary that works for the current gohostarch.
// This saves 6+ seconds of bootstrap.
- if archCaps, ok := isUnneededSSARewriteFile(srcFile); ok {
+ if archCaps, ok := isUnneededSSARewriteFile(srcFile, gohostarch); ok {
return fmt.Sprintf(`// Code generated by go tool dist; DO NOT EDIT.
package ssa