Subject: Re: Why are my Linux binaries so huge?
To: None <tech-pkg@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 03/26/2004 13:21:51
I have researched this more ...

On Wed, 17 Mar 2004, Jeremy C. Reed wrote:

> Using pkgsrc under Linux, the binaries are huge. For example:

> Then stripped:
>
> -rwxr-xr-x    1 root     root       950460 Mar 17 06:28 /usr/bin/openssl
>
> But on a non-pkgsrc system:
>
> -rwxr-xr-x    1 root     root       268168 Sep 30 16:25 /usr/bin/openssl

This is from a Red Hat package:
-rwxr-xr-x    1 root     root       341888 Feb 27  2003 /mnt//usr/bin/openssl

So I use my friend objdump -x, and learn:

 Dynamic Section:
-  NEEDED      libssl.so.4
-  NEEDED      libresolv.so.2
-  NEEDED      libcrypto.so.4
-  NEEDED      libgssapi_krb5.so.2
-  NEEDED      libkrb5.so.3
-  NEEDED      libk5crypto.so.3
-  NEEDED      libcom_err.so.3
+  NEEDED      librsaref.so.3
   NEEDED      libdl.so.2
-  NEEDED      libz.so.1
   NEEDED      libc.so.6

So the pkgsrc-made openssl needs librsaref.so.3 but include all the rest
instead of using shared libraries.

> These files are just too large:

> -rw-r--r--    1 reed     reed     12971896 Mar  6 20:49
> /usr/lib/libdb4-4.2.a

objdump -x tells me there is 313777 .debug_str lines. Is that normal?

So I ran strip on that .a archive file and reduced it down to 7-percent of
the size (959616 bytes).

> I use strip to make smaller; in some cases it is automatic with pkgsrc.

I mentioned in anotheremail it would be good to have an option that did
this for all installed pkgsrc-wide.

> But even when stripped files appear to way larger than on NetBSD or other
> Linux system.)

And that is cuased (as shown with objdump or ldd) that some
libraries/executables include the archives instead of linking with shared
objects.

Another example is libGL.so. On a pkgsrc system, it doesn't use all the
shared libraries, so it is bigger.

 Dynamic Section:
-  NEEDED      libpthread.so.0
-  NEEDED      libXext.so.6
-  NEEDED      libX11.so.6
-  NEEDED      libdl.so.2
   NEEDED      libc.so.6


I think it would be good to get these things fixed to be consistent with
what seems to be normal. NetBSD's native libGL uses shared libraries for
libX11 and libXext.

Another example is strings(1) comparing NetBSD's base version with package
version:

rainier:/usr/pkgsrc/security/openssl$ ls -l /usr/bin/strings
/usr/pkg/bin/strings
-r-xr-xr-x  1 root  wheel   19616 Nov 28 03:43 /usr/bin/strings
-r-xr-xr-x  1 root  wheel  362604 May 16  2002 /usr/pkg/bin/strings

rainier:/usr/pkgsrc/security/openssl$ ldd /usr/bin/strings
/usr/pkg/bin/strings
/usr/bin/strings:
         -lintl.0 => /usr/lib/libintl.so.0
         -lbfd.4 => /usr/lib/libbfd.so.4
         -lc.12 => /usr/lib/libc.so.12
/usr/pkg/bin/strings:
         -lc.12 => /usr/lib/libc.so.12


Is this a libtool issue that can be tweaked to help with many package
builds?

   Jeremy C. Reed
   http://www.reedmedia.net/