linux shared libraries
Fergus Henderson
fjh at cs.mu.oz.au
Sun Feb 9 17:06:24 AEDT 1997
Hi Tyson,
Here's the final diff in that batch of changes for Linux ELF support.
I've committed this.
The only thing left (presuming this works OK, of course) is that it
would be nice to change things so that using shared libraries is the
default.
--------------------
Finish off the stuff needed to support ELF shared libraries on Linux.
mercury/NEWS:
Mention that we now support ELF shared libraries on Linux.
mercury/README.Linux:
Document the use of shared libraries on Linux.
mercury/configure.in:
Enable the use of shared libraries on Linux.
Add some documentation regarding the use of position-independent
code on Solaris.
For systems that don't support shared libraries, set
CFLAGS_FOR_PIC to empty, not `-fpic'. (Previously
CFLAGS_FOR_PIC wasn't used on such systems, but now it
is used when creating boehm_gc/libgc.a.)
cvs diff: Diffing .
Index: NEWS
===================================================================
RCS file: /home/staff/zs/imp/mercury/NEWS,v
retrieving revision 1.41
diff -u -r1.41 NEWS
--- NEWS 1997/01/25 11:42:58 1.41
+++ NEWS 1997/02/09 02:59:37
@@ -67,6 +67,14 @@
speed up code that does a lot of memory allocation by inlining the
GC_malloc() function. (This option is also enabled by `-O6'.)
+* We now support ELF shared libraries on Linux.
+
+ See README.Linux for details.
+
+ Note that using shared libraries is not yet the default,
+ so if you want to take advantage of this, you must explicitly
+ enable it as described in README.Linux.
+
* We have fixed quite a few bugs.
Mode inference now works a little bit better.
cvs diff: README.Linux is a new entry, no comparison available
Index: configure.in
===================================================================
RCS file: /home/staff/zs/imp/mercury/configure.in,v
retrieving revision 1.80
diff -u -r1.80 configure.in
--- configure.in 1997/02/08 19:14:09 1.80
+++ configure.in 1997/02/09 05:55:35
@@ -1039,7 +1039,11 @@
EXT_FOR_SHARED_LIB=a
case "$host" in
- i386-*-freebsd*)
+ i?86-*-linux)
+ AC_MSG_RESULT(yes)
+ EXT_FOR_SHARED_LIB=so
+ ;;
+ i?86-*-freebsd*)
# From Cornelis van der Laan <nils at ims.uni-stuttgart.de>
AC_MSG_RESULT(yes)
LINK_SHARED_OBJ="ld -Bshareable"
@@ -1048,12 +1052,36 @@
sparc-sun-solaris2.*)
AC_MSG_RESULT(yes)
SHARED_LIBS="-lm -lc" # don't link in libgcc.a
- # for some reason, using -fpic doesn't seem to work on
- # Solaris - probably because of problems with the global
- # pointer register
LINK_SHARED_OBJ="$CC -G"
- CFLAGS_FOR_PIC=
+ CFLAGS_FOR_PIC=-fpic -DPIC # used only for libgc.{a,so}
EXT_FOR_PIC_OBJECTS=o
+ #
+ # Note that despite the above definition of CFLAGS_FOR_PIC,
+ # we don't use `-fpic' for shared libraries on Solaris
+ # (the definition of EXT_FOR_PIC_OBJECTS=o means that
+ # CFLAGS_FOR_PIC will be used only for building libgc.a
+ # and libgc.so.)
+ #
+ # The reason for this is that shared libraries work without
+ # it (well, at least they are shared on disk -- although the
+ # code is not shared at runtime), and using `-fpic' would
+ # reduce efficiency.
+ #
+ # It works because the Solaris dynamic linker will
+ # actually do the fixups at runtime for non-PIC code.
+ # (The code is mapped copy-on-write, and when the linker
+ # does the fixups, it gets copied. Hence the lack of
+ # runtime sharing.) We need to link with `gcc -G'
+ # rather than `gcc -shared', because `gcc -shared'
+ # reports an error if any runtime fixups would be needed.
+ #
+ # If you *do* use `-fpic', you must also use `-DPIC'.
+ #
+ # See runtime/goto.h for the code that handles PIC on SPARCs.
+ # Note that mixing PIC and non-PIC code is fine on SPARCs
+ # (though it doesn't work on x86s, due to the use of `ebx'
+ # in runtime/machdeps/i386_regs.h).
+
EXT_FOR_SHARED_LIB=so
;;
alpha-dec-osf*)
@@ -1082,6 +1110,10 @@
fi
;;
*)
+ # CFLAGS_FOR_PIC is used by boehm_gc/Makefile when creating
+ # libgc.a. If the system doesn't support shared libraries,
+ # then we should set it to empty, not `-fpic'.
+ CFLAGS_FOR_PIC=
AC_MSG_RESULT(no)
;;
esac
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list