Skip to content

Instantly share code, notes, and snippets.

@4ad
Created January 16, 2015 16:03
Show Gist options
  • Save 4ad/c3799da7e486854e6655 to your computer and use it in GitHub Desktop.
Save 4ad/c3799da7e486854e6655 to your computer and use it in GitHub Desktop.
Teach cmd/dist about GOARCH=arm64
diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c
index e4b8b58..04bf6cf 100644
--- a/src/cmd/dist/build.c
+++ b/src/cmd/dist/build.c
@@ -39,7 +39,7 @@ static void dopack(char*, char*, char**, int);
static char *findgoversion(void);
// The known architecture letters.
-static char *gochars = "566899";
+static char *gochars = "5667899";
// The known architectures.
static char *okgoarch[] = {
@@ -47,6 +47,7 @@ static char *okgoarch[] = {
"arm",
"amd64",
"amd64p32",
+ "arm64",
"386",
"ppc64",
"ppc64le",
diff --git a/src/cmd/dist/buildgc.c b/src/cmd/dist/buildgc.c
index 64434d5..c0302eb 100644
--- a/src/cmd/dist/buildgc.c
+++ b/src/cmd/dist/buildgc.c
@@ -73,7 +73,7 @@ xatoi(char *s, char **end)
return val;
}
-// mkanames reads [5689].out.h and writes anames[5689].c
+// mkanames reads [56789].out.h and writes anames[56789].c
// The format is much the same as the Go opcodes above.
// It also writes out cnames array for C_* constants and the dnames
// array for D_* constants.
diff --git a/src/cmd/dist/unix.c b/src/cmd/dist/unix.c
index 0fd17c1..6b2e675 100644
--- a/src/cmd/dist/unix.c
+++ b/src/cmd/dist/unix.c
@@ -708,6 +708,8 @@ main(int argc, char **argv)
gohostarch = "386";
else if(contains(u.machine, "arm"))
gohostarch = "arm";
+ else if(contains(u.machine, "aarch64"))
+ gohostarch = "arm64";
else if(contains(u.machine, "ppc64le"))
gohostarch = "ppc64le";
else if(contains(u.machine, "ppc64"))
diff --git a/src/go/build/build.go b/src/go/build/build.go
index 12c20e5..c62425a 100644
--- a/src/go/build/build.go
+++ b/src/go/build/build.go
@@ -1386,6 +1386,8 @@ func ArchChar(goarch string) (string, error) {
return "6", nil
case "arm":
return "5", nil
+ case "arm64":
+ return "7", nil
case "ppc64", "ppc64le":
return "9", nil
}
diff --git a/src/go/build/syslist.go b/src/go/build/syslist.go
index 9246cbf..e84a066 100644
--- a/src/go/build/syslist.go
+++ b/src/go/build/syslist.go
@@ -5,4 +5,4 @@
package build
const goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows "
-const goarchList = "386 amd64 amd64p32 arm ppc64 ppc64le "
+const goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le "
@keithkml
Copy link

Hello, thanks for posting this. I'm trying to build on iOS arm64 using Minux's goios fork. Building on armv7 (GOARCH=arm) works great, but I can't get arm64 working, even with your patch.

Any thoughts on what's going on? I'm pretty new to the Go build system / toolchain so I'm not sure what's failing or why.

##### Building compilers and Go bootstrap tool for host, darwin/amd64.
lib9
libbio
liblink
cmd/gc
cmd/6l
cmd/7l
go tool dist: opendir /Users/keith/.../goios-arm64/src/cmd/7l: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment