From xemacs-m  Sat May 24 09:28:23 1997
Received: from mercury.Sun.COM (mercury.Sun.COM [192.9.25.1])
	by xemacs.org (8.8.5/8.8.5) with SMTP id JAA20206
	for <xemacs-beta@xemacs.org>; Sat, 24 May 1997 09:28:22 -0500 (CDT)
Received: from Eng.Sun.COM ([129.146.1.25]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id BAA08753 for <xemacs-beta@xemacs.org>; Sat, 24 May 1997 01:12:32 -0700
Received: from kindra.eng.sun.com by Eng.Sun.COM (SMI-8.6/SMI-5.3)
	id AAA19841; Sat, 24 May 1997 00:56:23 -0700
Received: from xemacs.eng.sun.com by kindra.eng.sun.com (SMI-8.6/SMI-SVR4)
	id AAA19337; Sat, 24 May 1997 00:56:20 -0700
Received: by xemacs.eng.sun.com (SMI-8.6/SMI-SVR4)
	id AAA26989; Sat, 24 May 1997 00:56:23 -0700
Date: Sat, 24 May 1997 00:56:23 -0700
Message-Id: <199705240756.AAA26989@xemacs.eng.sun.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
From: Martin Buchholz <mrb@Eng.Sun.COM>
To: georgn@canada.Sun.COM
Cc: XEmacs Developers <xemacs-beta@xemacs.org>, georg.nikodym@canada.Sun.COM
Subject: Re: b1 success
In-Reply-To: <199705232256.SAA01572@verve.canada.sun.com>
References: <199705191905.PAA19737@verve.canada.sun.com>
	<199705200034.RAA12761@xemacs.eng.sun.com>
	<199705211433.KAA17537@verve.canada.sun.com>
	<199705220251.TAA16746@xemacs.eng.sun.com>
	<199705232256.SAA01572@verve.canada.sun.com>
X-Mailer: VM 6.31 under 20.3 XEmacs Lucid (beta1)
Reply-To: Martin Buchholz <mrb@Eng.Sun.COM>

>>>>> "Georg" == Georg Nikodym <georgn@canada> writes:

>>>>> "MB" == Martin Buchholz <mrb@Eng> writes:
MB> Shouldn't the linker take care of making the overhead be
MB> link-time only?  If I link with a library and use none of its
MB> symbols, should the resulting binary even have a reference to
MB> that useless library?

Georg> This is only true in the case of static linking where the linker is
Georg> responsible for COPYING .o's it extracts from .a's into the output
Georg> binary.

Georg> In dynamic linking (of an app), all that needs to happen is a check
Georg> that all the dependencies are met by the collection of shared objects
Georg> supplied as arguments to the link editor.  Remember, in dynamic linked 
Georg> apps the shared objects are mapped into the apps address space, there
Georg> is no dismembering going on.

I still think the linker could be smart enough to make the extra libs
on the ld command inexpensive.

However, in the real world, it's irrelevant - we have to deal with
real linkers.  I agree that minimizing the library list is a
worthwhile goal.  For libraries that only the xemacs binary needs, and 
that no other library depends on, it should be fairly easy to implement.

But trying to create a minimal set of libraries for the link of each
binary is going to be difficult to maintain.  As an example, on most
systems Motif support requires only Xt and Xlib as additional
libraries, while on some it requires Xpm as well.  Meanwhile, both Xm
and Xpm are optional.  We would have to be very careful indeed to
autodetect this situation.

Georg> Consider the classic hello world program.  It has, as far as the coder
Georg> is concerned one dependency, printf().  C on UNIX semantics supply an
Georg> implied dependency on exit(), which in turn depends on atexit() and
Georg> _exit().  Total four direct dependencies.  When built on Solaris, the
Georg> classic program ends up with 21 dependencies in total.  The additional 
Georg> 17 symbols come from the guts of printf() and friends (libc depending
Georg> on libc).

Georg> However, add "-lX11 -lXm -lm -lelf -ldl" to the compile line of
Georg> hello world and things change radically.  ldd shows:

Georg> 	libX11.so.4 =>	 /usr/lib/libX11.so.4
Georg> 	libXm.so.3 =>	 /usr/lib/libXm.so.3
Georg> 	libm.so.1 =>	 /usr/lib/libm.so.1
Georg> 	libelf.so.1 =>	 /usr/lib/libelf.so.1
Georg> 	libdl.so.1 =>	 /usr/lib/libdl.so.1
Georg> 	libc.so.1 =>	 /usr/lib/libc.so.1
Georg> 	libXext.so.0 =>	 /usr/openwin/lib/libXext.so.0
Georg> 	libsocket.so.1 =>	 /usr/lib/libsocket.so.1
Georg> 	libnsl.so.1 =>	 /usr/lib/libnsl.so.1
Georg> 	libXt.so.4 =>	 /usr/openwin/lib/libXt.so.4
Georg> 	libmp.so.2 =>	 /usr/lib/libmp.so.2
Georg> 	libSM.so.6 =>	 /usr/openwin/lib/libSM.so.6
Georg> 	libICE.so.6 =>	 /usr/openwin/lib/libICE.so.6

Georg> The total number of direct dependencies remains four (obviously) but
Georg> the total number of symbol dependencies leaps to 2965.

Martin

