speedb-io / speedb

A RocksDB compliant high performance scalable embedded key-value store
https://www.speedb.io/
Apache License 2.0
856 stars 63 forks source link

Fix cross-compilation on macOS x86_64 CPUs with target CPU arm64 #823

Closed shpala closed 4 months ago

shpala commented 5 months ago

Fix cross-compilation on macOS x86_64 CPUs with target CPU arm64 by manually setting CMAKE_SYSTEM_PROCESSOR to the cross-compilation target whenever CMAKE_SYSTEM_PROCESSOR doesn't match CMAKE_OSX_ARCHITECTURES after project() call. This is probably a Cmake bug that happens on macOS. (#822).

The issue happens when SpeeDB is built using the follwoing command: cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_PROCESSOR=arm64 .. The build itself succeeds, but because Cmake wrongly sets CMAKE_SYSTEM_PROCESSOR to x86_64 instead of arm64 and causes crc32c_arm64.cc not to be compiled. This in turn makes the project fails any linking with SpeeDB:

Undefined symbols for architecture arm64:
"crc32c_arm64(unsigned int, unsigned char const*, unsigned long)", referenced from:
speedb::crc32c::ExtendARMImpl(unsigned int, char const*, unsigned long) in libspeedb.a(crc32c.cc.o)
CLAassistant commented 5 months ago

CLA assistant check
All committers have signed the CLA.

jhult commented 4 months ago

@shpala, any updates on this? I think there are just 2 small changes required (and the CLA).

shpala commented 4 months ago

Done. Though there's a git error on the build server. The reason this happened is that I've rebased my branch over latest origin/main in order to be in sync with the current branch and I've force pushed my commit as if it was a new commit in a new branch. You need to run "git fetch --all" in order to build successfully.

@ofriedma @jhult do you want me to close this PR and reopen with the same changes?

ofriedma commented 4 months ago

Compilation succeed for linux arm

ofriedma commented 4 months ago

@shpala Merged, Thank you for your contribution