MantisBT - CMake
View Issue Details
0011333CMakeModulespublic2010-10-19 07:132012-07-09 06:52
Rolf Eike Beer 
Rolf Eike Beer 
normaltweakalways
closedfixed 
CMake-2-8 
CMake 2.8.8CMake 2.8.8 
0011333: FindThreads incorrectly adds -pthread to linker options
FindThreads sets CMAKE_THREAD_LIBS_INIT to -pthread on QNX which leads to this linker warning:

c++: unrecognized option '-pthread'

QNX has the phtread stuff in the standard library. The best way would IMHO be to check if a program that uses pthread_* can be successfully linked without specifying any linker option before trying out the different flags.
No tags attached.
related to 0007830closed David Cole CMake 2.6.2 doesn't find pthread_* function in libc on OpenSolaris 
related to 0012457closed David Cole Wrong detection for pthread under Linux 
diff pthread_libc.diff (3,668) 2011-02-03 15:38
https://public.kitware.com/Bug/file/3676/*
patch 19a4b885+0001-FindThreads-Try-pthreads-with-no-special-option-firs.patch (3,618) 2011-04-25 11:38
https://public.kitware.com/Bug/file/3832/19a4b885%2B0001-FindThreads-Try-pthreads-with-no-special-option-firs.patch
Issue History
2010-10-19 07:13Rolf Eike BeerNew Issue
2010-11-10 13:11David ColeAssigned To => David Cole
2010-11-10 13:11David ColeStatusnew => assigned
2010-11-10 13:11David ColeTarget Version => CMake 2.8.4
2010-12-08 13:43Ben BoeckelAssigned ToDavid Cole => Ben Boeckel
2010-12-14 13:20Kovarththanan RajaratnamCategoryCMake => Modules
2011-01-06 14:50Ben BoeckelNote Added: 0024476
2011-01-06 14:50Ben BoeckelTarget VersionCMake 2.8.4 =>
2011-02-03 15:38Rolf Eike BeerFile Added: pthread_libc.diff
2011-02-03 15:39Rolf Eike BeerNote Added: 0025250
2011-04-18 16:17Brad KingRelationship addedrelated to 0007830
2011-04-25 11:38Brad KingFile Added: 19a4b885+0001-FindThreads-Try-pthreads-with-no-special-option-firs.patch
2011-04-25 11:40Brad KingNote Added: 0026249
2011-08-01 10:50David ColeAssigned ToBen Boeckel => David Cole
2011-08-01 10:50David ColeTarget Version => CMake 2.8.6
2011-08-09 14:03Rolf Eike BeerNote Added: 0027185
2011-08-20 14:58David ColeNote Added: 0027256
2011-08-20 14:58David ColeStatusassigned => resolved
2011-08-20 14:58David ColeFixed in Version => CMake 2.8.6
2011-08-20 14:58David ColeResolutionopen => fixed
2011-09-14 12:37David ColeRelationship addedrelated to 0012457
2011-09-14 12:38David ColeNote Added: 0027417
2011-09-14 12:38David ColeStatusresolved => feedback
2011-09-14 12:38David ColeResolutionfixed => reopened
2011-09-14 12:40David ColeFixed in VersionCMake 2.8.6 =>
2011-09-14 12:42Funda WangNote Added: 0027419
2011-09-14 12:51Funda WangNote Added: 0027420
2011-09-14 16:44Brad KingNote Added: 0027422
2011-09-14 17:38Orion PoplawskiNote Added: 0027424
2011-09-16 04:06Rolf Eike BeerNote Added: 0027431
2011-09-16 04:06Rolf Eike BeerStatusfeedback => assigned
2011-09-22 16:57David ColeNote Added: 0027478
2011-09-22 16:57David ColeTarget VersionCMake 2.8.6 =>
2011-10-28 12:24David ColeTarget Version => CMake 2.8.7
2011-12-13 19:20David ColeNote Added: 0027966
2011-12-13 19:20David ColeTarget VersionCMake 2.8.7 =>
2012-01-02 17:13Rolf Eike BeerNote Added: 0028137
2012-01-04 14:18Rolf Eike BeerTarget Version => CMake 2.8.8
2012-01-21 16:27Rolf Eike BeerNote Added: 0028387
2012-01-21 16:27Rolf Eike BeerAssigned ToDavid Cole => Rolf Eike Beer
2012-01-21 16:27Rolf Eike BeerStatusassigned => resolved
2012-01-21 16:27Rolf Eike BeerResolutionreopened => fixed
2012-01-21 16:27Rolf Eike BeerFixed in Version => CMake 2.8.8
2012-07-09 06:52David ColeNote Added: 0029959
2012-07-09 06:52David ColeStatusresolved => closed

Notes
(0024476)
Ben Boeckel   
2011-01-06 14:50   
Not sure if I'll have time to get around to this before 2.8.4.
(0025250)
Rolf Eike Beer   
2011-02-03 15:39   
Entirely untested, I'll see if I find time to test it the next days.
(0026249)
Brad King   
2011-04-25 11:40   
Patch "19a4b885+0001-FindThreads-Try-pthreads-with-no-special-option-firs.patch" is a git format-patch version of pthread_libc.diff based on commit 19a4b885. I created it just to make this easier to integrate later. Can anyone test this on QNX and verify that it works? Is the result changed on Linux?
(0027185)
Rolf Eike Beer   
2011-08-09 14:03   
Sorry, I don't have access to the QNX machine anymore.
(0027256)
David Cole   
2011-08-20 14:58   
Fix pushed to CMake 'next'

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fd61be71401ef9e0a241562fc31539273084deff [^]
(0027417)
David Cole   
2011-09-14 12:38   
The patch used to fix this issue has apparently caused 0012457

What is the right fix for BOTH of these issues?

Please add notes here with your thoughts and ideas...

Thanks!
(0027419)
Funda Wang   
2011-09-14 12:42   
Ugly hack:

http://svnweb.mageia.org/packages/cauldron/cmake/current/SOURCES/cmake-2.8.6-fix-thread-detection.patch [^]
(0027420)
Funda Wang   
2011-09-14 12:51   
Maybe the real problem comes from CHECK_SYMBOL_EXISTS function. It does not produce real link against specific function. For instance:

$ cat a.c
#include <math.h>

 void cmakeRequireSymbol(int dummy,...){(void)dummy;}
 int main()
 {
   cmakeRequireSymbol(0,&sin);
   return 0;
 }

It is obviously when linking a.c, we should pass -lm as libs, but it does not produce 'sin' symbol.
(0027422)
Brad King   
2011-09-14 16:44   
Re 0011333:0027420: Your require-symbol example does really link to sin:

$ gcc a.c
/tmp/ccWOt2zo.o: In function `main':
a.c:(.text+0x71): undefined reference to `sin'
collect2: ld returned 1 exit status
$ gcc a.c -lm
$
(0027424)
Orion Poplawski   
2011-09-14 17:38   
Try it with optimization (-O)
$ gcc -O a.c
$
(0027431)
Rolf Eike Beer   
2011-09-16 04:06   
So the problem we se here looks indeed like a problem in CHECK_SYMBOL_EXISTS for me. But on the other hand I can't find any test that checks either CHECK_SYMBOL_EXISTS or FindThreads.

Should we split out a different bug (with high priority I would say) that CHECK_SYMBOL_EXISTS is unreliable depending e.g. on optimization?
(0027478)
David Cole   
2011-09-22 16:57   
Not enough time left to address this issue before the 2.8.6 release. Deferred until a future release.
(0027966)
David Cole   
2011-12-13 19:20   
Unset target version field; too late for a fix to go into 2.8.7; deferred until a future version.
(0028137)
Rolf Eike Beer   
2012-01-02 17:13   
I have pushed a branch test-symbol-exists that indeed proves that this is a bug in CheckSymbolExists.
(0028387)
Rolf Eike Beer   
2012-01-21 16:27   
Pushed to next (again). CheckSymbolExists should really work now, so this should not cause any additional pain.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3dc6f2bfb34ff90a905b10872e98c163940f456a [^]
(0029959)
David Cole   
2012-07-09 06:52   
Closing resolved issues that have not been updated in more than 4 months.