View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010710CMakeModulespublic2010-05-13 19:112016-06-10 14:31
ReporterDaniel Richard G. 
Assigned ToBill Hoffman 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake-2-8 
Target VersionFixed in Version 
Summary0010710: FindThreads.cmake does not work properly on Tru64
Descriptionfind_package(Threads) in CMake 2.8.1 does not work correctly on OSF/Tru64. There are multiple problems with the module as it is currently written:

1. At line 141, there is a platform-specific conditional (CMAKE_SYSTEM MATCHES "OSF1-V*") that blanks out the name of the pthread library. This is not correct for my particular system; without a threading directive passed to the compiler, code fails to link due to missing pthread functions.

2. Prior to that point, the module does find -lpthread. But this is not the correct directive to use, according to the cc(1) man page: it's -pthread. (Note, of course, that this does not necessarily apply if GCC is being used.)

3a. The situation on this system is even more complicated than that, however. Both -lpthread (singular) and -lpthreads (plural) exist, and

3b. -lpthreads exports "pthread_create", while -lpthread exports "__pthread_create", and

3c. If you do a normal CHECK_LIBRARY_EXISTS() call, then -lpthreads appears to be the correct library. But if you do your own test program, which #includes pthread.h, pthread_create() becomes a preprocessor macro that expands to __pthread_create(). So -lpthread is the actual library needed.


Here's what I see as the takeaway:

1. If -pthread/-thread/-mt/etc. does the trick, use that in preference to any -l* library specifier.

2. The function-link test has to be done with a source file that #includes pthread.h, otherwise it's useless.

3. There's no need to special-case OSF/Tru64, because a robust enough FindThreads module can handle it.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0036988)
Rolf Eike Beer (developer)
2014-10-06 16:20

Does using "-pthread" in both CMAKE_C_FLAGS and target_link_libraries() at the same time work? In this case this would be just another instance of "-pthread should be preferred over explicitely specifying a library". Does this problem still exist in 3.0.2 or newer at all?
(0041696)
Kitware Robot (administrator)
2016-06-10 14:28

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2010-05-13 19:11 Daniel Richard G. New Issue
2010-08-03 12:24 Kovarththanan Rajaratnam Category CMake => Modules
2010-12-15 09:11 David Cole Assigned To => Bill Hoffman
2010-12-15 09:11 David Cole Status new => assigned
2014-10-06 16:20 Rolf Eike Beer Note Added: 0036988
2016-06-10 14:28 Kitware Robot Note Added: 0041696
2016-06-10 14:28 Kitware Robot Status assigned => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team