Skip to content

go: Apple Silicon updates #65696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Formula/go.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class Go < Formula
# Don't update this unless this version cannot bootstrap the new version.
resource "gobootstrap" do
on_macos do
url "https://storage.googleapis.com/golang/go1.7.darwin-amd64.tar.gz"
sha256 "51d905e0b43b3d0ed41aaf23e19001ab4bc3f96c3ca134b48f7892485fc52961"
url "https://golang.org/dl/go1.12.17.darwin-amd64.tar.gz"
sha256 "a2f58b4bf10f3e882c1a43eba27a2aba65fc815384fbdfc46331c13bca5f5f24"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no objection to bootstrapping with a recent compiler. We'll probably need a recent version for ARM anyway

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried to build an ARM go with this compiler. I can get back to you with the lowest version that compiles the patched Go trunk later!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that 1.12.17 can build a native arm64 go.

Building Go cmd/dist using /Users/arnaud/go1.4. (go1.12.17 darwin/amd64)
Building Go toolchain1 using /Users/arnaud/go1.4.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for host, darwin/amd64.
Building packages and commands for target, darwin/arm64.
---
Installed Go for darwin/arm64 in /Users/arnaud/Desktop/goarm
Installed commands in /Users/arnaud/Desktop/goarm/bin

~/D/g/src git:() ➜ ../bin/darwin_arm64/go version
go version devel +7716a2fbb7 Sun Nov 22 11:44:49 2020 -0500 darwin/arm64

bin/go is a amd64 build for some reason, but it's probably something that should wait until 1.16 is released, they might change some stuff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bin/go is a amd64 build for some reason

Then it's not a native arm64 go, is it? I don't understand that contradiction.

Copy link
Author

@abarisain abarisain Nov 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I failed to mention this in my original PR, but this PR itself isn't sufficient to build a native arm Go: this will have to wait for 1.16.

Which is why it's probably best if it's not merged until 1.16 (but this can be used as a reference of what needs to be done). I wanted to explore why bootstraped Go was crashing (as reported in Homebrew/brew#7857), and prepare some of the investigative work needed for 1.16.

Then it's not a native arm64 go, is it? I don't understand that contradiction.

I don't get that either, but if you build with this command, you get:

  • amd64 go in bin/go
  • arm64 go in bin/darwin_arm64/go

bin/darwin_arm64/ contains a fully working distribution that works perfectly if you move it somewhere and set it as your GOROOT: I've been using that for a couple days now.
Not sure why an amd go gets built in bin/ but I'm not really familiar with Go's make.bash and bootstrap.bash. It may be a simple build script difference between bootstrap.bash and make.bash?
It might require another change in the buildscript on arm though.

Edit:

Ah, I think that this happens because we're actually cross compiling to another arch, as shown by those two log lines:

Building packages and commands for host, darwin/amd64.
Building packages and commands for target, darwin/arm64.

It's annoyingly hard not to confuse arm64 and amd64 if you're not paying extra attention when reading. Thought those lines were the same at first

end

on_linux do
Expand All @@ -54,6 +54,10 @@ def install

cd "src" do
ENV["GOROOT_FINAL"] = libexec
if MacOS.version >= :big_sur
# Required for Apple Silicon Rosetta: Without it, Go will hang while building
ENV["GODEBUG"] = "asyncpreemptoff=1"
end
system "./make.bash", "--no-clean"
end

Expand Down