[patch] build shared libraries

Bernhard Fischer rep.nop at aon.at
Mon Sep 5 12:29:22 UTC 2005


On Mon, Sep 05, 2005 at 01:54:23PM +0200, Peter S. Mazinger wrote:
>On Mon, 5 Sep 2005, Bernhard Fischer wrote:
>
>> Hi,
>> 
>> Attached patch adds CONFIG_BUILD_LIBRARIES.
>
>haven't tested it, only looked at the patch:
>1. for shared libs the objects should all be built PIC (use -fPIC instead 
>of -fpic -commented currently-, -fpic is probably meaningful only on ppc)

Right. That would need changing.

>2. use -Wl,-z,defs when linking the libs, to assure that everything is 
>defined

Ok.

>3. soname is only meaningful if the libs have versioning, like
>libb-1.0.1.so, soname could be libb.so.1 (some would use as libname 
>libbb.so.1.0.1 and soname libbb.so.1), versioning would help if
>external apps are built against these libs and/or if ABI changes.

Currently, even svn-HEAD has version 1.00.
I'm aware that the API versioning might need a little touch up before
soname is useful.
>
>> 
>> If set, lib*.a will be also build as shared libraries:
>> ./libbb/libbb.so
>> ./libpwdgrp/libpwdgrp.so
>> ./archival/libunarchive/libunarchive.so
>> ./networking/libiproute/libiproute.so
>> ./coreutils/libcoreutils/libcoreutils.so
[snip]
>> This patch is ment as an RFC. It worked flawlessly in my cursory
>> testing so far.
>> Comments?
>> 
>> 
>> 
>> 1)
>> # ldd bin/busybox
>> 	libunarchive.so => /lib/libunarchive.so (0x40018000)
>> 	libiproute.so => /lib/libiproute.so (0x400e2000)
>> 	libpwdgrp.so => /lib/libpwdgrp.so (0x400f0000)
>> 	libcoreutils.so => /lib/libcoreutils.so (0x400f3000)
>> 	libbb.so => /lib/libbb.so (0x400f5000)
>> 	libdl.so.2 => /lib/tls/libdl.so.2 (0x40105000)
>> 	libm.so.6 => /lib/tls/libm.so.6 (0x40108000)
>> 	libcrypt.so.1 => /lib/tls/libcrypt.so.1 (0x4012b000)
>> 	libc.so.6 => /lib/tls/libc.so.6 (0x40158000)
>> 	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
>> # ls -l bin/busybox
>> -rwxr-xr-x    1 0      0        739044 Sep  5 09:38 bin/busybox
>
>I would be interested how big the libs are?

above example stems from make allyesconfig. Abovementioned libs are:
# ls -l lib*.{a,so}  
-rw-r--r--    1 0        0          190574 Sep  5 09:38 libbb.a
-rw-r--r--    1 0        0           89519 Sep  5 09:38 libbb.so
-rw-r--r--    1 0        0            3472 Sep  5 09:38 libcoreutils.a
-rw-r--r--    1 0        0            7517 Sep  5 09:38 libcoreutils.so
-rw-r--r--    1 0        0           71540 Sep  5 09:38 libiproute.a
-rw-r--r--    1 0        0           66018 Sep  5 09:38 libiproute.so
-rw-r--r--    1 0        0           36054 Sep  5 09:38 libpwdgrp.a
-rw-r--r--    1 0        0           16606 Sep  5 09:38 libpwdgrp.so
-rw-r--r--    1 0        0           50550 Sep  5 09:38 libunarchive.a
-rw-r--r--    1 0        0           36254 Sep  5 09:38 libunarchive.so

Note that all of them are not stripped and not built with PIC (which
iirc adds a bit to the size).
# strip -s -R .debug -R .notes -R .comment -R .version libbb.so
# ls -l libbb.so
-rw-r--r--  1 0 0 63364 Sep  5 14:21 libbb.so

>> 
>> Annotations:
>> a) There are two files in libbb which use libcrypt: correct_password.c
>> and pw_encrypt.c. Because of this libbb.so itself has to link against
>> libcrypt. Is this intended, given that there is libpwdgrp?
>
>as I understand it, busybox used the version provided by *libc, libpwdgrp 
>is meant for systems lacking libcrypt

I have not looked too closely, but i was under the impression that the
libpwdgrp was linked in unconditionally as it provides the helpers for
loginutils. If you are right, then we should provide an option to let
the user select if libpwdgrp is to be built and linked in or not.
>
>Peter

Thanks for your suggestion.




More information about the busybox mailing list