Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: undefined reference to symbol 'clock_gettime@@GLIBC_2.2.5' on CentOS 6 #4639

Closed
Totktonada opened this issue Nov 22, 2019 · 3 comments
Assignees
Labels
bug Something isn't working build
Milestone

Comments

@Totktonada
Copy link
Member

Tarantool version: 2.3.0-231-g22bbb34fb.
OS version: CentOS 6.

Tarantool fails to build on CentOS 6 in our CI.

https://travis-ci.org/tarantool/tarantool/jobs/615173058
https://gitlab.com/tarantool/tarantool/-/jobs/357787965

Relevant part of a build log:

/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

@Totktonada Totktonada added build bug Something isn't working labels Nov 22, 2019
@avtikhon
Copy link
Contributor

Caused commit is:

commit 77fa45bd05f8cdd4c0f9bad85185ef5b61528d49
Author: Serge Petrenko <sergepetrenko@tarantool.org>
Date:   Wed Sep 11 17:21:48 2019 +0300

    lua: add fiber.top() listing fiber cpu consumption

@avtikhon
Copy link
Contributor

Error:

make[2]: Entering directory '/source/build/usr/src/debug/tarantool-2.3.0.203'
Linking CXX executable cbus.test
cd /source/build/usr/src/debug/tarantool-2.3.0.203/test/unit && /usr/bin/cmake -E cmake_link_script CMakeFiles/cbus.test.dir/link.txt --verbose=1
/opt/rh/devtoolset-6/root/usr/bin/c++   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -fopenmp -msse2 -std=c++11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -Wno-invalid-offsetof -Wno-cast-function-type -Wno-unused-parameter -Wno-unused -Wno-unused-result -Wno-tautological-compare -O2 -g -DNDEBUG -ggdb -O2    CMakeFiles/cbus.test.dir/cbus.c.o  -o cbus.test -rdynamic ../../src/lib/core/libcore.a libunit.a ../../src/libstat.a ../../src/lib/core/libcore.a ../../src/lib/salad/libsalad.a ../../src/lib/small/libsmall.a ../../src/lib/uri/liburi.a ../../libdecNumber.a ../../libev.a -lm ../../libeio.a -lpthread ../../libcoro.a ../../src/lib/msgpuck/libmsgpuck.a -licui18n -licuuc -licudata -lgcc_s -lunwind-x86_64 -lunwind 
/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
make[2]: Leaving directory '/source/build/usr/src/debug/tarantool-2.3.0.203'
CMakeFiles/Makefile2:5359: recipe for target 'test/unit/CMakeFiles/cbus.test.dir/all' failed
make[1]: *** [test/unit/CMakeFiles/cbus.test.dir/all] Error 2
make[1]: Leaving directory '/source/build/usr/src/debug/tarantool-2.3.0.203'
Makefile:139: recipe for target 'all' failed
make: *** [all] Error 2

@avtikhon
Copy link
Contributor

avtikhon commented Nov 22, 2019

Fix is to add the compiling option '-lrt', like:

/opt/rh/devtoolset-6/root/usr/bin/c++   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -fopenmp -msse2 -std=c++11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -Wno-invalid-offsetof -Wno-cast-function-type -Wno-unused-parameter -Wno-unused -Wno-unused-result -Wno-tautological-compare -O2 -g -DNDEBUG -ggdb -O2    CMakeFiles/cbus.test.dir/cbus.c.o  -o cbus.test -rdynamic ../../src/lib/core/libcore.a libunit.a ../../src/libstat.a ../../src/lib/core/libcore.a ../../src/lib/salad/libsalad.a ../../src/lib/small/libsmall.a ../../src/lib/uri/liburi.a ../../libdecNumber.a ../../libev.a -lm ../../libeio.a -lpthread ../../libcoro.a ../../src/lib/msgpuck/libmsgpuck.a -licui18n -licuuc -licudata -lgcc_s -lunwind-x86_64 -lunwind -lrt

Need to add lrt to all built failed tests at 'test/unit/CMakeLists.txt' file (25 entries from 60)

avtikhon added a commit that referenced this issue Nov 22, 2019
After the commit 77fa45b
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
avtikhon added a commit that referenced this issue Nov 22, 2019
After the commit 77fa45b
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
avtikhon added a commit that referenced this issue Nov 22, 2019
After the commit 77fa45b
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
avtikhon added a commit that referenced this issue Nov 26, 2019
After the commit 77fa45b
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
avtikhon added a commit that referenced this issue Nov 29, 2019
After the commit 77fa45b
('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

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

Close #4639
avtikhon added a commit that referenced this issue Nov 29, 2019
After the commit 77fa45b
('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
avtikhon added a commit that referenced this issue Dec 6, 2019
After the commit 77fa45b
('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
@kyukhin kyukhin added this to the 2.3.1 milestone Dec 6, 2019
@kyukhin kyukhin closed this as completed in 960e9c0 Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build
Projects
None yet
Development

No branches or pull requests

3 participants