-
Notifications
You must be signed in to change notification settings - Fork 59
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
problem compiling and running with Apple Silicon processor #53
Comments
Hi! The particular bug is because for some reason, the compiled One thing I wonder is if this only pertains to these bindings, or if a small nif example fails in general with Apple's compiler. It might also be you need to add some special flags to the compiler for this to work. The underlying |
actions/runner-images#2187 would be really nice to have here. Then I could go enable building for that platform. |
Another data point is that |
Hi @nicocaille, I ran into this exact same issue on a different library (as well as this one) and fixed both by running:
For some reason the compiler gets confused when you have x86 libraries installed so you just have to point it in the right direction. This is alongside removing the |
I'm unsure why it's specified since darwin has been uni-arch for ages, but the arm version is smart enough to know which arch to build. M1 Mac Mini ``` dabaer@Mac-mini enacl % uname -m arm64 dabaer@Mac-mini enacl % make compile rebar3 compile ===> Verifying dependencies... ===> Compiling c_src/aead.c ===> Compiling c_src/enacl.c ===> Compiling c_src/enacl_ext.c ===> Compiling c_src/enacl_nif.c ===> Compiling c_src/generichash.c ===> Compiling c_src/hash.c ===> Compiling c_src/kdf.c ===> Compiling c_src/kx.c ===> Compiling c_src/public.c ===> Compiling c_src/pwhash.c ===> Compiling c_src/randombytes.c ===> Compiling c_src/secret.c ===> Compiling c_src/secretstream.c ===> Compiling c_src/sign.c ===> Linking /Users/jadenn/Documents/arviksa/enacl/priv/enacl_nif.so ===> Analyzing applications... ===> Compiling enacl dabaer@Mac-mini enacl % make tests rebar3 ct ===> Verifying dependencies... ===> Analyzing applications... ===> Compiling enacl ===> Running Common Test suites... %%% enacl_SUITE: .......... All 10 tests passed. ``` Intel Mac Mini ``` Dakoras-Mini:enacl dakora$ uname -m x86_64 Dakoras-Mini:enacl dakora$ make compile rebar3 compile ===> Verifying dependencies... ===> Compiling c_src/aead.c ===> Compiling c_src/enacl.c ===> Compiling c_src/enacl_ext.c ===> Compiling c_src/enacl_nif.c ===> Compiling c_src/generichash.c ===> Compiling c_src/hash.c ===> Compiling c_src/kdf.c ===> Compiling c_src/kx.c ===> Compiling c_src/public.c ===> Compiling c_src/pwhash.c ===> Compiling c_src/randombytes.c ===> Compiling c_src/secret.c ===> Compiling c_src/secretstream.c ===> Compiling c_src/sign.c ===> Linking /Users/dakora/enacl/priv/enacl_nif.so ===> Analyzing applications... ===> Compiling enacl Dakoras-Mini:enacl dakora$ make tests rebar3 ct ===> Verifying dependencies... ===> Analyzing applications... ===> Compiling enacl ===> Running Common Test suites... %%% enacl_SUITE: .......... All 10 tests passed. ```
I'm unsure why it's specified since darwin has been uni-arch for ages, but the arm version is smart enough to know which arch to build.
Lines 21 to 23 in e02325d
|
For those who are still waiting for the PRs there's a quick workaround you can do in your environment that requires no modification to the library: Export the paths for homebrew like @dabaer suggested:
Now, also specify the
Now clean and rebuild your enacl dep and it will actually produce a dual-architecture library. |
Hello, The libsodium library was installed via homebrew, version ===> Fetching pc v1.14.0
===> Analyzing applications...
===> Compiling pc
===> Compiling c_src/aead.c
===> Compiling c_src/enacl.c
===> Compiling c_src/enacl_ext.c
===> Compiling /Users/taylor/build/lightning/deps/enacl/c_src/enacl_nif.c
===> /Users/taylor/build/lightning/deps/enacl/c_src/enacl_nif.c:435:83: error: incompatible function pointer types initializing 'void (*)(ErlNifEnv *, void *)' (aka 'void (*)(struct enif_environment_t *, void *)') with an expression of type 'int (ErlNifEnv *, void **, ERL_NIF_TERM)' (aka 'int (struct enif_environment_t *, void **, unsigned long)') [-Wincompatible-function-pointer-types]
ERL_NIF_INIT(enacl_nif, nif_funcs, enacl_crypto_load, NULL, enacl_crypto_upgrade, enacl_crypto_unload);
^~~~~~~~~~~~~~~~~~~
/Users/taylor/.asdf/installs/erlang/26.0.2/erts-14.0.2/include/erl_nif.h:432:25: note: expanded from macro 'ERL_NIF_INIT'
LOAD, RELOAD, UPGRADE, UNLOAD, \
^~~~~~
1 error generated.
** (Mix) Could not compile dependency :enacl, "/Users/taylor/.asdf/installs/elixir/1.16.2-otp-26/.mix/elixir/1-16/rebar3 bare compile --paths /Users/taylor/build/lightning/_build/dev/lib/*/ebin" command failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile enacl --force", update it with "mix deps.update enacl" or clean it with "mix deps.clean enacl" |
@midigofrank I ran into the same issue recently, the fixes I initially reported here no longer seem to work on Apple Silicon. I haven't been able to find a solution and have since migrated to using Erlang's :crypto module for random bytes, and :argon2_elixir for hashing (which is all I used libsodium for). I'm not sure of any alternatives for the Box type functions for encryption and signatures unfortunately. |
For those who are having issues with M1, the aeternity fork compiles and loads just fine: https://github.com/aeternity/enacl |
Niice, the aeternity fork works fine . Thanks for mentioning this @arpunk 🙌 |
I ran into this issue with my x86_64 cpu. Not sure how to fix this. I tried the fork mentioned here and it worked. But ideally would like to use the official published hex. |
Hello,
I have erlang compiled on macOS Big Sur with arm64 arch:
I changed the
rebar.config
file to take into account theCFLAGS
/CXXFLAGS
/LDFLAGS
which i think were adapted to Apple Silicon framework:I checked that the file is compiled for the arm64 with the following:
I tried to call the sign_detached function as an example to see if it is working, getting the following
warn
/error
message:I don't know if i missed some fields in the compile arguments or if it is simply not compatible at the moment.
Thanks for your help
The text was updated successfully, but these errors were encountered: