View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012457CMakeCMakepublic2011-09-14 11:282012-03-06 08:37
ReporterFunda Wang 
Assigned ToDavid Cole 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformLinuxOSMageiaOS VersionCauldron
Product VersionCMake-2-8 
Target VersionCMake 2.8.6Fixed in VersionCMake 2.8.6 
Summary0012457: Wrong detection for pthread under Linux
DescriptionThe patch introduced in 0011333 produces wrong result for Linux.

It always builds successful when checking symbols within the first round detection. i.e.

<snip>
Run Build Command:/usr/bin/gmake "cmTryCompileExec/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build
gmake[1]: Entering directory `/home/fwang/rpm/BUILD/OpenSceneGraph-3.0.0/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/fwang/rpm/BUILD/OpenSceneGraph-3.0.0/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec.dir/CheckSymbolExists.c.o
/usr/bin/gcc -O2 -g -frecord-gcc-switches -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -mtune=generic -march=i586 -fasynchronous-unwind-tables -o a.c.o -c a.c
Linking C executable cmTryCompileExec
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
/usr/bin/gcc -O2 -g -frecord-gcc-switches -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fomit-frame-pointer -mtune=generic -march=i586 -fasynchronous-unwind-tables -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags a.c.o -o cmTryCompileExec -rdynamic
gmake[1]: Leaving directory `/home/fwang/rpm/BUILD/OpenSceneGraph-3.0.0/build/CMakeFiles/CMakeTmp'

File /home/fwang/rpm/BUILD/OpenSceneGraph-3.0.0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

void cmakeRequireSymbol(int dummy,...){(void)dummy;}
int main()
{
#ifndef pthread_create
  cmakeRequireSymbol(0,&pthread_create);
#endif
  return 0;
}
</snip>

Maybe check libc's pthread function should be conditioned with platform.
TagsNo tags attached.
Attached Files

 Relationships
related to 0011333closedRolf Eike Beer FindThreads incorrectly adds -pthread to linker options 

  Notes
(0027418)
David Cole (manager)
2011-09-14 12:41

What is the right fix for this *and* 0011333?

Please add notes here or on 0011333 with your thoughts and ideas...

Thanks!
(0027421)
Eric NOULARD (developer)
2011-09-14 13:55

I'm not sure to understand the problem.
Currently using

find_package(Thread)

On linux leads to have
CMAKE_THREAD_LIBS_INIT = -lpthread
is this an unwanted result?

You'd rather use -pthread?
Is that the trouble as explained here:
http://stackoverflow.com/questions/1662909/undefined-reference-to-pthread-create-in-linux-c-programming [^]

just asking in order to be sure to understand the issue
because on my box linking with -lpthread is working ok.
(0027423)
Orion Poplawski (reporter)
2011-09-14 17:31

The problem is that with optimization enabled, the compiler optimizes out the pthread_create reference:

$ gcc -c /home/orion/thrtest/CMakeFiles/CMakeTmp/CheckSymbolExists.c
$ nm CheckSymbolExists.o
0000000000000000 T cmakeRequireSymbol
0000000000000057 T main
                 U pthread_create
$ gcc -c -O1 /home/orion/thrtest/CMakeFiles/CMakeTmp/CheckSymbolExists.c
$ nm CheckSymbolExists.o
0000000000000000 T cmakeRequireSymbol
0000000000000002 T main

So the check is flawed - it incorrectly thinks pthread_create is in libc (or some other default lib).
(0027651)
David Cole (manager)
2011-10-26 00:09

This was resolved by reverting the change that caused it: the fix for related issue 0011333. That issue is now re-opened...
(0028836)
David Cole (manager)
2012-03-06 08:37

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2011-09-14 11:28 Funda Wang New Issue
2011-09-14 12:37 David Cole Relationship added related to 0011333
2011-09-14 12:37 David Cole Assigned To => David Cole
2011-09-14 12:37 David Cole Status new => assigned
2011-09-14 12:41 David Cole Note Added: 0027418
2011-09-14 13:55 Eric NOULARD Note Added: 0027421
2011-09-14 17:31 Orion Poplawski Note Added: 0027423
2011-10-26 00:09 David Cole Note Added: 0027651
2011-10-26 00:09 David Cole Status assigned => resolved
2011-10-26 00:09 David Cole Fixed in Version => CMake 2.8.6
2011-10-26 00:09 David Cole Resolution open => fixed
2011-10-26 00:09 David Cole Target Version => CMake 2.8.6
2012-03-06 08:37 David Cole Note Added: 0028836
2012-03-06 08:37 David Cole Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team