From owner-freebsd-ports@FreeBSD.ORG Wed Jun 9 23:49:33 2004 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D6C8F16A4CE for ; Wed, 9 Jun 2004 23:49:33 +0000 (GMT) Received: from mail.ambrisko.com (adsl-64-174-51-43.dsl.snfc21.pacbell.net [64.174.51.43]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7AB8843D2D for ; Wed, 9 Jun 2004 23:49:33 +0000 (GMT) (envelope-from ambrisko@ambrisko.com) Received: from server2.ambrisko.com (HELO www.ambrisko.com) (192.168.1.2) by mail.ambrisko.com with ESMTP; 09 Jun 2004 16:49:11 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by www.ambrisko.com (8.12.9p2/8.12.9) with ESMTP id i59NnBSU082029; Wed, 9 Jun 2004 16:49:11 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.12.9p2/8.12.9/Submit) id i59NnBcu082028; Wed, 9 Jun 2004 16:49:11 -0700 (PDT) (envelope-from ambrisko) From: Doug Ambrisko Message-Id: <200406092349.i59NnBcu082028@ambrisko.com> In-Reply-To: <33E67F1E-B976-11D8-8148-003065ABFD92@mac.com> To: Charles Swiger Date: Wed, 9 Jun 2004 16:49:11 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL94b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII cc: freebsd-ports@freebsd.org Subject: Re: RFC: [Long] Change PTHREAD_LIBS to -pthread for -CURRENT X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2004 23:49:34 -0000 Charles Swiger writes: | Second, LD_PRELOAD is intended to solve the issue of "how do I | substitute a different version of a shared library (so long as it | provides the symbols needed by the program so that the executable | dynamicly links) than the one the program was actually linked against". | | Solaris uses this mechanism to support different flavors of malloc | besides the default SCD-compliant one, such as bsdmalloc and mapmalloc, | and it also uses this mechanism to provide backwards compatibility with | buggy programs as per "man ld.so.1": | | NOTES | The user compatibility library /usr/lib/0@0.so.1 provides a | mechanism that establishes a value of 0 at location 0. Some | applications exist that erroneously assume a null character | pointer should be treated the same as a pointer to a null | string. A segmentation violation will occur in these appli- | cations when a null character pointer is accessed. If this | library is added to such an application at runtime using | LD_PRELOAD, it provides an environment that is sympathetic | to this errant behavior. However, the user compatibility | library is intended neither to enable the generation of such | applications, nor to endorse this particular programming | practice. | | For this to actually be useful (usable?) under FreeBSD, the implication | is that the different thread libraries which exist under FreeBSD need | to be interchangable via dynamic linking, rather than requiring | compile-time changes to the code using threads. I don't know whether | libpthreads, libc_r, and libkse can be switched using dynamic linking, | but if they can't, pick the best implementation and make it the default | that "cc -pthreads" uses. As the original author of the FreeBSD implementation of LD_PRELOAD with help from the commiter that commited it for me ... There is a problem with LD_PRELOAD since the libc's are not interchangable. With Solaris you can do "runsocks" a thread program and it works but fails under FreeBSD. "runsocks" does a LD_PRELOAD of a stub libc type thing that has a replacement network calls like send etc. It then dlopen libc to then run the real send etc. after the socksification has been done to the protocol to talk to the socks proxy if needed. Under FreeBSD we need to pull in the libc_r version instead of libc if the program is threaded. This is not a problem with Solaris but is with FreeBSD. I forget about Linux. So to socksify Netscape I had to compile a socks shim with libc_r and then use that version if the program was threaded or you the other if it wasn't :-( Adding the minimal libc_r layer onto of libc didn't really make this situation better. Now I admit I don't use this as much as a few years ago. These problem occured after the LD_PRELOAD was added since it was added before libc_r existed. FWIW, Doug A.