Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH v1] build: fix unit tests build with lrt
@ 2019-11-22 13:51 Alexander V. Tikhonov
  2019-11-28 16:41 ` Alexander Turenko
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander V. Tikhonov @ 2019-11-22 13:51 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: tarantool-patches

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

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [Tarantool-patches] [PATCH v1] build: fix unit tests build with lrt
@ 2019-11-29  7:05 Alexander V. Tikhonov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander V. Tikhonov @ 2019-11-29  7:05 UTC (permalink / raw)
  To: Igor Munkin; +Cc: tarantool-patches

After the commit 77fa45bd05f8cdd4c0f9bad85185ef5b61528d49
('lua: add fiber.top() listing fiber cpu consumption')
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

Found that fiber.cc is using now clock_gettime(), which requires -lrt
with glibc. To fix it added librt dependency for core library for glibc.
Due to glibc requires for -lrt for clock_gettime() only for some
versions, check 'man clock_gettime.2':
  'Link with -lrt (only for glibc versions before 2.17).'
the check whether is able to use clock_gettime() w/o librt library is
added.

Close #4639
---

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

 CMakeLists.txt              | 6 ++++++
 src/lib/core/CMakeLists.txt | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d6c0846e..ca968eb8d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -116,6 +116,12 @@ else ()
     set(HAVE_CLOCK_GETTIME ${HAVE_CLOCK_GETTIME_DECL})
 endif ()
 set(CMAKE_REQUIRED_LIBRARIES "")
+# According to `man 2 clockgettime` the glibc wrapper requires
+# -lrt on glibc versions before 2.17. We need to check whether
+# the function is available without -lrt to set this linker option
+# conditionally.
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME_WITHOUT_RT)
+
 check_symbol_exists(__get_cpuid cpuid.h HAVE_CPUID)
 
 # Checks for libev
diff --git a/src/lib/core/CMakeLists.txt b/src/lib/core/CMakeLists.txt
index e60b5199e..8623aa0de 100644
--- a/src/lib/core/CMakeLists.txt
+++ b/src/lib/core/CMakeLists.txt
@@ -46,3 +46,11 @@ target_link_libraries(core salad small uri decNumber ${LIBEV_LIBRARIES}
 if (ENABLE_BACKTRACE AND NOT TARGET_OS_DARWIN)
     target_link_libraries(core gcc_s ${UNWIND_LIBRARIES})
 endif()
+
+# Since fiber.top() introduction, fiber.cc, which is part of core
+# library, depends on clock_gettime() syscall, so we should set
+# -lrt when it is appropriate. See a comment for
+# HAVE_CLOCK_GETTIME_WITHOUT_RT in ${REPO}/CMakeLists.txt.
+if ("${HAVE_CLOCK_GETTIME}" AND NOT "${HAVE_CLOCK_GETTIME_WITHOUT_RT}")
+    target_link_libraries(core rt)
+endif()
-- 
2.17.1

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [Tarantool-patches] [PATCH v1] build: fix unit tests build with lrt
@ 2019-11-22 11:39 Alexander V. Tikhonov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander V. Tikhonov @ 2019-11-22 11:39 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: tarantool-patches

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 it the rt library needed to be added like for unit tests builds.
Added -lrt to 25 builds from overall 60 at cmake file.

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 | 50 ++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 4a57597e9..544515271 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -66,40 +66,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)
 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)
 
 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)
 endif ()
 
 add_executable(fiber_stress.test fiber_stress.cc)
-target_link_libraries(fiber_stress.test core)
+target_link_libraries(fiber_stress.test core rt)
 
 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)
 
 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)
 
 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)
 
 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)
 
 add_executable(cbus.test cbus.c)
-target_link_libraries(cbus.test core unit stat)
+target_link_libraries(cbus.test core unit stat rt)
 
 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)
 
 if (ENABLE_BUNDLED_MSGPUCK)
     set(MSGPUCK_DIR ${PROJECT_SOURCE_DIR}/src/lib/msgpuck/)
@@ -116,7 +116,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)
 
 add_executable(guava.test guava.c)
 target_link_libraries(guava.test salad small)
@@ -136,7 +136,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)
 add_executable(histogram.test histogram.c)
 target_link_libraries(histogram.test stat unit)
 add_executable(ratelimit.test ratelimit.c)
@@ -151,7 +151,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)
 
 set(ITERATOR_TEST_SOURCES
     vy_iterators_helper.c
@@ -163,7 +163,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)
 
 add_executable(vy_point_lookup.test
     vy_point_lookup.c
@@ -185,11 +185,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)
 
 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)
 
 add_executable(vy_write_iterator.test
     vy_write_iterator.c
@@ -198,16 +198,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)
 
 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)
 
 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)
 
 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)
 
 add_executable(checkpoint_schedule.test
     checkpoint_schedule.c
@@ -216,23 +216,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)
 
 add_executable(crypto.test crypto.c)
-target_link_libraries(crypto.test crypto unit)
+target_link_libraries(crypto.test crypto unit rt)
 
 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)
 
 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)
 
 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)
 
 add_executable(merger.test merger.test.c)
 target_link_libraries(merger.test unit core box)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-29  7:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 13:51 [Tarantool-patches] [PATCH v1] build: fix unit tests build with lrt Alexander V. Tikhonov
2019-11-28 16:41 ` Alexander Turenko
2019-11-29  7:12   ` Alexander Tikhonov
  -- strict thread matches above, loose matches on Subject: below --
2019-11-29  7:05 Alexander V. Tikhonov
2019-11-22 11:39 Alexander V. Tikhonov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox