clang and static linking?

Dimitry Andric dim at FreeBSD.org
Sat Nov 10 00:33:40 UTC 2012


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: static-isnan-in-libm-1.diff
Type: text/x-diff
Size: 988 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20121110/b3e17be0/attachment.diff>


More information about the freebsd-current mailing list