From owner-freebsd-current@FreeBSD.ORG Sat Nov 10 00:33:40 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 05DA2DD2 for ; Sat, 10 Nov 2012 00:33:40 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id B05188FC15 for ; Sat, 10 Nov 2012 00:33:39 +0000 (UTC) Received: from [192.168.0.6] (spaceball.home.andric.com [192.168.0.6]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 015E35C59; Sat, 10 Nov 2012 01:33:38 +0100 (CET) Message-ID: <509DA0E4.9060906@FreeBSD.org> Date: Sat, 10 Nov 2012 01:33:40 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Steve Kargl Subject: Re: clang and static linking? 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> In-Reply-To: <509D90EC.5040302@FreeBSD.org> Content-Type: multipart/mixed; boundary="------------000007060705070806050007" 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 00:33:40 -0000 This is a multi-part message in MIME format. --------------000007060705070806050007 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. --------------000007060705070806050007 Content-Type: text/x-diff; name="static-isnan-in-libm-1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="static-isnan-in-libm-1.diff" 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. */ +#ifdef PIC __weak_reference(__isnan, isnan); __weak_reference(__isnanf, isnanf); @@ -55,3 +56,4 @@ __isnanf(float f) u.f = f; return (u.bits.exp == 255 && u.bits.man != 0); } +#endif /* PIC */ Index: lib/msun/src/s_isnan.c =================================================================== --- lib/msun/src/s_isnan.c (revision 242841) +++ lib/msun/src/s_isnan.c (working copy) @@ -30,8 +30,9 @@ #include "fpmath.h" -/* Provided by libc */ -#if 0 +/* Provided by libc.so */ +#ifndef PIC +#undef isnan int isnan(double d) { @@ -40,7 +41,7 @@ isnan(double d) u.d = d; return (u.bits.exp == 2047 && (u.bits.manl != 0 || u.bits.manh != 0)); } -#endif +#endif /* !PIC */ int __isnanf(float f) --------------000007060705070806050007--