Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 371647 - dev-cpp/gtest-1.5.0 doesn't link to pthread as it should
Summary: dev-cpp/gtest-1.5.0 doesn't link to pthread as it should
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: MATSUU Takuto (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-14 20:18 UTC by Łukasz Michalik
Modified: 2012-11-05 16:32 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
files/gtest-1.5.0-pthread-as-needed.patch (gtest-1.5.0-pthread-as-needed.patch,1.94 KB, patch)
2011-09-28 08:08 UTC, Christian Burger
Details | Diff
patch to gtest 1.5.0 ebuild (gtest-1.5.0.ebuild.patch,1.40 KB, patch)
2011-09-28 08:10 UTC, Christian Burger
Details | Diff
configure-fix-pthread-linking.patch (0001-configure-fix-pthread-linking.patch,3.07 KB, text/plain)
2012-10-15 21:29 UTC, Justin Bronder (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Łukasz Michalik 2011-06-14 20:18:59 UTC
# ldd /usr/lib64/libgtest.so
        linux-vdso.so.1 =>  (0x000002c576dc1000)
        libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/libstdc++.so.6 (0x000002c576840000)
        libc.so.6 => /lib64/libc.so.6 (0x000002c5764d8000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x000002c5762c1000)
        libm.so.6 => /lib64/libm.so.6 (0x000002c576040000)
        /lib64/ld-linux-x86-64.so.2 (0x000002c576dc2000)
panoramix / # nm -D /usr/lib64/libgtest.so | grep pthread
                 w pthread_cancel
                 U pthread_getspecific
                 U pthread_key_create
                 U pthread_key_delete
                 U pthread_mutex_destroy
                 U pthread_mutex_init
                 U pthread_mutex_lock
                 U pthread_mutex_unlock
                 U pthread_self
                 U pthread_setspecific

Reproducible: Always
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2011-06-15 01:23:05 UTC
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking whether to check for GCC pthread/shared inconsistencies... yes
checking whether -pthread is sufficient with -shared... yes

The configure checks are correct. You don't need to link to anything except libc.

$ nm -D /lib/libc.so.6 |grep pthread
00000000000df370 T __libc_pthread_init
00000000000de910 T pthread_attr_destroy
00000000000de970 T pthread_attr_getdetachstate
00000000000de9d0 T pthread_attr_getinheritsched
00000000000dea30 T pthread_attr_getschedparam
00000000000dea90 T pthread_attr_getschedpolicy
00000000000deaf0 T pthread_attr_getscope
00000000000de940 T pthread_attr_init
00000000000de9a0 T pthread_attr_setdetachstate
00000000000dea00 T pthread_attr_setinheritsched
00000000000dea60 T pthread_attr_setschedparam
00000000000deac0 T pthread_attr_setschedpolicy
00000000000deb20 T pthread_attr_setscope
0000000000109470 T pthread_cond_broadcast
00000000000debb0 T pthread_cond_broadcast
00000000000debe0 T pthread_cond_destroy
00000000001094a0 T pthread_cond_destroy
00000000000dec10 T pthread_cond_init
00000000001094d0 T pthread_cond_init
00000000000dec40 T pthread_cond_signal
0000000000109500 T pthread_cond_signal
00000000000deca0 T pthread_cond_timedwait
0000000000109560 T pthread_cond_timedwait
00000000000dec70 T pthread_cond_wait
0000000000109530 T pthread_cond_wait
00000000000deb50 T pthread_condattr_destroy
00000000000deb80 T pthread_condattr_init
00000000000de8e0 T pthread_equal
00000000000dee80 T pthread_exit
00000000000decd0 T pthread_getschedparam
00000000000ded30 T pthread_mutex_destroy
00000000000ded60 T pthread_mutex_init
00000000000ded90 T pthread_mutex_lock
00000000000dedc0 T pthread_mutex_unlock
00000000000dedf0 T pthread_self
00000000000dee20 W pthread_setcancelstate
00000000000dee50 T pthread_setcanceltype
00000000000ded00 T pthread_setschedparam
Comment 2 Ciaran McCreesh 2011-06-15 10:38:13 UTC
Look more carefully: gtest uses pthread_key_*.
Comment 3 Łukasz Michalik 2011-06-15 11:44:08 UTC
(In reply to comment #1)
> The configure checks are correct. You don't need to link to anything except
> libc.

No.  glibc seems to be providing *some* of pthread symbols, but not all off them, namely pthread_key_* and pthread_*specific:

# nm -D /lib/libc.so.6 | grep -E 'pthread_(.*specific|key)'
# nm -D /lib/libpthread.so.0 | grep -E 'pthread_(.*specific|key)'
000000000000c5e0 T __pthread_getspecific
000000000000c540 T __pthread_key_create
000000000000c660 T __pthread_setspecific
000000000000c5e0 T pthread_getspecific
000000000000c540 T pthread_key_create
000000000000c5a0 T pthread_key_delete
000000000000c660 T pthread_setspecific

Currently the library isn't expressing that dependency.
Comment 4 Christian Burger 2011-09-28 08:04:52 UTC
I have the same problem here. Solved the problem with a quick fix to the dev-util/gtest ebuild. Instead of using autoconf and friends I used the experimental CMake script provided. I had to alter it a little (added installation routine and an option to build without pthread library) and change the ebuild accordingly.

My ebuild does not support 'static-libs' anymore (as far as I see: none of the packages in the Gentoo tree need it) and there is no symlinking or version numbering of the library like '/usr/lib/libgtest.so -> libgtest.so.0.0.0', instead just plain and simple '/usr/lib/libgtest.so'. I was too lazy to do the replacement of the placeholders in 'gtest-config.in' manually, so for that bit I am still using the configure-script -- not aesthetically pleasing, but it works (at least for sys-apps/paludis-0.68.0).

Anyways, I will attach my quick fix.


Related bug at Google Code:
http://code.google.com/p/googletest/issues/detail?id=336
Comment 5 Christian Burger 2011-09-28 08:08:14 UTC
Created attachment 288055 [details, diff]
files/gtest-1.5.0-pthread-as-needed.patch

switch from static to shared lib generation; provided install routines (installs gtest-config, which is generated by the configure script -- not pretty)
Comment 6 Christian Burger 2011-09-28 08:10:34 UTC
Created attachment 288057 [details, diff]
patch to gtest 1.5.0 ebuild
Comment 7 Justin Bronder (RETIRED) gentoo-dev 2012-10-15 21:29:18 UTC
Created attachment 326650 [details]
configure-fix-pthread-linking.patch

Still a problem in 1.6.0.  I've attached a fix that doesn't require using cmake as the previous fix still wasn't applied.
Comment 8 Justin Bronder (RETIRED) gentoo-dev 2012-11-02 05:10:02 UTC
Fixed in dev-cpp/gtest-1.6.0-r1
Comment 9 SpanKY gentoo-dev 2012-11-05 16:32:59 UTC
(In reply to comment #8)

did you send these changes to the respective upstream ?

the patch name is also wrong in the tree.  you should follow the ${P} standard.