This is an automated email from the ASF dual-hosted git repository.

szaszm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git

commit 36244376bb46c5c85657c6dfe92a6a0c4cea650a
Author: Gabor Gyimesi <[email protected]>
AuthorDate: Thu Jul 20 14:31:23 2023 +0200

    MINIFICPP-2139 Fix build on ARM7 architecture
    
    Closes #1590
    Signed-off-by: Marton Szasz <[email protected]>
---
 cmake/BundledRocksDB.cmake    |  5 +++++
 libminifi/CMakeLists.txt      |  3 +++
 thirdparty/rocksdb/arm7.patch | 15 +++++++++++++++
 3 files changed, 23 insertions(+)

diff --git a/cmake/BundledRocksDB.cmake b/cmake/BundledRocksDB.cmake
index e9a72db93..f1dc063d3 100644
--- a/cmake/BundledRocksDB.cmake
+++ b/cmake/BundledRocksDB.cmake
@@ -26,6 +26,10 @@ function(use_bundled_rocksdb SOURCE_DIR BINARY_DIR)
         list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/lz4/dummy")
     endif()
 
+    # Patch to fix build issue on ARM7 architecture: 
https://github.com/facebook/rocksdb/issues/8609#issuecomment-1009572506
+    set(PATCH_FILE "${SOURCE_DIR}/thirdparty/rocksdb/arm7.patch")
+    set(PC ${Bash_EXECUTABLE} -c "set -x && \
+            (\"${Patch_EXECUTABLE}\" -p1 -R -s -f --dry-run -i 
\"${PATCH_FILE}\" || \"${Patch_EXECUTABLE}\" -p1 -N -i \"${PATCH_FILE}\")")
     # Define byproducts
     if (WIN32)
         set(BYPRODUCT "lib/rocksdb.lib")
@@ -71,6 +75,7 @@ function(use_bundled_rocksdb SOURCE_DIR BINARY_DIR)
             URL_HASH 
"SHA256=9102704e169cfb53e7724a30750eeeb3e71307663852f01fa08d5a320e6155a8"
             SOURCE_DIR "${BINARY_DIR}/thirdparty/rocksdb-src"
             CMAKE_ARGS ${ROCKSDB_CMAKE_ARGS}
+            PATCH_COMMAND ${PC}
             BUILD_BYPRODUCTS 
"${BINARY_DIR}/thirdparty/rocksdb-install/${BYPRODUCT}"
             EXCLUDE_FROM_ALL TRUE
             LIST_SEPARATOR % # This is needed for passing semicolon-separated 
lists
diff --git a/libminifi/CMakeLists.txt b/libminifi/CMakeLists.txt
index 31d9c1ce5..9dc91ef75 100644
--- a/libminifi/CMakeLists.txt
+++ b/libminifi/CMakeLists.txt
@@ -104,6 +104,9 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND 
CMAKE_CXX_COMPILER_VERSION VER
     list(APPEND LIBMINIFI_LIBRARIES stdc++fs)
 endif()
 target_link_libraries(core-minifi ${CMAKE_DL_LIBS} ${LIBMINIFI_LIBRARIES})
+if (UNIX AND (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7"))
+    target_link_libraries(core-minifi "-latomic")
+endif()
 
 SET (LIBMINIFI core-minifi PARENT_SCOPE)
 
diff --git a/thirdparty/rocksdb/arm7.patch b/thirdparty/rocksdb/arm7.patch
new file mode 100644
index 000000000..1eb64ed5c
--- /dev/null
+++ b/thirdparty/rocksdb/arm7.patch
@@ -0,0 +1,15 @@
+diff --git 
a/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h 
b/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h
+index 225e3fa72..cd5f935f1 100644
+--- a/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h
++++ b/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h
+@@ -131,6 +131,10 @@ static inline tokutime_t toku_time_now(void) {
+   uint64_t result;
+   __asm __volatile__("mrs %[rt], cntvct_el0" : [ rt ] "=r"(result));
+   return result;
++#elif defined(__arm__)
++  uint32_t lo, hi;
++  __asm __volatile__("mrrc p15, 1, %[lo], %[hi], c14" : [ lo ] "=r" (lo), 
[hi] "=r" (hi));
++  return (uint64_t)hi << 32 | lo;
+ #elif defined(__powerpc__)
+   return __ppc_get_timebase();
+ #elif defined(__s390x__)

Reply via email to