home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!cam-cl!cam-cl!os102
- From: os102@cl.cam.ac.uk (Oliver Stephens)
- Newsgroups: comp.lang.modula3
- Subject: Shared Libraries under SunOS
- Message-ID: <1992Jul21.151044.4471@cl.cam.ac.uk>
- Date: 21 Jul 92 15:10:44 GMT
- Sender: news@cl.cam.ac.uk (The news facility)
- Reply-To: oliver.stephens@computer-lab.cambridge.ac.uk
- Organization: Computer Lab, University of Cambridge, UK
- Lines: 81
-
- More stuff on shared libraries under SunOS :
-
- 1. You don't need the contents of lib<name>.a if you have lib<name>.so.*
- as programs are never linked with -Bstatic (at least I cannot think of
- any reason why they should). You do, however, need a file of that name
- for the driver to work correctly, so you can replace it with a zero-length
- file to save more disc space
-
- 2. Below are some m3make templates for creating shared libraries
- automatically. They give you two new directives :
-
- sharedLibrary(name) - equivalent of library(name)
- SharedLibrary(name) - equivalent of Library(name)
-
- There are three (at least) minor gotchas :
-
- A. If you have a lib<name>.a but no lib<name>.so.* then the driver
- won't bother to rebuild : solution - remove lib<name>.a
-
- B. If the link fails (usually because some of the source files have
- not been compiled with a shared library target in mind) then the
- driver ignores it - this is because I replace the archive pass of
- the driver with a link pass, but the driver ignores the exit status
- of this pass : solution - remove all object files [m3make clean]
- before starting a shared library build
-
- C. If an installed lib<name>.a already exists (from a previous ordinary
- library build) then it will not change to zero-length when you
- install the shared library - this is because I use 'touch' to create
- the file : solution - change it to a zero-length file by hand or
- delete it first (if you want the extra disk space)
-
- ---+--- The following should go in your $(LIB_USE)/toplevel.tmpl file ---+---
-
- #ifdef TARGET_SPARC
-
- #define sharedLibrary(name) @@\
- all:: lib##name.a @@\
- clean:: ; rm -f lib##name.a lib##name.ax lib##name.so.1.1 @@\
- lib##name.a: FRC; $(DO_M3) -X1@-PIC@ -Y3@$(LIB_USE)/ld-so@ -Y4@touch@ \
- -a lib##name.a $(PGM_SOURCES) $(IMPORT_LIBS)
-
- #define SharedLibrary(name) @@\
- install:: @@\
- INSTALL (lib##name.so.1.1, $(LIB_INSTALL), 755) @@\
- INSTALL (lib##name.ax, $(LIB_INSTALL), 644) @@\
- touch $(LIB_INSTALL)/lib##name.a @@\
- sharedLibrary(name)
-
- #else
-
- #define sharedLibrary(name) library(name)
- #define SharedLibrary(name) Library(name)
-
- #endif
-
- ---+--- And the following shell script should go in $(LIB_USE)/ld-so ---+---
-
- #!/bin/csh -f
- #
- # ld-so : shared library linker for m3
- #
- # (just a simple shell around /bin/ld which changes the arguments
- # so that shared libraries can be created - needed because I don't
- # have enough control over the commands the m3 driver issues)
- #
- # Olly Stephens (os102@cl.cam.ac.uk) - 20/7/92
- #
-
- set argv[1]=-o # change 'cru' to '-o'
- set argv[2]=$2:r.so.1.1 # change <lib>.a to <lib>.so.1.1
-
- /bin/ld -assert pure-text $*
-
- ---+---
-
- -------------------------------------------------------------------------
- Olly Stephens oliver.stephens@cl.cam.ac.uk
- Computer Laboratory
- University of Cambridge Loved you there and then, and now like a sheep
- United Kingdom - Van Morrison
-