From owner-freebsd-current@FreeBSD.ORG Sat Nov 10 02:14:53 2012 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E81CB3A0; Sat, 10 Nov 2012 02:14:53 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by mx1.freebsd.org (Postfix) with ESMTP id BB14E8FC0A; Sat, 10 Nov 2012 02:14:53 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.5/8.14.5) with ESMTP id qAA2Erbr079671; Fri, 9 Nov 2012 18:14:53 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.5/8.14.5/Submit) id qAA2Erlw079670; Fri, 9 Nov 2012 18:14:53 -0800 (PST) (envelope-from sgk) Date: Fri, 9 Nov 2012 18:14:53 -0800 From: Steve Kargl To: Dimitry Andric Subject: Re: clang and static linking? Message-ID: <20121110021453.GA79662@troutmask.apl.washington.edu> References: <20121108231349.GA79485@troutmask.apl.washington.edu> <509D4548.7030806@FreeBSD.org> <20121109182810.GA61338@troutmask.apl.washington.edu> <509D5BC3.9020704@FreeBSD.org> <509D90EC.5040302@FreeBSD.org> <509DA0E4.9060906@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <509DA0E4.9060906@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-current@FreeBSD.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Nov 2012 02:14:54 -0000 On Sat, Nov 10, 2012 at 01:33:40AM +0100, Dimitry Andric wrote: > On 2012-11-10 00:25, Dimitry Andric wrote: > ... > > The more difficult way out is to not define any duplicate functions in > > libc.a and libm.a. For the shared libraries, this should not be a > > problem, since the dynamic linker will figure out which of the two > > copies will get precedence. The functions must stay available for > > backwards compatibility reasons anyway. > > > > For static libraries, this compatibility seems to be unnecessary, as > > they will only be used to link new programs. Therefore, it would > > probably be best to remove the whole isnan.o member from libc.a, and > > move all the isnan functions to libm.a instead. > > > > Currently, isnan() is commented out in lib/msun/src/s_isnan.c, maybe we > > can enable it whenever PIC is not defined? Then we could simply skip > > building lib/libc/gen/isnan.c for libc.a. > > More concretely, here is a patch that seems to achieve the above: > - Only define isnan, isnanf, __isnan and __isnanf in libc.so, not in > libc.a and libc_p.a. > - Define isnan in libm.a and libm_p.a, not in libm.so. I don't think > there is a need to define __isnan in the .a files, so I left that out. > Index: lib/libc/gen/isnan.c > =================================================================== > --- lib/libc/gen/isnan.c (revision 242841) > +++ lib/libc/gen/isnan.c (working copy) > @@ -35,6 +35,7 @@ > * binary compat until we can bump libm's major version number. > */ Dimitry, Your patch fixes the initial problem I saw with using gfortran and openmpi. Note, gfortran ignores -fno-builtins and I rarely build C code with -static and -fno-builtins that uses isnan[f]. Unless someone objects, I think your patch is fine. -- Steve