seredat / karbowanec

Karbo (Karbovanets) - Digital Exchange Medium - cryptocurrency made in Ukraine, CryptoNote protocol implementation.
https://karbo.io/
Other
104 stars 66 forks source link

Undefined symbols for architecture arm64: "_getmcontext" "_setmcontext" for Mac M1 CPU #183

Open aivve opened 2 years ago

aivve commented 2 years ago
[ 91%] Linking CXX executable karbowanecd
Undefined symbols for architecture arm64:
  "_getmcontext", referenced from:
      System::Dispatcher::Dispatcher() in libSystem.a(Dispatcher.cpp.o)
      _swapcontext in libSystem.a(Context.c.o)
  "_setmcontext", referenced from:
      _swapcontext in libSystem.a(Context.c.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
aivve commented 2 years ago

For arm mac cpu's need to rewrite Dispatcher

driquelme commented 2 years ago

Regarding the above comment, the change would require writing arm64 asm code?

aivve commented 2 years ago

Maybe not necessarily asm, perhaps something like Android version

aivve commented 2 years ago

Rewrote asm code but only got segmentation fault.

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000000000000
error: memory read failed for 0x0
aivve commented 2 years ago

The size of pthread_mutex_t for some reason is 64 whereas on arm64 it should be 48 ??

aivve commented 2 years ago

After df8d9d9f4a5fbfaa6edaea965b11415164252fc3 it catchers the error:

ERROR   Exception: Dispatcher::getReusableContext, swapcontext failed, result=22, Invalid argument

not crashes but exits

aivve commented 2 years ago

same exception is caught on lastest Dispatcher version, also replaced context functions by using ucontext.h with the same result