willbryant / kitchen_sync

Fast unidirectional synchronization - make or efficiently update a copy of a database, without slow dumping & reloading
MIT License
282 stars 35 forks source link

Kitchen_sync doesn't build on Mac M1 arm64 #100

Closed oobles closed 3 years ago

oobles commented 3 years ago

On Macbook with arm64 M1 processor:

% brew install kitchen-sync Error: kitchen-sync: no bottle available! You can try to install from source with: brew install --build-from-source kitchen-sync Please note building from source is unsupported. You will encounter build failures with some formulae. If you experience any issues please create pull requests instead of asking for help on Homebrew's GitHub, Twitter or any other official channels.

Installing from source yields:

% brew install --build-from-source kitchen-sync ==> Downloading https://github.com/willbryant/kitchen_sync/archive/v2.10.tar.gz Already downloaded: /Users/david/Library/Caches/Homebrew/downloads/d72c77c42ecdd88237ce695224cbfcc5ecb815a3bafce4e246988bfc7f2c1459--kitchen_sync-2.10.tar.gz ==> cmake . -DMySQL_INCLUDE_DIR=/opt/homebrew/opt/mysql-client/include/mysql -DMySQL_LIBRARY_DIR=/opt/homebrew/opt/mysql-client/lib -DPostgreSQL_INCLUDE_DIR=/opt/homebrew/opt/libpq/include -DPostgreSQL_LIBRARY_DIR=/ ==> make install Last 15 lines from /Users/david/Library/Logs/Homebrew/kitchen-sync/02.make: CATCH_BREAK_INTO_DEBUGGER(); ^ /tmp/kitchen-sync-20210412-14758-1hvi87p/kitchen_sync-2.10/src/yaml-cpp/include/../../catch2/catch.hpp:5485:75: note: expanded from macro 'CATCH_BREAK_INTO_DEBUGGER'

define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); }

                                                                      ^

/tmp/kitchen-sync-20210412-14758-1hvi87p/kitchen_sync-2.10/src/yaml-cpp/include/../../catch2/catch.hpp:5464:34: note: expanded from macro 'CATCH_TRAP'

define CATCH_TRAP() asm("int $3\n" : : ) / NOLINT /

                             ^
:1:6: note: instantiated into assembly here int $3 ^ 2 errors generated. make[2]: *** [test/CMakeFiles/ks_unit_tests.dir/ks_unit_tests.cpp.o] Error 1 make[1]: *** [test/CMakeFiles/ks_unit_tests.dir/all] Error 2 make: *** [all] Error 2 Do not report this issue to Homebrew/brew or Homebrew/core!

This is because catch2 didn't previously support arm64 architecture. This was fixed in:

https://github.com/catchorg/Catch2/releases/tag/v2.12.4

Please upgrade to more recent Catch2.

Manually adding test for mac gets past the error:

#if defined(__i386__) || defined(__x86_64__)
    #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
#elif defined(__aarch64__)
    #define CATCH_TRAP()  __asm__(".inst 0xd4200000")
#endif

However, Blake3 fails to build with issues related to Intel intrinsics. I haven't found a work around to this yet.

willbryant commented 3 years ago

That's weird. KS compiles and runs fine on AWS Graviton ARM chipset processors, including the blake3 part. Since Graviton has fewer extensions than Apple - in fact as I understand it effectively no-one except apple is allowed to create ARM instruction set extensions - you would expect it to work on M1. So I wonder if it is more an issue around compiler flags and defines, particularly the CHECK_C_COMPILER_FLAG stuff in CMakeLists.txt.

Please open a ticket with the full cmake and make output.