[lfs-dev] More on static libs

Bruce Dubbs bruce.dubbs at gmail.com
Thu Mar 12 18:04:37 PDT 2015

Bruce Dubbs wrote:
> Ken Moffat wrote:
>> On Thu, Mar 12, 2015 at 05:32:21PM -0500, Bruce Dubbs wrote:
>>> There are lots of ways to make mistakes, but I can't really see how someone
>>> can link a static library into one of the LFS packages without really going
>>> far from the book and changing a Makefile or similar.  I suppose removing a
>>> .so file may revert back to the complementary .a file.
>> Long while since I've managed it (on x86_64, which is where all my
>> development used to happen, most static libs lack -fPIC so they will
>> not link into a shared lib).  But on i686: in one case (bzip2) I
>> missed the solib version change when I was making the symlink, which
>> effectively matches your suggestion.  Before that, I had screwed up
>> a symlink with one of the files we moved into /lib - that is the more
>> general sort of error, and I'm fairly sure that I later saw someone
>> reporting what turned out to be the same problem on support.
>> Also, making static libs unavailable even on i686 guards against a
>> future change accidentally pulling one in.
> So you are suggesting that we move all /usr/lib/*.a files at the end of each
> package?


$ cat /usr/lib/libc.so
/* GNU ld script
    Use the shared library, but some functions are only in
    the static library, so try that secondarily.  */
GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a  AS_NEEDED ( 
/lib64/ld-linux-x86-64.so.2 ) )

So  libc_nonshared.a is *really* needed.

On 686:

GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux.so.2 ) )

   -- Bruce

More information about the lfs-dev mailing list