apple / foundationdb

FoundationDB - the open source, distributed, transactional key-value store
https://apple.github.io/foundationdb/
Apache License 2.0
14.51k stars 1.31k forks source link

Cross compile FDB for aarch64 & ARMv7 #7574

Closed JaylinYu closed 2 years ago

JaylinYu commented 2 years ago

I am trying to corss-compile FDB for armv7 and amrv8 with cross compiling tool chain. The google benchmark and flowbench is giving me a lot troubles, is there a way to disable these test and benchmark module? try to delete enable_testing() in cmakelist but no luck.

JaylinYu commented 2 years ago

Whoops, seems like AVX is a must for FDB? which is not supported for gnueabi & gnueabihf

JaylinYu commented 2 years ago

Another issue: seems like the fdbrpc/libcoroutine/context.c is using sth that toolchain does not provide: error: 'struct mcontext_t' has no member named 'gregs'

is there a way to configure it compatible with toolchain?

sfc-gh-anoyes commented 2 years ago

When building for aarch64, foundationdb should be selecting boost coroutines instead of fdbrpc/libcoroutine/. There's probably something about our cmake setup that doesn't detect this when cross-compiling

jzhou77 commented 2 years ago

Whoops, seems like AVX is a must for FDB? which is not supported for gnueabi & gnueabihf

You can disable AVX. See this example.

JaylinYu commented 2 years ago

Whoops, seems like AVX is a must for FDB? which is not supported for gnueabi & gnueabihf

You can disable AVX. See this example.

Tried this before, gets me nowhere, have to manually disable "-mavx"

JaylinYu commented 2 years ago

When building for aarch64, foundationdb should be selecting boost coroutines instead of fdbrpc/libcoroutine/. There's probably something about our cmake setup that doesn't detect this when cross-compiling

Thx! I manage to pass this error by manually selecting boost as a coroutine implementation. However another issue pops when compiling contrib: Error : selected processor does not support 'crc32cb w....' Is there a way to configure FDB to work on crc32?

JaylinYu commented 2 years ago

Idk for whatever reason, the -march option in cmake/configurecompiler seems not working. I passed last error by manually set CXX_FLAGS as "-march=armv8-a+crc-simd -mtune=generic". Now seems like stripping of fdbmonitor not working: fdbmonitor && strip --strip-debug --strip-unneeded -o /home/projects/foundationdb/ninja-build/packages/bin/fdbmonitor /home/projects/foundationdb/ninja-build/bin/fdbmonitor strip: Unable to recognise the format of the input file `/home/projects/foundationdb/ninja-build/bin/fdbmonitor'

probably due to no proper cross-compile option for jemalloc and other dependencies...

Just realize there is no cross-compiling adapter for strip in cmake/flowcommands.cmake ...... fine by modifying CMakeList I manage to get over with this error.... then find another issue on linking stage: seems like FDB trying to link x86 libssl.a with the aarch64 toolchain when building flow module (mkcert).....

Switching back to release 7.1, problem solved.....

JaylinYu commented 2 years ago

Still got same error when compiling fdbserver: /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libssl.a(libssl-lib-methods.o): Relocations in generic ELF (EM: 62) /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libssl.a(libssl-lib-methods.o): Relocations in generic ELF (EM: 62) /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libssl.a(libssl-lib-methods.o): Relocations in generic ELF (EM: 62) /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libssl.a: error adding symbols: file in wrong format

perhaps I need to manually cross compile openssl aarch64?

JaylinYu commented 2 years ago

after resolving openssl, seems like still got jemalloc to do ....

JaylinYu commented 2 years ago

after jemalloc, finally get aarch64 done. armv7/32bit to go....

one little suggestion, really need to rewrite the Cmake file for cross-compiling... I can sort it out as a PR if you want.