mirror of
https://github.com/golang/go
synced 2024-11-05 15:26:15 -07:00
cmd/dist: use gohostarch for ssa rewrite check
Fix a build failure when bootstrapping the Go compiler with go-bootstrap 1.4
while the environment contains GOARCH=riscv64.
Building Go toolchain1 using go-1.4-bootstrap-20171003.
src/cmd/compile/internal/ssa/rewriteRISCV64.go:4814
invalid operation: y << x (shift count type int64, must be unsigned integer)
This is because:
- buildtool.go:198: calls bootstrapRewriteFile(src)
- bootstrapRewriteFile: buildtool.go:283 calls:
- isUnneededSSARewriteFile: checks os.Getenv("GOARCH")
- isUnneededSSARewriteFile: returns "", false
- bootstrapRewriteFile: calls bootstrapFixImports
- boostrapFixImports: generates code go1.4 cannot compile
Instead of checking "GOARCH" in the environment, use the gohostarch variable.
Change-Id: Ie9c190498555c4068461fead6278a62e924062c6
GitHub-Last-Rev: 300d7a7fea
GitHub-Pull-Request: golang/go#52362
Reviewed-on: https://go-review.googlesource.com/c/go/+/400376
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
This commit is contained in:
parent
f70b93a6e9
commit
b3b8d2bfeb
16
src/cmd/dist/buildtool.go
vendored
16
src/cmd/dist/buildtool.go
vendored
@ -16,7 +16,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -243,11 +242,11 @@ var ssaRewriteFileSubstring = filepath.FromSlash("src/cmd/compile/internal/ssa/r
|
||||
|
||||
// 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
|
||||
}
|
||||
@ -262,13 +261,10 @@ func isUnneededSSARewriteFile(srcFile string) (archCaps string, unneeded bool) {
|
||||
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
|
||||
@ -277,9 +273,9 @@ func isUnneededSSARewriteFile(srcFile string) (archCaps string, unneeded bool) {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user