[Tarantool-patches] [PATCH 03/11] build: skip linking with -ldl on OpenBSD

sergeyb at tarantool.org sergeyb at tarantool.org
Tue May 12 15:32:18 MSK 2020


From: Sergey Bronnikov <sergeyb at tarantool.org>

OpenBSD includes DL library in a base system

Part of #4967
---
 cmake/BuildMisc.cmake    |  2 +-
 cmake/FindCURL.cmake     |  2 +-
 cmake/FindICU.cmake      |  2 +-
 src/CMakeLists.txt       |  8 +++++---
 test/unit/CMakeLists.txt | 16 ++++++++++------
 5 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/cmake/BuildMisc.cmake b/cmake/BuildMisc.cmake
index 0c571f326..b4a3ca1fc 100644
--- a/cmake/BuildMisc.cmake
+++ b/cmake/BuildMisc.cmake
@@ -39,7 +39,7 @@ macro(libmisc_build)
         else()
             set(GOMP_LIBRARY gomp)
         endif()
-        target_link_libraries(misc ${GOMP_LIBRARY} pthread dl)
+        target_link_libraries(misc ${GOMP_LIBRARY} pthread)
     endif()
 
     unset(misc_src)
diff --git a/cmake/FindCURL.cmake b/cmake/FindCURL.cmake
index 6193a58ad..fa20717aa 100644
--- a/cmake/FindCURL.cmake
+++ b/cmake/FindCURL.cmake
@@ -35,7 +35,7 @@ set(DL_LIB_NAME dl)
 find_library(Z_LIBRARY NAMES ${Z_LIB_NAME})
 find_library(NGHTTP2_LIBRARY NAMES ${NGHTTP2_LIB_NAME})
 find_library(PTHREAD_LIBRARY NAMES ${PTHREAD_LIB_NAME})
-find_library(DL_LIBRARY NAMES ${DL_LIB_NAME})
+#find_library(DL_LIBRARY NAMES ${DL_LIB_NAME})
 
 if(DEFINED CURL_ROOT)
     set(CURL_FIND_OPTS NO_CMAKE NO_CMAKE_SYSTEM_PATH)
diff --git a/cmake/FindICU.cmake b/cmake/FindICU.cmake
index 2bb9a5d59..26f0683f3 100644
--- a/cmake/FindICU.cmake
+++ b/cmake/FindICU.cmake
@@ -50,7 +50,7 @@ include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(ICU
     REQUIRED_VARS ICU_INCLUDE_DIR ICU_LIBRARY_I18N ICU_LIBRARY_UC)
 set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
-set(ICU_LIBRARIES ${ICU_LIBRARY_I18N} ${ICU_LIBRARY_UC} ${ICU_LIBRARY_DATA} dl)
+set(ICU_LIBRARIES ${ICU_LIBRARY_I18N} ${ICU_LIBRARY_UC} ${ICU_LIBRARY_DATA})
 mark_as_advanced(ICU_INCLUDE_DIR ICU_INCLUDE_DIRS
         ICU_LIBRARY_I18N ICU_LIBRARY_UC ICU_LIBRARIES)
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2b5ea1b87..79a1b45cc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -71,9 +71,11 @@ set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${lua_sources})
 #
 # Always links pthread and dl dynamically.
 set(generic_libraries pthread)
-find_library(DL_LIBRARY NAMES dl)
-if(NOT "${DL_LIBRARY}" STREQUAL "DL_LIBRARY-NOTFOUND")
-    set(generic_libraries ${generic_libraries} dl)
+if(NOT TARGET_OS_OPENBSD)
+    find_library(DL_LIBRARY NAMES dl)
+    if(NOT "${DL_LIBRARY}" STREQUAL "DL_LIBRARY-NOTFOUND")
+        set(generic_libraries ${generic_libraries} dl)
+    endif()
 endif()
 
 add_library(stat STATIC rmean.c latency.c histogram.c)
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 84eb066bd..3bdfc6bb1 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -5,6 +5,10 @@ endif()
 file(GLOB all_sources *.c *.cc)
 set_source_files_compile_flags(${all_sources})
 
+if(NOT TARGET_OS_OPENBSD)
+    set(LIB_DL "dl")
+endif()
+
 include_directories(${PROJECT_SOURCE_DIR}/src)
 include_directories(${PROJECT_BINARY_DIR}/src)
 include_directories(${PROJECT_SOURCE_DIR}/src/box)
@@ -161,7 +165,7 @@ target_link_libraries(luaT_tuple_new.test unit box server core misc
 add_executable(luaL_iterator.test luaL_iterator.c)
 target_link_libraries(luaL_iterator.test unit server coll core misc
     ${CURL_LIBRARIES} ${LIBYAML_LIBRARIES} ${READLINE_LIBRARIES}
-    ${ICU_LIBRARIES} ${LUAJIT_LIBRARIES} dl)
+    ${ICU_LIBRARIES} ${LUAJIT_LIBRARIES} ${LIB_DL})
 
 add_executable(say.test say.c)
 target_link_libraries(say.test core unit)
@@ -176,7 +180,7 @@ set(ITERATOR_TEST_SOURCES
 set(ITERATOR_TEST_LIBS core tuple xrow unit)
 
 add_executable(vy_mem.test vy_mem.c ${ITERATOR_TEST_SOURCES})
-target_link_libraries(vy_mem.test ${ITERATOR_TEST_LIBS} dl)
+target_link_libraries(vy_mem.test ${ITERATOR_TEST_LIBS} ${LIB_DL})
 
 add_executable(vy_point_lookup.test
     vy_point_lookup.c
@@ -198,7 +202,7 @@ add_executable(vy_point_lookup.test
     ${PROJECT_SOURCE_DIR}/src/box/schema_def.c
     ${PROJECT_SOURCE_DIR}/src/box/identifier.c
 )
-target_link_libraries(vy_point_lookup.test core tuple xrow xlog unit dl)
+target_link_libraries(vy_point_lookup.test core tuple xrow xlog unit ${LIB_DL})
 
 add_executable(column_mask.test
     column_mask.c)
@@ -211,13 +215,13 @@ add_executable(vy_write_iterator.test
     ${PROJECT_SOURCE_DIR}/src/box/vy_write_iterator.c
     ${ITERATOR_TEST_SOURCES}
 )
-target_link_libraries(vy_write_iterator.test xlog ${ITERATOR_TEST_LIBS} dl)
+target_link_libraries(vy_write_iterator.test xlog ${ITERATOR_TEST_LIBS} ${LIB_DL})
 
 add_executable(vy_cache.test vy_cache.c ${ITERATOR_TEST_SOURCES})
-target_link_libraries(vy_cache.test ${ITERATOR_TEST_LIBS} dl)
+target_link_libraries(vy_cache.test ${ITERATOR_TEST_LIBS} ${LIB_DL})
 
 add_executable(coll.test coll.cpp)
-target_link_libraries(coll.test coll unit misc dl)
+target_link_libraries(coll.test coll unit misc ${LIB_DL})
 
 add_executable(tuple_bigref.test tuple_bigref.c)
 target_link_libraries(tuple_bigref.test tuple unit)
-- 
2.23.0



More information about the Tarantool-patches mailing list