0003-CMakeLists.txt-check-for-atomic-library.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From 9e82eb57870ec7c01734b44ed4bb994362004df3 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Fri, 27 Dec 2019 10:20:53 +0100
  4. Subject: [PATCH] CMakeLists.txt: check for atomic library
  5. On some architectures, atomic binutils are provided by the libatomic
  6. library from gcc. Linking with libatomic is therefore necessary,
  7. otherwise the build fails with:
  8. [100%] Linking CXX executable leveldbutil
  9. /home/fabrice/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/7.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: libleveldb.a(env_posix.cc.o): in function `leveldb::(anonymous namespace)::Limiter::Acquire()':
  10. env_posix.cc:(.text+0x124): undefined reference to `__atomic_fetch_sub_4'
  11. This is often for example the case on sparcv8 32 bit.
  12. Fixes:
  13. - http://autobuild.buildroot.org/results/01d5a50581ac9e9b46f40e6f9665f74897db5e6f
  14. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  15. [Upstream status: https://github.com/google/leveldb/pull/765]
  16. ---
  17. CMakeLists.txt | 4 ++++
  18. 1 file changed, 4 insertions(+)
  19. diff --git a/CMakeLists.txt b/CMakeLists.txt
  20. index be41ba4..9d6773f 100644
  21. --- a/CMakeLists.txt
  22. +++ b/CMakeLists.txt
  23. @@ -41,6 +41,7 @@ include(CheckIncludeFile)
  24. check_include_file("unistd.h" HAVE_UNISTD_H)
  25. include(CheckLibraryExists)
  26. +check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_ATOMIC)
  27. check_library_exists(crc32c crc32c_value "" HAVE_CRC32C)
  28. check_library_exists(snappy snappy_compress "" HAVE_SNAPPY)
  29. check_library_exists(tcmalloc malloc "" HAVE_TCMALLOC)
  30. @@ -270,6 +271,9 @@ if(HAVE_CLANG_THREAD_SAFETY)
  31. -Werror -Wthread-safety)
  32. endif(HAVE_CLANG_THREAD_SAFETY)
  33. +if(HAVE_ATOMIC)
  34. + target_link_libraries(leveldb atomic)
  35. +endif(HAVE_ATOMIC)
  36. if(HAVE_CRC32C)
  37. target_link_libraries(leveldb crc32c)
  38. endif(HAVE_CRC32C)
  39. --
  40. 2.24.0