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

darwin: add support for AppleM1 processor #225

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hlolli
Copy link

@hlolli hlolli commented Mar 9, 2023

This was quite annoying thing to debug :) since port_compiler doesn't print link time errors, even with DEBUG=1

image

I tested by first cleaning

$ m -rf priv _build c_src/*.{o,d} c_src/double-conversion/*.{o,d}

then in the rebar3 shell, I tested like seen in the screenshot

$ DEBUG=1 rebar3 shell

@HiteshVaghani
Copy link

Please merge this to the master. I am facing the same problem.

@dragonwasrobot
Copy link

I also have this issue

@nickva
Copy link
Collaborator

nickva commented Jun 13, 2024

I tried adding a mac os ci stage: https://github.com/davisp/jiffy/blob/master/.github/workflows/ci.yml#L40 running on macos-12 and macos-14. macos-14 seems to be arm based it seems: https://github.com/orgs/community/discussions/102846.

The CI passes currently passes on those workers, so wonder if this is still needed?

@hlolli
Copy link
Author

hlolli commented Jun 13, 2024

I tried adding a mac os ci stage: https://github.com/davisp/jiffy/blob/master/.github/workflows/ci.yml#L40 running on macos-12 and macos-14. macos-14 seems to be arm based it seems: https://github.com/orgs/community/discussions/102846.

The CI passes currently passes on those workers, so wonder if this is still needed?

I find hard to believe, but it could be that this got fixed in more recent llvm releases ? We already forked jiffy while back. I can't explain this result. Maybe the github docker images are multi-architecture but is running still on x86_64 🤷

@nickva
Copy link
Collaborator

nickva commented Jun 13, 2024

I find hard to believe,

🤷 I just went by https://github.com/orgs/community/discussions/102846 from Jan 13 this year:

We are also making the macOS 14 runner image available to GitHub hosted runners. Workflows executed on this image will run exclusively on the 3 vCPU M1 runner announced earlier today. To use the runner, simply update the runs-on: key in your YAML workflow file to macos-14

I don't have an ARM MacOS laptop so can't test it locally.

But something in llvm compiler being fixed sounds like a plausible explanation.

@hlolli
Copy link
Author

hlolli commented Jun 13, 2024

vCPU M1 runner

TIL nice !

I tried it again

hlolli@hlodvers-mbp ~/f/jiffy (master)> rebar3 compile
===> Fetching pc v1.15.0
===> Analyzing applications...
===> Compiling pc
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling jiffy
===> Compiling c_src/decoder.c
===> Compiling c_src/encoder.c
===> Compiling c_src/jiffy.c
===> Compiling c_src/termstack.c
===> Compiling c_src/utf8.c
===> Compiling c_src/util.c
===> Compiling c_src/doubles.cc
===> Compiling c_src/objects.cc
===> Compiling c_src/double-conversion/bignum-dtoa.cc
===> Compiling c_src/double-conversion/bignum.cc
===> Compiling c_src/double-conversion/cached-powers.cc
===> Compiling c_src/double-conversion/diy-fp.cc
===> Compiling c_src/double-conversion/double-conversion.cc
===> Compiling c_src/double-conversion/fast-dtoa.cc
===> Compiling c_src/double-conversion/fixed-dtoa.cc
===> Compiling c_src/double-conversion/strtod.cc
===> Linking /Users/hlolli/forks/jiffy/priv/jiffy.so
> rebar3 shell
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling jiffy
Erlang/OTP 25 [erts-13.2.2.4] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1]

Eshell V13.2.2.4  (abort with ^G)
1> jiffy:decode(<<"{\"foo\": \"bar\"}">>).
=WARNING REPORT==== 13-Jun-2024::20:18:14.250054 ===
The on_load function for module jiffy returned:
{error,{bad_lib,"Failed to find library init function: 'dlsym(0x95583830, _nif_init): symbol not found'"}}

** exception error: undefined function jiffy:decode/1
2>

notsureif...

> file /Users/hlolli/forks/jiffy/priv/jiffy.so
/Users/hlolli/forks/jiffy/priv/jiffy.so: Mach-O 64-bit arm64 bundle, flags:<|DYLDLINK>

compare that to arweave (which uses the jiffy fork I mentioned with this fix)

> file ./_build/default/lib/jiffy/priv/jiffy.so
./_build/default/lib/jiffy/priv/jiffy.so: Mach-O 64-bit arm64 executable, flags:<|DYLDLINK|BINDS_TO_WEAK|PIE>

I don't know what to make of this, if this was the issue, been a while

@nickva
Copy link
Collaborator

nickva commented Jun 13, 2024

Thanks for checking @hlolli, much appreciated! Let's keep the PR open, it may need a longer investigation and may still be valid despite the CI on GH Actions passing.

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

Successfully merging this pull request may close these issues.

4 participants