[Tarantool-patches] [PATCH v1] build: fix unit tests build with lrt

Alexander V. Tikhonov avtikhon at tarantool.org
Fri Nov 22 16:51:38 MSK 2019


After the commit 77fa45bd05f8cdd4c0f9bad85185ef5b61528d49
the unit tests builds failed like:

/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/ld:
  ../../src/lib/core/libcore.a(fiber.c.o): undefined reference to symbol
  'clock_gettime@@GLIBC_2.2.5'
//lib64/librt.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
test/unit/CMakeFiles/cbus.test.dir/build.make:108: recipe for target
  'test/unit/cbus.test' failed
make[2]: *** [test/unit/cbus.test] Error 1

To fix the issue the 'rt' library was added to test unit cmake file only
for linux and freebsd targets.

Close #4639
---

Github: https://github.com/tarantool/tarantool/tree/avtikhon/gh-4639-lrt-unit-tests-full-ci
Issue: https://github.com/tarantool/tarantool/issues/4639

 test/unit/CMakeLists.txt | 54 +++++++++++++++++++++-------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 4a57597e9..4058c12f7 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -12,6 +12,10 @@ include_directories(${CMAKE_SOURCE_DIR}/third_party)
 include_directories(${ICU_INCLUDE_DIRS})
 include_directories(${CURL_INCLUDE_DIRS})
 
+if (TARGET_OS_LINUX OR TARGET_OS_FREEBSD)
+	set(RT_LIBRARY rt)
+endif()
+
 add_library(unit STATIC unit.c)
 
 add_executable(heap.test heap.c)
@@ -66,40 +70,40 @@ target_link_libraries(bloom.test salad)
 add_executable(vclock.test vclock.cc)
 target_link_libraries(vclock.test vclock unit)
 add_executable(xrow.test xrow.cc)
-target_link_libraries(xrow.test xrow unit)
+target_link_libraries(xrow.test xrow unit ${RT_LIBRARY})
 add_executable(decimal.test decimal.c)
 target_link_libraries(decimal.test core unit)
 
 add_executable(fiber.test fiber.cc)
 set_source_files_properties(fiber.cc PROPERTIES COMPILE_FLAGS -O0)
-target_link_libraries(fiber.test core unit)
+target_link_libraries(fiber.test core unit ${RT_LIBRARY})
 
 if (NOT ENABLE_GCOV)
     # This test is known to be broken with GCOV
     add_executable(guard.test guard.cc)
-    target_link_libraries(guard.test core unit)
+    target_link_libraries(guard.test core unit ${RT_LIBRARY})
 endif ()
 
 add_executable(fiber_stress.test fiber_stress.cc)
-target_link_libraries(fiber_stress.test core)
+target_link_libraries(fiber_stress.test core ${RT_LIBRARY})
 
 add_executable(fiber_cond.test fiber_cond.c unit.c)
-target_link_libraries(fiber_cond.test core)
+target_link_libraries(fiber_cond.test core ${RT_LIBRARY})
 
 add_executable(fiber_channel.test fiber_channel.cc unit.c)
-target_link_libraries(fiber_channel.test core)
+target_link_libraries(fiber_channel.test core ${RT_LIBRARY})
 
 add_executable(fiber_channel_stress.test fiber_channel_stress.cc)
-target_link_libraries(fiber_channel_stress.test core)
+target_link_libraries(fiber_channel_stress.test core ${RT_LIBRARY})
 
 add_executable(cbus_stress.test cbus_stress.c)
-target_link_libraries(cbus_stress.test core stat)
+target_link_libraries(cbus_stress.test core stat ${RT_LIBRARY})
 
 add_executable(cbus.test cbus.c)
-target_link_libraries(cbus.test core unit stat)
+target_link_libraries(cbus.test core unit stat ${RT_LIBRARY})
 
 add_executable(coio.test coio.cc)
-target_link_libraries(coio.test core eio bit uri unit)
+target_link_libraries(coio.test core eio bit uri unit ${RT_LIBRARY})
 
 if (ENABLE_BUNDLED_MSGPUCK)
     set(MSGPUCK_DIR ${PROJECT_SOURCE_DIR}/src/lib/msgpuck/)
@@ -116,7 +120,7 @@ if (ENABLE_BUNDLED_MSGPUCK)
 endif ()
 
 add_executable(scramble.test scramble.c)
-target_link_libraries(scramble.test scramble)
+target_link_libraries(scramble.test scramble ${RT_LIBRARY})
 
 add_executable(guava.test guava.c)
 target_link_libraries(guava.test salad small)
@@ -136,7 +140,7 @@ add_executable(json.test json.c)
 target_link_libraries(json.test json unit ${ICU_LIBRARIES})
 
 add_executable(rmean.test rmean.cc)
-target_link_libraries(rmean.test stat unit)
+target_link_libraries(rmean.test stat unit ${RT_LIBRARY})
 add_executable(histogram.test histogram.c)
 target_link_libraries(histogram.test stat unit)
 add_executable(ratelimit.test ratelimit.c)
@@ -151,7 +155,7 @@ target_link_libraries(luaL_iterator.test unit server coll core misc
     ${ICU_LIBRARIES} ${LUAJIT_LIBRARIES} dl)
 
 add_executable(say.test say.c)
-target_link_libraries(say.test core unit)
+target_link_libraries(say.test core unit ${RT_LIBRARY})
 
 set(ITERATOR_TEST_SOURCES
     vy_iterators_helper.c
@@ -163,7 +167,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} dl ${RT_LIBRARY})
 
 add_executable(vy_point_lookup.test
     vy_point_lookup.c
@@ -185,11 +189,11 @@ 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 dl ${RT_LIBRARY})
 
 add_executable(column_mask.test
     column_mask.c)
-target_link_libraries(column_mask.test tuple unit)
+target_link_libraries(column_mask.test tuple unit ${RT_LIBRARY})
 
 add_executable(vy_write_iterator.test
     vy_write_iterator.c
@@ -198,16 +202,16 @@ 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} dl ${RT_LIBRARY})
 
 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} dl ${RT_LIBRARY})
 
 add_executable(coll.test coll.cpp)
-target_link_libraries(coll.test coll unit misc dl)
+target_link_libraries(coll.test coll unit misc dl ${RT_LIBRARY})
 
 add_executable(tuple_bigref.test tuple_bigref.c)
-target_link_libraries(tuple_bigref.test tuple unit)
+target_link_libraries(tuple_bigref.test tuple unit ${RT_LIBRARY})
 
 add_executable(checkpoint_schedule.test
     checkpoint_schedule.c
@@ -216,23 +220,23 @@ add_executable(checkpoint_schedule.test
 target_link_libraries(checkpoint_schedule.test m unit)
 
 add_executable(sio.test sio.c)
-target_link_libraries(sio.test unit core)
+target_link_libraries(sio.test unit core ${RT_LIBRARY})
 
 add_executable(crypto.test crypto.c)
-target_link_libraries(crypto.test crypto unit)
+target_link_libraries(crypto.test crypto unit ${RT_LIBRARY})
 
 add_executable(swim.test swim.c swim_test_transport.c swim_test_ev.c
                swim_test_utils.c ${PROJECT_SOURCE_DIR}/src/version.c)
-target_link_libraries(swim.test unit swim)
+target_link_libraries(swim.test unit swim ${RT_LIBRARY})
 
 add_executable(swim_proto.test swim_proto.c swim_test_transport.c swim_test_ev.c
                swim_test_utils.c ${PROJECT_SOURCE_DIR}/src/version.c)
-target_link_libraries(swim_proto.test unit swim)
+target_link_libraries(swim_proto.test unit swim ${RT_LIBRARY})
 
 add_executable(swim_errinj.test swim_errinj.c swim_test_transport.c
                swim_test_ev.c swim_test_utils.c
                ${PROJECT_SOURCE_DIR}/src/version.c)
-target_link_libraries(swim_errinj.test unit swim)
+target_link_libraries(swim_errinj.test unit swim ${RT_LIBRARY})
 
 add_executable(merger.test merger.test.c)
 target_link_libraries(merger.test unit core box)
-- 
2.17.1



More information about the Tarantool-patches mailing list