Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: bootstrap: unset goarch when calling bootstrapRewriteFile
The GOOS and GOARCH environment variables should be unset before calling mkbuildcfg, as the target GOOS and GOARCH is not relevant while compiling the bootstrap Go compiler using the C-based go-bootstrap go1.4 compiler. This change fixes a build failure when 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 By unsetting GOARCH here we are causing isUnneededSSARewriteFile to return true instead of false which generates stub functions bypassing the incompatible code. buildtool.go:272 in isUnneededSSARewriteFile is the only place the GOARCH environment variable is checked apart from the xinit function. This patch simply moves the os.Setenv("GOARCH", "") to before the block of code where bootstrapRewriteFile is called. [Buildroot]: submitted to upstream: - golang#52583 - https://go-review.googlesource.com/c/go/+/400376 - GitHub-Pull-Request: golang#52362 Signed-off-by: Christian Stewart <christian@paral.in>
- Loading branch information