Skip to content
Snippets Groups Projects
  • Alexander V. Tikhonov's avatar
    960e9c0c
    build: fix unit tests build with -lrt on CentOS 6 · 960e9c0c
    Alexander V. Tikhonov authored
    After the commit 77fa45bd
    ('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
    
    (cherry picked from commit 99b0ef771135eab66ef3758371b1b5431e21cbff)
    960e9c0c
    History
    build: fix unit tests build with -lrt on CentOS 6
    Alexander V. Tikhonov authored
    After the commit 77fa45bd
    ('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
    
    (cherry picked from commit 99b0ef771135eab66ef3758371b1b5431e21cbff)