Subject: toolchain/20095: cc -shared -pthread doesn't link with libpthread
To: None <gnats-bugs@gnats.netbsd.org>
From: Matthias Scheler <tron@colwyn.zhadum.de>
List: netbsd-bugs
Date: 01/28/2003 18:37:01
>Number:         20095
>Category:       toolchain
>Synopsis:       cc -shared -pthread doesn't link with libpthread
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 28 09:38:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 1.6M 2003-01-27 sources
>Organization:
Matthias Scheler                                  http://scheler.de/~matthias/
>Environment:
System: NetBSD lyssa.b5.zhadum.de 1.6M NetBSD 1.6M (LYSSA) #1: Mon Jan 27 22:13:56 CET 2003 tron@lyssa.b5.zhadum.de:/src/sys/compile/LYSSA i386
Architecture: i386
Machine: i386

>Description:
The "configure" script of the "glib2" distribution recognized the new
"-pthread" switch of NetBSD's "cc" compiler frontend and uses it:

cc -shared -nodefaultlibs  .libs/gthread-impl.o  -Wl,--rpath -Wl,/src/NetBSD-current/pkgsrc/devel/glib2/work/glib-2.2.0/glib/.libs -Wl,--rpath -Wl,/usr/pkg/lib  -L/src/NetBSD-current/pkgsrc/devel/glib2/work/.buildlink/lib ../glib/.libs/libglib-2.0.so /usr/lib/libintl.so  -Wl,-R/usr/pkg/lib -pthread -Wl,-soname -Wl,libgthread-2.0.so.200 -o .libs/libgthread-2.0.so.200.0

Unfortunately "cc" doesn't link the created shared object with "libpthread":

tron@lyssa:/usr/pkgsrc/devel/glib2>ldd work/glib-2.2.0/gthread/.libs/libgthread-2.0.so.200.0
work/glib-2.2.0/gthread/.libs/libgthread-2.0.so.200.0:
         -lm.0 => /usr/lib/libm387.so.0
         -lm.0 => /usr/lib/libm.so.0
         -liconv.3 => /usr/pkg/lib/libiconv.so.3
         -lintl.0 => /usr/lib/libintl.so.0

This causes lots of build failures in program which are linked with
"libgthread" later e.g. while building the "gtk2" package. Building
these packages worked fine before "cc" had the "-pthread" switch.

>How-To-Repeat:
pkg_delete -r glib2
cd /usr/pkgsrc/x11/gtk2
make

>Fix:
None provided.
>Release-Note:
>Audit-Trail:
>Unformatted: