*BSD News Article 9012


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!uunet!charon.amdahl.com!amdahl!JUTS!griffin!gab10
From: gab10@griffincd.amdahl.com (Gary A Browning)
Newsgroups: comp.unix.bsd
Subject: Re: Questions on Joerg Shared lib
Message-ID: <64yK023u2exT01@JUTS.ccc.amdahl.com>
Date: 10 Dec 92 05:05:15 GMT
References: <1992Dec2.043206.23671@ntuix.ntu.ac.sg> <1992Dec9.172904.13771@fcom.cc.utah.edu>
Sender: netnews@ccc.amdahl.com
Organization: Amdahl Corporation
Lines: 91

In article <1992Dec9.172904.13771@fcom.cc.utah.edu>, terry@cs.weber.edu
(A Wizard of Earth C) writes:
> In article <1992Dec2.043206.23671@ntuix.ntu.ac.sg>
> othman@ntrc25.ntrc.ntu.ac.sg (othman (EEE/Div 4)) writes:

> >1) What are the limitations of this shared lib, apart from having to convert
> >the current libs.

[ deleted ]
 
 vi) I think you cannot currently make a module into a shared lib if it
     has global data that is referenced outside of the library.  This
     was the reason for the getopt patch.  It's not too serious. Getopt
     is effectively just always statically linked.
 
> >2) How does the conversion work? Do we have to recompile all the libs? From
> >the first analysis of the Makefiles, it appears as though it does not
> have to?
> 
> i)	Re-make all libs.  Recompile all apps using the "shared" libs.

You do not need to recompile *all* applications.  However, there is going
to be a threshhold of memory usage where if one has lots of statically
linked programs and a few dynamically ones to the same libraries, the
memory usage would be higher than having all of them statically linked.

You can also choose not to use a shared library.
Recognizing that this is a stop gap shared library implementation, I was
thinking of three possible senarios:
  (1) Not use the shared library version of libc for any compiles but
      create and use the X11 shared libraries for ALL of the X
      applications.  This should save quite a bit of memory and disk
      space.
  (2) Same as above but use the libc shared libraries for programs that
      are *not* part of the 0.1 distribution.  This senario may waste
      more memory than is gains.
  (3) Same as (2) above but use the libc shared libs for 0.1 programs.
      There may be some system programs that I will need statically
      linked.  This senario probably saves the most memory but I can no
      longer report bugs unless I can prove that they are not related
      to the shared library implementation.  The best way to prove this
      is to run with the statically linked versions of the system.
      I don't think I want to do this one.  I just do not see much
      memory benefit for the cost.

> 
> ii)	Well, type "make" anyway.  This will probably result in the object
> 	files being regenerated.  I suppose you could make existing
> 	libraries into "shared" libraries with a bit of conniving, but the
> 	time spent would probably exceed recompilation time.

No it does not recompile the libraries.  It does link the modules in the
lib*.a file into a single text segment at the fixed address though.  And
it also builds and compiles stub routines from the definitions in the
lib*.a file.  Pretty slick really.

[ deleted ]

> >4) Is the patches to gcc and g++ really necessary? We can use command line
> >options to select alternative crt and libc, can't we?
> 
> i)	Technically, no.
> ii)	Technically, yes, but any unresolved symbols will result in the
> 	standard default libraries being dragged in.  This prevents that.
> 	There is also an implicit assumption that you want shared libs
> 	to be the default.  I assume that this is why the patches are
> 	done.  Besides, the options are a bit large to remember so that
> 	you ling against the symbol table as opposed to the shared objects.

I do not understand the comment but here is what I know about gcc.
The patches add a single line to the parser string that recognizes
'-static' and alters the crt0.o (sp?) preamble file and libc_s.a (sp?)
to be the original, non-shared ones instead of the now default shared
library support ones.  I do not like this implementation - I would rather
that the default be '-static' and the option be '-dynamic'.  This way
I have to make changes to the Makefile of only the programs that I want
to use shared libraries.   I wish there was a way to set an environment
variable instead of altering makefiles. 

Also, I am not sure yet how to get the shared lib version of crt0 and
the static verions of libc (a quick guess would be gcc *.o -lc but I need
to test it first).

Note that *all* shared libraries other than libc must be explicitly
requested in the '-l' flags (-lX11 becomes something like -lX11_s).

[ deleted ]
-- 
Gary Browning        | Exhilaration is that feeling you get just after a
		     | great idea hits you, and just before you realize
                     | what is wrong with it.