From owner-freebsd-threads@FreeBSD.ORG Tue Sep 22 16:16:20 2009 Return-Path: Delivered-To: freebsd-threads@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 329D0106568B for ; Tue, 22 Sep 2009 16:16:20 +0000 (UTC) (envelope-from ale@FreeBSD.org) Received: from andxor.it (relay.andxor.it [195.223.2.3]) by mx1.freebsd.org (Postfix) with SMTP id 7953E8FC1F for ; Tue, 22 Sep 2009 16:16:19 +0000 (UTC) Received: (qmail 88349 invoked from network); 22 Sep 2009 15:49:37 -0000 Received: from unknown (HELO ale.andxor.it) (192.168.2.5) by andxor.it with SMTP; 22 Sep 2009 15:49:37 -0000 Message-ID: <4AB8F211.3070707@FreeBSD.org> Date: Tue, 22 Sep 2009 17:49:37 +0200 From: Alex Dupre User-Agent: Thunderbird 2.0.0.22 (X11/20090624) MIME-Version: 1.0 To: freebsd-threads@FreeBSD.org Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: Subject: how to overcome missing stubs in FreeBSD 6 X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2009 16:16:20 -0000 Hello, I have a scenario with a thread-safe library that uses pthread_equal() function. In FreeBSD 7+ there is the appropriate libc stub, but in FreeBSD 6 it's missing, so a single-threaded binary linked to this library should be linked also to a threading library to resolve the missing symbol. This is not good for two reasons: - additional overhead for useless threading lib - different linking between FreeBSD versions I thought that declaring pthread_equal() as weak symbol with a stub function in the library would globally solve the problem in FreeBSD 6, but actually it doesn't work as expected: a binary linked to the library with -pthread continues to use the stub function instead of the one defined in libpthread. The only way I found to make it working was to link directly to -lpthread *before* the incriminated lib, but this is not acceptable. Is there a clean solution? -- Alex Dupre