Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
2.03k stars 578 forks source link

Clang 3.9.1 on F25 fails to build (missing pthread linkage in tests) #5257

Closed dnsmichi closed 7 years ago

dnsmichi commented 7 years ago

Expected Behavior

clang++ builds Icinga 2.

Current Behavior

Build fails with clang++.

/bin/ld: CMakeFiles/boosttest-test-base.dir/base-array.cpp.o: undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5'
/usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation)
test/CMakeFiles/boosttest-test-base.dir/build.make:710: die Regel für Ziel „Bin/Debug/boosttest-test-base“ scheiterte
make[2]: *** [Bin/Debug/boosttest-test-base] Fehler 1
CMakeFiles/Makefile2:2714: die Regel für Ziel „test/CMakeFiles/boosttest-test-base.dir/all“ scheiterte
make[1]: *** [test/CMakeFiles/boosttest-test-base.dir/all] Fehler 2
make[1]: *** Es wird auf noch nicht beendete Prozesse gewartet...
[ 90%] Building CXX object lib/methods/CMakeFiles/methods.dir/timeperiodtask.cpp.o
[ 90%] Building CXX object lib/livestatus/CMakeFiles/livestatus.dir/livestatuslistener.cpp.o
[ 91%] Building CXX object lib/livestatus/CMakeFiles/livestatus.dir/livestatusquery.cpp.o
[ 91%] Building CXX object lib/livestatus/CMakeFiles/livestatus.dir/livestatuslogutility.cpp.o
[ 91%] Building CXX object lib/livestatus/CMakeFiles/livestatus.dir/logtable.cpp.o
[ 91%] Building CXX object lib/livestatus/CMakeFiles/livestatus.dir/maxaggregator.cpp.o
[ 92%] Building CXX object lib/livestatus/CMakeFiles/livestatus.dir/minaggregator.cpp.o
[ 92%] Building CXX object lib/db_ido/CMakeFiles/db_ido.dir/hostdbobject.cpp.o
[ 93%] Linking CXX shared library ../../Bin/Debug/libmethods.so
[ 93%] Built target methods

Possible Solution

Modify CMakeLists.txt to include -lpthread. I need to verify that this builds on macOS and variants then too.

Steps to Reproduce (for bugs)

Build the current git master w/ baaef9

Context

Use clang++ instead of gcc on Fedora 25.

Your Environment

michi@imagine ~/coding/icinga/icinga2 (master) $ icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: v2.6.3-265-gbaaef9a; debug)

Copyright (c) 2012-2017 Icinga Development Team (https://www.icinga.com/)
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Application information:
  Installation root: /usr
  Sysconf directory: /etc
  Run directory: /var/run
  Local state directory: /var
  Package data directory: /usr/share/icinga2
  State path: /var/lib/icinga2/icinga2.state
  Modified attributes path: /var/lib/icinga2/modified-attributes.conf
  Objects path: /var/cache/icinga2/icinga2.debug
  Vars path: /var/cache/icinga2/icinga2.vars
  PID path: /var/run/icinga2/icinga2.pid

System information:
  Platform: Fedora
  Platform version: 25 (Workstation Edition)
  Kernel: Linux
  Kernel version: 4.10.10-200.fc25.x86_64
  Architecture: x86_64

Build information:
  Compiler: Clang 3.9.1
  Build host: imagine
leeclemens commented 7 years ago

Tested -lpthread on CentOS 7 and ran in to this clang issue: https://access.redhat.com/solutions/3037411

Fixed with additional change (a33ebac92c2b3a976a0c73721dc95ac04ae87413) and was able to compile.

Should I open a new Issue for the clang/C++11 features mis-detection and workaround? Or bundle it in with this clang related compilation issue?

System information:
  Platform: CentOS Linux
  Platform version: 7 (Core)
  Kernel: Linux
  Kernel version: 3.10.0-514.10.2.el7.x86_64
  Architecture: x86_64

Build information:
  Compiler: Clang 3.4.2
dnsmichi commented 7 years ago

A new PR based on your fix would be nice, no need for an extra issue :)