Skip to content
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

Apple Silicon M1 support? #9385

Closed
paulmillr opened this issue Aug 14, 2021 · 21 comments · Fixed by #10981
Closed

Apple Silicon M1 support? #9385

paulmillr opened this issue Aug 14, 2021 · 21 comments · Fixed by #10981
Labels
Enhancement New feature or request Help Wanted Extra attention is needed Tracking Gotta Catch 'Em All

Comments

@paulmillr
Copy link

paulmillr commented Aug 14, 2021

Feature Description

Prysm needs native support for Apple Silicon M1. The chips are extremely efficient and silent.

Currently it seems to be possible to compile AMD64 code for ARM with Rosetta, which is meh - it's non-native, not as energy-efficient as ARM apps etc.

All clients status:

@paulmillr paulmillr added the Tracking Gotta Catch 'Em All label Aug 14, 2021
@paulmillr paulmillr changed the title Apple Silicon M1 ARM support Apple Silicon M1 support? Aug 14, 2021
@nisdas nisdas added the Enhancement New feature or request label Aug 18, 2021
@nisdas
Copy link
Member

nisdas commented Aug 18, 2021

@prestonvanloon , how much work would it be to add darwin_arm64 support ? Go has supported it since 1.16 and for bazel we should have a darwin toolchain that can compile this for us.

@asanso
Copy link
Contributor

asanso commented Aug 18, 2021

Currently it seems to be possible to compile AMD64 code for ARM with Rosetta,

@paulmillr may you share a workaround here? I tried Rosetta on M1 and still no luck

@asanso
Copy link
Contributor

asanso commented Sep 7, 2021

Adding a patch to update herumi that has now static binary for M1 mac.

diff --git a/go.mod b/go.mod
index 32d08f953..c5c14a309 100644
--- a/go.mod
+++ b/go.mod
@@ -41,7 +41,7 @@ require (
        github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
        github.com/grpc-ecosystem/grpc-gateway/v2 v2.0.1
        github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
-       github.com/herumi/bls-eth-go-binary v0.0.0-20210130185500-57372fb27371
+       github.com/herumi/bls-eth-go-binary v0.0.0-20210902234237-7763804ee078
        github.com/huin/goupnp v1.0.2 // indirect
        github.com/ianlancetaylor/cgosymbolizer v0.0.0-20200424224625-be1b05b0b279
        github.com/ipfs/go-ipfs-addr v0.0.1
diff --git a/go.sum b/go.sum
index 0ff120a42..db416ce07 100644
--- a/go.sum
+++ b/go.sum
@@ -498,6 +498,8 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
 github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
 github.com/herumi/bls-eth-go-binary v0.0.0-20210130185500-57372fb27371 h1:LEw2KkKciJEr3eKDLzdZ/rjzSR6Y+BS6xKxdA78Bq6s=
 github.com/herumi/bls-eth-go-binary v0.0.0-20210130185500-57372fb27371/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U=
+github.com/herumi/bls-eth-go-binary v0.0.0-20210902234237-7763804ee078 h1:7V5qCWTKJ0T/9KjYo2dBFaIDEb2dvy3onu9nqOIIFDc=
+github.com/herumi/bls-eth-go-binary v0.0.0-20210902234237-7763804ee078/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U=
 github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
 github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
 github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM=

@nisdas
Copy link
Member

nisdas commented Sep 7, 2021

To add on to that, the above patch along with this one will allow go build to work
https://gist.github.com/nisdas/a84c92e987611288a07521f459e24e41

So you can build and run prysm using go to build . However translating this to bazel will take a bit more work as we will also require the appropriate toolchain for darwin-arm64.

@asanso
Copy link
Contributor

asanso commented Sep 7, 2021

Thanks @nisdas how about committing this 2 patches though at least?

@prestonvanloon
Copy link
Member

Thanks @nisdas how about committing this 2 patches though at least?

This sounds good. Please submit a patch for dependency updates to unblock M1 compilation. Cross-compilation will be more involved, but the dependency updates are required in both scenarios.

@asanso
Copy link
Contributor

asanso commented Sep 8, 2021

Please submit a patch for dependency updates

@prestonvanloon both patches are attached to this issue

@nisdas
Copy link
Member

nisdas commented Sep 15, 2021

@asanso #9600 adds in support for go builds in M1

@mrabino1
Copy link
Contributor

We will probably need to update the prysm.sh script to pull the correct binaries.

@nisdas
Copy link
Member

nisdas commented Sep 17, 2021

@mrabino1 Unfortunately that would require changes to our cross compiler toolchain. What the PR does is allow you to build and run prysm on a M1 using go build. However to generate binaries that can be tagged and released will take more work.

@mrabino1
Copy link
Contributor

@nisdas gotcha... I am more referencing that the prysm.sh script was modified to pull binaries as a workaround (as it was failing).. today it works.. but not running arm binaries. just the macOS ones... in the future, and if the team wants to support it (e.g the work you are referencing) the prysm.sh script will need to be modified ..

@nisdas
Copy link
Member

nisdas commented Sep 17, 2021

Gotcha, yes that would require a fix to our scripts for it.

@prestonvanloon prestonvanloon added the Help Wanted Extra attention is needed label Jan 11, 2022
@prestonvanloon
Copy link
Member

Also see #7950 (this issue may be a duplicate)

@leolara
Copy link
Contributor

leolara commented Jun 7, 2022

I think the status of this is almost 99% complete with this PR: #10192

@leolara
Copy link
Contributor

leolara commented Jun 7, 2022

I think just this is missing: #10263

@gdistasi
Copy link

Do you think it is going to be ready before the Merge?

@leolara
Copy link
Contributor

leolara commented Jun 22, 2022

from #7950 (comment)

prestonvanloon said:

the true blocker for this is the cross compilation config.

For darwin amd64, we run the following

bazel build --config=osx_amd64_docker //cmd/beacon-chain //cmd/validator //cmd/client-stats
We need to establish a osx_arm64_docker config that would produce arm64 binaries.

@leolara
Copy link
Contributor

leolara commented Jun 22, 2022

@gdistasi I am not sure, there are many items to takle in implementing cross compilation. But the normal compilation on a M1 works already.

@tjayrush
Copy link

@gdistasi I am not sure, there are many items to takle in implementing cross compilation. But the normal compilation on a M1 works already.

Can you point me to instructions on how to do this?

@prestonvanloon
Copy link
Member

@tjayrush

If you install M1 native go on your M1 device, you can build Prysm with go like go build ./cmd/beacon-chain and it will be compiled for the M1 chip.

We have also started issuing M1 supported binaries with each release. They are labeled darwin_arm64.

Please DM me if you need more support!

@gdistasi
Copy link

gdistasi commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Help Wanted Extra attention is needed Tracking Gotta Catch 'Em All
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants