From owner-freebsd-ports@FreeBSD.ORG Tue Jun 8 18:04:07 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 8A40116A4CE for ; Tue, 8 Jun 2004 18:04:07 +0000 (GMT) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.86]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3EF9B43D39 for ; Tue, 8 Jun 2004 18:04:07 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from mac.com (smtpin08-en2 [10.13.10.153]) by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id i58I42o1011054 for ; Tue, 8 Jun 2004 11:04:02 -0700 (PDT) Received: from [10.1.1.193] (nfw2.codefab.com [199.103.21.225] (may be forged)) (authenticated bits=0) by mac.com (Xserve/smtpin08/MantshX 4.0) with ESMTP id i58I3vBO027056 for ; Tue, 8 Jun 2004 11:04:01 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v618) In-Reply-To: <200406081817.43175.michaelnottebrock@gmx.net> References: <1086673141.18374.35.camel@shumai.marcuscom.com> <200406081020.48658.michaelnottebrock@gmx.net> <20040608084115.GC3604@freebsd3.cimlogic.com.au> <200406081817.43175.michaelnottebrock@gmx.net> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <33E67F1E-B976-11D8-8148-003065ABFD92@mac.com> Content-Transfer-Encoding: 7bit From: Charles Swiger Date: Tue, 8 Jun 2004 14:03:53 -0400 X-Mailer: Apple Mail (2.618) 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: Tue, 08 Jun 2004 18:04:07 -0000 On Jun 8, 2004, at 12:17 PM, Michael Nottebrock wrote: > On Tuesday 08 June 2004 10:41, John Birrell wrote: >> The reason was that the gcc people want -pthread to be the standard >> way of sucking in thread support via their compiler. They intend the >> -pthread option to be used across all operating systems, notably >> including Linux. > > I see. How do we address the issue of having multiple threads > libraries to > choose from then? I take it using the libmap feature is not the answer. First, I'm fully in favor of using "-pthread" to tell the compiler "compile and link the code using whatever additional flags and mechanisms are necessary to support POSIX threads", rather than having to specific some combination of "-D_THREAD_SAFE -DPIC -lpthread", etc, particularly as that combination changes from OS to OS, or even from release to release within a specific OS. 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. -- -Chuck