Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
package/go: add support for riscv64 architecture
Enable the supported "riscv64" GOARCH. Add a patch to fix a build failure due to GOARCH leaking into the calls to the go-bootstrap compiler. Unsets the GOARCH before calling go-bootstrap. PR: golang/go#52362 Signed-off-by: Christian Stewart <christian@paral.in> --- v1 -> v2: - fixed build error with go-bootstrap v2 -> v3: - go: does not support riscv-32bit
- Loading branch information
Showing
4 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
package/go/0002-build-bootstrap-set-environment-before-generating-bu.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
From 00f3f4ee0d477779c87e4e60b08708362670e122 Mon Sep 17 00:00:00 2001 | ||
From: Christian Stewart <christian@paral.in> | ||
Date: Thu, 14 Apr 2022 13:34:26 -0700 | ||
Subject: [PATCH] build: bootstrap: set environment before generating buildcfg | ||
|
||
The GOOS and GOARCH environment variables should be unset before calling | ||
mkbuildcfg. 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) | ||
|
||
There is a build issue with go1.4 with the riscv64 code: however, why is the | ||
riscv64 code being compiled at all? | ||
|
||
GOARCH is set when calling mkbuildcfg, so go1.4 is trying to compile riscv64. | ||
--- | ||
src/cmd/dist/buildtool.go | 56 ++++++++++++++++++++------------------- | ||
1 file changed, 29 insertions(+), 27 deletions(-) | ||
|
||
diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go | ||
index 036f8c52fa..73f6524969 100644 | ||
--- a/src/cmd/dist/buildtool.go | ||
+++ b/src/cmd/dist/buildtool.go | ||
@@ -112,9 +112,6 @@ func bootstrapBuildTools() { | ||
} | ||
xprintf("Building Go toolchain1 using %s.\n", goroot_bootstrap) | ||
|
||
- mkbuildcfg(pathf("%s/src/internal/buildcfg/zbootstrap.go", goroot)) | ||
- mkobjabi(pathf("%s/src/cmd/internal/objabi/zbootstrap.go", goroot)) | ||
- | ||
// Use $GOROOT/pkg/bootstrap as the bootstrap workspace root. | ||
// We use a subdirectory of $GOROOT/pkg because that's the | ||
// space within $GOROOT where we store all generated objects. | ||
@@ -126,6 +123,34 @@ func bootstrapBuildTools() { | ||
base := pathf("%s/src/bootstrap", workspace) | ||
xmkdirall(base) | ||
|
||
+ // Set up environment for invoking Go 1.4 go command. | ||
+ // GOROOT points at Go 1.4 GOROOT, | ||
+ // GOPATH points at our bootstrap workspace, | ||
+ // GOBIN is empty, so that binaries are installed to GOPATH/bin, | ||
+ // and GOOS, GOHOSTOS, GOARCH, and GOHOSTOS are empty, | ||
+ // so that Go 1.4 builds whatever kind of binary it knows how to build. | ||
+ // Restore GOROOT, GOPATH, and GOBIN when done. | ||
+ // Don't bother with GOOS, GOHOSTOS, GOARCH, and GOHOSTARCH, | ||
+ // because setup will take care of those when bootstrapBuildTools returns. | ||
+ | ||
+ defer os.Setenv("GOROOT", os.Getenv("GOROOT")) | ||
+ os.Setenv("GOROOT", goroot_bootstrap) | ||
+ | ||
+ defer os.Setenv("GOPATH", os.Getenv("GOPATH")) | ||
+ os.Setenv("GOPATH", workspace) | ||
+ | ||
+ defer os.Setenv("GOBIN", os.Getenv("GOBIN")) | ||
+ os.Setenv("GOBIN", "") | ||
+ | ||
+ os.Setenv("GOOS", "") | ||
+ os.Setenv("GOHOSTOS", "") | ||
+ os.Setenv("GOARCH", "") | ||
+ os.Setenv("GOHOSTARCH", "") | ||
+ | ||
+ // Create the build config files. | ||
+ mkbuildcfg(pathf("%s/src/internal/buildcfg/zbootstrap.go", goroot)) | ||
+ mkobjabi(pathf("%s/src/cmd/internal/objabi/zbootstrap.go", goroot)) | ||
+ | ||
// Copy source code into $GOROOT/pkg/bootstrap and rewrite import paths. | ||
writefile("module bootstrap\n", pathf("%s/%s", base, "go.mod"), 0) | ||
for _, dir := range bootstrapDirs { | ||
@@ -172,30 +197,6 @@ func bootstrapBuildTools() { | ||
}) | ||
} | ||
|
||
- // Set up environment for invoking Go 1.4 go command. | ||
- // GOROOT points at Go 1.4 GOROOT, | ||
- // GOPATH points at our bootstrap workspace, | ||
- // GOBIN is empty, so that binaries are installed to GOPATH/bin, | ||
- // and GOOS, GOHOSTOS, GOARCH, and GOHOSTOS are empty, | ||
- // so that Go 1.4 builds whatever kind of binary it knows how to build. | ||
- // Restore GOROOT, GOPATH, and GOBIN when done. | ||
- // Don't bother with GOOS, GOHOSTOS, GOARCH, and GOHOSTARCH, | ||
- // because setup will take care of those when bootstrapBuildTools returns. | ||
- | ||
- defer os.Setenv("GOROOT", os.Getenv("GOROOT")) | ||
- os.Setenv("GOROOT", goroot_bootstrap) | ||
- | ||
- defer os.Setenv("GOPATH", os.Getenv("GOPATH")) | ||
- os.Setenv("GOPATH", workspace) | ||
- | ||
- defer os.Setenv("GOBIN", os.Getenv("GOBIN")) | ||
- os.Setenv("GOBIN", "") | ||
- | ||
- os.Setenv("GOOS", "") | ||
- os.Setenv("GOHOSTOS", "") | ||
- os.Setenv("GOARCH", "") | ||
- os.Setenv("GOHOSTARCH", "") | ||
- | ||
// Run Go 1.4 to build binaries. Use -gcflags=-l to disable inlining to | ||
// workaround bugs in Go 1.4's compiler. See discussion thread: | ||
// https://groups.google.com/d/msg/golang-dev/Ss7mCKsvk8w/Gsq7VYI0AwAJ | ||
@@ -217,6 +218,7 @@ func bootstrapBuildTools() { | ||
cmd = append(cmd, "-toolexec="+tool) | ||
} | ||
cmd = append(cmd, "bootstrap/cmd/...") | ||
+ | ||
run(base, ShowOutput|CheckExit, cmd...) | ||
|
||
// Copy binaries into tool binary directory. | ||
-- | ||
2.35.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters