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

Cannot compile with Apple M1 #3632

Closed
cna0 opened this issue May 20, 2021 · 23 comments
Closed

Cannot compile with Apple M1 #3632

cna0 opened this issue May 20, 2021 · 23 comments

Comments

@cna0
Copy link
Contributor

cna0 commented May 20, 2021

I'm trying to build the project on Mac M1, but NIFs fail to compile. I cannot pass through compiling the emcl dependency, so I'm not sure if there's any other dependency having the same issue. However, herumi/mcl@b0abe61 has added support for M1 which is not included in emcl.

@marc0olo
Copy link
Contributor

this is interesting. @omar-saadoun was trying to run the new node versions in our development tool aeproject and he also faced problems with his Apple M1.

he isn't able to run the docker-image of the node due to this issue: docker/for-mac#5148

cc @mradkov

@omar-saadoun
Copy link
Contributor

Thanks @marc0olo like you said this is related to aeternity/aeproject#376

@cna0
Copy link
Contributor Author

cna0 commented May 27, 2021

The simplest workaround I found was to enable Rosetta for the Terminal and then compile the project (of course without Docker).

@omar-saadoun
Copy link
Contributor

May be it will work for the node itself but I think it won't for aeproject

@earlyriser99
Copy link
Contributor

earlyriser99 commented Jun 30, 2021

I played with this a bit. Updating the git submodule in emcl so its mcl points to the latest version allows the build process to complete.

Unfortunately this wasn't enough to get the node up and running. The enacl build is not linking libsodium.so to its nif. I tried changing the enacl rebar.config to explicitly build arm64 instead of x86-64, but the link step then complained about linking incompatible architectures.

Possibly my libsodium.so was built wrong. More work needed

@subhod-i
Copy link

@earlyriser99 What about re-installing the arm64 libsodium? this might resolve the linking incompatible architectures issue.

@subhod-i
Copy link

Support and publishing docker image for platform arm64 is important as arm64 becomes mainstream.

@seanhinde
Copy link
Contributor

An update: I now have a native build running locally on my machine.

Next step is to incorporate all the manual steps into the proper build of the node and document the process.

After that I can take a look at an arm64 docker build.

@subhod-i
Copy link

@seanhinde Thanks for the quick update. I know the current native build fix is not documented, can you guide us on running the native build?
Compiling node manually on the terminal with Rosetta2 shall work right?

@marc0olo
Copy link
Contributor

After that I can take a look at an arm64 docker build.

I know such question is sometimes hard to answer 😅 - do you have a rough estimate for this?

@seanhinde
Copy link
Contributor

I'm planning to have a go at tidying this up this weekend. At the moment I only have evening and weekend access to the m1 machine..

@seanhinde
Copy link
Contributor

@seanhinde Thanks for the quick update. I know the current native build fix is not documented, can you guide us on running the native build?

There are some changes needed to aeminer so it's not just documenting a process. It should be seamless when I'm done.

Compiling node manually on the terminal with Rosetta2 shall work right?

This I have not tried.

@seanhinde
Copy link
Contributor

Darn. I lose the m1 machine this weekend. Will be next week now.

@omar-saadoun
Copy link
Contributor

@seanhinde I have M1. Can I help you somehow?

@seanhinde
Copy link
Contributor

Not right now, but I'll see if I can find a way to use you as the test subject - a few branches need to come together across a few of our repos as well.

@seanhinde
Copy link
Contributor

seanhinde commented Nov 25, 2021

There is a branch at https://github.com/aeternity/aeternity/tree/gh-3632-apple-arm-m1-support

Right now for me it all builds cleanly so long as the normal dependencies libsodium, libgmp etc are available as native arm libs

I'd appreciate it if a few more folks could try this branch on their machine before pushing to the mainline. @omar-saadoun ?

There is one failing unit test for me at the moment

git clone https://github.com/aeternity/aeternity
cd aeternity
git checkout gh-3632-apple-arm-m1-support
make
make eunit-latest
make ct-latest

@omar-saadoun
Copy link
Contributor

I'm getting this error after make command:

env: escript: No such file or directory
make: *** [internal-compile-deps] Error 127

@seanhinde
Copy link
Contributor

You need to have erlang installed as well

@omar-saadoun
Copy link
Contributor

Hmm...I'm supposed to have it already any particular procedure?

@seanhinde
Copy link
Contributor

More investigations led to this procedure:

Following the instructions at Build from Source with the following differences:

brew install cmake

Then before running make in the checked out branch run:

export PATH=/opt/homebrew/bin:$PATH
export CFLAGS="-I/opt/homebrew/include"
export LDFLAGS="-L/opt/homebrew/lib"

seanhinde added a commit that referenced this issue Nov 29, 2021
@subhod-i
Copy link

@seanhinde since the FIX is in master, I was trying to pull the latest master tagged docker image from the hub and try running it. Encountered the same error where the container exited in a few seconds.

Native binary I am able to build.

@marc0olo
Copy link
Contributor

@subhod-i I think @thepiwo opened a new issue for that, see #3799

@seanhinde
Copy link
Contributor

Closing this one with a final PR to update the docs with details from this ticket #3820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants