From: Csaba H. <csa...@cr...> - 2006-05-29 20:23:34
|
On 2006-05-29, Terrence Cole <ter...@tr...> wrote: > Csaba Henk wrote: >> On 2006-05-28, Terrence Cole <ter...@tr...> wrote: > A very good question. From what I can glean in `man gcc`, -pthread is > more correct. The flag "-pthread" tells gcc to "build a target with > thread support." Glibc appears to distribute its threading code in > libpthread.so. Thus, in linux, it doesn't matter which flag is used > since -pthread just tells gcc to link in libpthread, as you can see below. > > Building with -lpthread (without the patch): > > terrence@lemur ~/P/f/f/lib> ldd .libs/libfuse.so.2.6.0 > linux-gate.so.1 => (0xffffe000) > libpthread.so.0 => /lib/libpthread.so.0 (0xb7f95000) > librt.so.1 => /lib/librt.so.1 (0xb7f8b000) > libc.so.6 => /lib/libc.so.6 (0xb7e73000) > /lib/ld-linux.so.2 (0x80000000) > > Building with -pthread (with the patch): > > terrence@lemur ~/P/f/f/lib> ldd .libs/libfuse.so.2.6.0 > linux-gate.so.1 => (0xffffe000) > librt.so.1 => /lib/librt.so.1 (0xb7ec3000) > libpthread.so.0 => /lib/libpthread.so.0 (0xb7eaf000) > libc.so.6 => /lib/libc.so.6 (0xb7d97000) > /lib/ld-linux.so.2 (0x80000000) > > It would appear that FBSD's libc does not provide its threading in an > external library, but has it built-in instead, so only works with > -pthread and not -lpthread. > > Other platforms require things like -lthr, -threads, etc. The complete > pthread test macro probably isn't _needed_ but should provide automatic > support if fuse ever makes it to one of those platforms. It also > provides a drop-target (m4/) for other off-the-shelf autoconf macros, > which may come in useful. > > Thanks for prompting me to look all this up; I've been meaning to figure > out the semantic differences on this issue for awhile. :-) Thank you for looking it up. Miklos, what do you think about this patch? One more weirdness can be seen related to pkg-config (for which you didn't do the adjustments). What seemed logical to me is the following for fuse.pc.in: --------------------------------------------- prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ pthread_cflags=@PTHREAD_CFLAGS@ pthread_libs=@PTHREAD_LIBS@ Name: fuse Description: Filesystem in Userspace Version: @VERSION@ Libs: -L${libdir} -lfuse ${pthread_libs} Cflags: -I${includedir}/fuse -D_FILE_OFFSET_BITS=64 ${pthread_cflags} --------------------------------------------- However, it's not good. (Eg. on FreeBSD, PTHREAD_CFLAGS will be set to "-D_THREAD_SAFE -pthread", PTHREAD_LIBS to "", and then, sshfs compilation fails at the final linking stage.) What works indeed is --------------------------------------------- prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ pthread_cflags=@PTHREAD_CFLAGS@ Name: fuse Description: Filesystem in Userspace Version: @VERSION@ Libs: -L${libdir} -lfuse ${pthread_cflags} Cflags: -I${includedir}/fuse -D_FILE_OFFSET_BITS=64 --------------------------------------------- That is, it seems as if the toolchain would like to see the "-pthread" exactly at those places where you'd put "-lpthread", regardless the semantical difference between the two. Regards, Csaba |