From owner-freebsd-current Mon May 13 10:49:59 2002 Delivered-To: freebsd-current@freebsd.org Received: from snipe.prod.itd.earthlink.net (snipe.mail.pas.earthlink.net [207.217.120.62]) by hub.freebsd.org (Postfix) with ESMTP id DA04937B406 for ; Mon, 13 May 2002 10:49:53 -0700 (PDT) Received: from pool0153.cvx40-bradley.dialup.earthlink.net ([216.244.42.153] helo=mindspring.com) by snipe.prod.itd.earthlink.net with esmtp (Exim 3.33 #2) id 177Jx4-0003t9-00; Mon, 13 May 2002 10:49:39 -0700 Message-ID: <3CDFFC75.381001CB@mindspring.com> Date: Mon, 13 May 2002 10:48:37 -0700 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Mikhail Teterin Cc: Marcel Moolenaar , current@FreeBSD.ORG Subject: Re: does the order of .a files matter? References: <200205101233.g4ACXctb041093@corbulon.video-collage.com> <20020512220007.GA21019@dhcp01.pn.xcllnt.net> <3CDF57EF.443F3BE7@mindspring.com> <200205131052.36927.mi+mx@aldan.algebra.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Mikhail Teterin wrote: > = I explain the lexical ordering by way of the following commands when > = exiting the Makefile in "vi" in command mode: > = > = !!ls *.c > = JJJJJJJJJJJJJJJJJ[...] > = ISRCS= > = > = 8-). > > This does not explain anything. Whatever the joke was, I did not get it. These are the commands you give the editor to take the output of "ls *.c", and put all the files on a single line: SRCS=aardvark.c bear.c cat.c dog.c elephant.c ... In other words, the lexical ordering comes from the fact that the output of the "ls" command is sorted alphabetically. > The question stands -- why can the object files be given to the linker > in arbitrary order, Because .o files are object files which it is mandatory to include in the final executable. > but the the static libraries must be carefully ordered -- possibly > even listed multiple times! Because .a files are archives containing lists of object files which it is *optional* to include in the final executable. > There is nothing > apparent in the .a format, that forces such behaviour. Uh... .a files are archives containing lists of object files which it is *optional* to include in the final executable. > All of our Makefiles list objects in the alphabetical order -- why > not sort them once with lorder/tsort and skip the lorder/tsort step > from the library build (in bsd.lib.mk)? That would also speed up > world-building... Because programmers are intrinsically lazy, and write Makefile's last? Also, the speedup is really questionable. The dependency graph is going to be created as if the symbol satisfaction order were random anyway. And, in fact, unless you put one function per object file, you really can't guarantee that tsort will minimize the sorting necessary. You are assuming -- perhaps incorectly -- that the functions were broken up between source files in tsort order. > = Linking fewer object files into an executable makes the executable > = smaller. Smaller executables are better than larger executables from a > = putatively "smarter" linker (personally, I measure linker intelligence > = as inversely proportional to the resulting executable size, relative > = to the idealized executable size). > > Terry, NONE of this is relevant to the subject. Nobody is criticizing > our linker for not putting UNNEEDED objects into the executables. The > gaping hole in the linker, that is the subject of this thread, is the > linker's inability to find NEEDED objects, which are right in front of > its nose. We apparently differ on our definitions of "right in front of its nose". Also... it's not "our linker", it is "FSF's linker". See also the "info ld"; if you wanted an implicit "--start-group" at the start of all object lists, and an implicit "--end-group" at the end, then you could hack it to support it. But, I would not want it in my local FreeBSD; from the documentation: Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives. > = I had a big gripe, complete with examples involving famous names, > = ready to go. But I will replace it with a much smaller response: > = > = "A craftsman must know his tools". > > And always seek to improve them. Or invent new ones, leaving the old ones intact. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message