Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pthread checks and compiler flags #8

Closed
mia-0 opened this issue Nov 26, 2011 · 9 comments
Closed

Add pthread checks and compiler flags #8

mia-0 opened this issue Nov 26, 2011 · 9 comments

Comments

@mia-0
Copy link

mia-0 commented Nov 26, 2011

Currently, rtorrent fails to compile on some systems because it’s missing some compiler flags.

Please add Autoconf checks for pthread, and use the appropriate compiler flags (on most systems, adding -pthread to CXXFLAGS and LDFLAGS should do the trick).

@rakshasa
Copy link
Owner

Should be fixed now.

@vp1981
Copy link

vp1981 commented Dec 16, 2011

Still there, to build rtorrent from git, commit `ee859a61375ad3919ebab41b730b6edcdaaeb21a', I have to set LIBS:
export LIBS="-lpthread"
...

OS: Archlinux x86_64,
LIBC: glibc, 2.14.1
LD: binutils-2.22, (ld --version -> 2.22.0.20111201)
libpthread: /lib/libpthread-2.14.1.so
            /lib/libpthread.so -> /lib/libpthread-2.14.1.so

I missed something?

@rakshasa
Copy link
Owner

Do 'grep PTHREAD config.log' and check that the PTHREAD_LIBS is the right value.

Also grep for FLAGS and LIBS.

@vp1981
Copy link

vp1981 commented Dec 16, 2011

I tried: unset LIBS, run makepkg (explanation below) but compilation failed:

libtool: link: g++ -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fno-strict-aliasing -g -DDEBUG -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include -I/usr/include -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z -Wl,relro -Wl,--hash-style=gnu -o rtorrent main.o  libsub_root.a ui/libsub_ui.a core/libsub_core.a display/libsub_display.a input/libsub_input.a rpc/libsub_rpc.a utils/libsub_utils.a -lncursesw -lsigc-2.0 -lcurl -ltorrent -L/usr/lib -lxmlrpc_server -lxmlrpc -lxmlrpc_util -lxml2 -lz -lm
/usr/bin/ld: libsub_root.a(thread_base.o): undefined reference to symbol 'pthread_kill@@GLIBC_2.2.5'
/usr/bin/ld: note: 'pthread_kill@@GLIBC_2.2.5' is defined in DSO /lib/libpthread.so.0 so try adding it to the linker command line
/lib/libpthread.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

then did
$ grep 'PTHREAD' config.log
and got

PTHREAD_CC='gcc'
PTHREAD_CFLAGS=' -pthread '
PTHREAD_LIBS=' -lpthread   '

After I set LIBS again and successfully compile rtorrent again. settings for PTHREAD are the same.

Not sure what could cause the failure but here is where libpthread located:

$ ls -l /lib/libpthread*
-rwxr-xr-x 1 root root 135326 Dec  3 03:29 /lib/libpthread-2.14.1.so
lrwxrwxrwx 1 root root     20 Dec  3 03:29 /lib/libpthread.so.0 -> libpthread-2.14.1.so
$ ls -l /usr/lib/libpthread*
-rw-r--r-- 1 root root 385742 Dec  3 03:29 /usr/lib/libpthread.a
-rw-r--r-- 1 root root    218 Dec  3 03:28 /usr/lib/libpthread.so
-rw-r--r-- 1 root root   1772 Dec  3 03:29 /usr/lib/libpthread_nonshared.

P.S. I'm using Archlinux as I already said so I use makepkg tool and PKGBUILD in which I set or unset env variables.

@rakshasa
Copy link
Owner

You also need to grep for LIBS and CXXFLAGS.

@vp1981
Copy link

vp1981 commented Dec 17, 2011

Now I'm completely confused.
I run makepkg w/o set LIBS, grep for PTHREAD, LIBS, CFLAGS in config.log and save results in 'rtorrent-wo.txt'. After that I set LIBS and run makepkg again, grep the same save output in 'rtorrent-w.txt'. Now the differences:

$ diff -Naur rtorrent-w{o,}.txt
--- rtorrent-wo.txt     2011-12-17 12:02:06.000000000 +0900
+++ rtorrent-w.txt      2011-12-17 12:00:55.000000000 +0900
@@ -1,11 +1,11 @@
 $ grep 'PTHREAD' config.log
 PTHREAD_CC='gcc'
-PTHREAD_CFLAGS=' -pthread '
-PTHREAD_LIBS=' -lpthread   '
+PTHREAD_CFLAGS='  -pthread '
+PTHREAD_LIBS=' -lpthread     '

 $ grep 'LIBS' config.log
-ac_cv_env_LIBS_set=
-ac_cv_env_LIBS_value=
+ac_cv_env_LIBS_set=set
+ac_cv_env_LIBS_value=-lpthread
 ac_cv_env_libcurl_LIBS_set=
 ac_cv_env_libcurl_LIBS_value=
 ac_cv_env_libtorrent_LIBS_set=
@@ -16,8 +16,8 @@
 pkg_cv_libtorrent_LIBS='-ltorrent  '
 pkg_cv_sigc_LIBS='-lsigc-2.0  '
 CPPUNIT_LIBS='-lcppunit -ldl'
-LIBS='-lncursesw  -lsigc-2.0   -lcurl   -ltorrent   -L/usr/lib   -lxmlrpc_server -lxmlrpc -lxmlrpc_util -lxml2 -lz -lm '
-PTHREAD_LIBS=' -lpthread   '
+LIBS='-lncursesw -lpthread -lsigc-2.0   -lcurl   -ltorrent   -L/usr/lib   -lxmlrpc_server -lxmlrpc -lxmlrpc_util -lxml2 -lz -lm '
+PTHREAD_LIBS=' -lpthread     '
 libcurl_LIBS='-lcurl  '
 libtorrent_LIBS='-ltorrent  '
 sigc_LIBS='-lsigc-2.0  '
@@ -36,7 +36,7 @@
 pkg_cv_sigc_CFLAGS='-I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include  '
 CFLAGS='-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2'
 CPPUNIT_CFLAGS=''
-PTHREAD_CFLAGS=' -pthread '
+PTHREAD_CFLAGS='  -pthread '
 libcurl_CFLAGS=' '
 libtorrent_CFLAGS=' '
 sigc_CFLAGS='-I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include  '

and ignoring spaces

$ diff -Nbaur rtorrent-w{o,}.txt
--- rtorrent-wo.txt     2011-12-17 12:02:06.000000000 +0900
+++ rtorrent-w.txt      2011-12-17 12:00:55.000000000 +0900
@@ -4,8 +4,8 @@
 PTHREAD_LIBS=' -lpthread   '

 $ grep 'LIBS' config.log
-ac_cv_env_LIBS_set=
-ac_cv_env_LIBS_value=
+ac_cv_env_LIBS_set=set
+ac_cv_env_LIBS_value=-lpthread
 ac_cv_env_libcurl_LIBS_set=
 ac_cv_env_libcurl_LIBS_value=
 ac_cv_env_libtorrent_LIBS_set=
@@ -16,7 +16,7 @@
 pkg_cv_libtorrent_LIBS='-ltorrent  '
 pkg_cv_sigc_LIBS='-lsigc-2.0  '
 CPPUNIT_LIBS='-lcppunit -ldl'
-LIBS='-lncursesw  -lsigc-2.0   -lcurl   -ltorrent   -L/usr/lib   -lxmlrpc_server -lxmlrpc -lxmlrpc_util -lxml2 -lz -lm '
+LIBS='-lncursesw -lpthread -lsigc-2.0   -lcurl   -ltorrent   -L/usr/lib   -lxmlrpc_server -lxmlrpc -lxmlrpc_util -lxml2 -lz -lm '
 PTHREAD_LIBS=' -lpthread   '
 libcurl_LIBS='-lcurl  '
 libtorrent_LIBS='-ltorrent  '

Any suggestions?

@rakshasa
Copy link
Owner

Updated the pthread checks to have the setting of LIBS and CXXFLAGS outside of the macro, not sure if it will fix anything but you can try.

@vp1981
Copy link

vp1981 commented Dec 19, 2011

Thank you, now I'm able to compile rtorrent w/o need to set LIBS.

@Ulrar
Copy link

Ulrar commented Feb 24, 2014

I had that problem on gentoo (rtorrent-0.8.9), using LIBS="-lpthread" emerge rtorrent solved the problem. Might want to update the ebuild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants