[m-dev.] diff: FreeBSD & shared libraries

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Jun 21 17:45:13 AEST 1999


Estimated hours taken: 1

scripts/ml.in:
	Make static linking the default on FreeBSD,
	since shared linking doesn't work.

README.FreeBSD:
	Document that shared libraries are not supported on FreeBSD.
	Add some hints about what would need to be done to make them work.

Workspace: /home/mercury0/fjh/mercury
Index: README.FreeBSD
===================================================================
RCS file: README.FreeBSD
diff -N README.FreeBSD
--- /dev/null	Mon Jun 21 17:34:44 1999
+++ README.FreeBSD	Mon Jun 21 17:41:13 1999
@@ -0,0 +1,56 @@
+For FreeBSD, the Boehm conservative garbage collector does not yet support
+shared libraries.  So Mercury does not yet support shared libraries on FreeBSD,
+except in the (not very useful) case where you compile with GC disabled,
+e.g. using the option `--gc none'.
+
+The rest of this file contains some hints for eager FreeBSD hackers
+about what would need to be done to make the Boehm collector support
+shared libraries on FreeBSD.
+
+--------------------
+
+The basic problem is that on FreeBSD the conservative collector does not
+scan the memory regions that contain global variables from dynamically linked
+shared object files.
+
+First, check the `recent_changes' file at
+<http://reality.sgi.com/boehm/gc_source/> to see if someone else
+has already solved the problem.
+
+In order to support dynamic linking, I think you need to implement the
+GC_register_dynamic_libraries() function in boehm_gc/dyn_load.c.
+This function needs to call
+	GC_add_root(low_address, high_plus_one_address, TRUE)
+for every memory region in dynamically loaded code that needs to be
+scanned by the collector, so that the collector can scan global
+variables defined in shared libraries.
+
+If FreeBSD uses ELF and supports ELF in exactly the same way that Linux
+does, then you could try the following patch, which just enables the Linux
+code in the FreeBSD case.  But most likely there are some differences
+between FreeBSD and Linux in this respect, so this will probably not work
+as is -- you should consider this just a starting point.
+
+Read the comments at the top of dyn_load.c for more details.
+
+--- dyn_load.c	Mon Aug 31 15:05:05 1998
++++ dyn_load.c.new	Wed Jun 16 22:58:48 1999
+@@ -260,7 +260,7 @@
+ # endif /* !USE_PROC ... */
+ # endif /* SUNOS */
+ 
+-#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF)
++#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || defined(FREEBSD)
+ 
+ /* Dynamic loading code for Linux running ELF. Somewhat tested on
+  * Linux/x86, untested but hopefully should work on Linux/Alpha. 
+--- config.h	Wed Oct 28 10:16:49 1998
++++ config.h.new	Wed Jun 16 23:08:56 1999
+@@ -699,6 +699,7 @@
+ #   ifdef FREEBSD
+ #	define OS_TYPE "FREEBSD"
+ #	define MPROTECT_VDB
++#	define DYNAMIC_LOADING
+ #   endif
+ #   ifdef NETBSD
+ #	define OS_TYPE "NETBSD"
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.62
diff -u -r1.62 ml.in
--- ml.in	1999/06/01 09:46:19	1.62
+++ ml.in	1999/06/21 07:24:24
@@ -282,9 +282,10 @@
 # it will also have set mercury_libs.
 case $mercury_libs in default)
 	mercury_libs=shared
-	case $FULLARCH in i?86-*-linux*)
+	case $FULLARCH in i?86-*-linux*|i?86-*-freebsd*)
 		# shared libraries are not the default on Linux
 		# -- see README.Linux
+		# Likewise for FreeBSD
 		case $make_shared_lib in false)
 			mercury_libs=static
 			;;
@@ -298,9 +299,10 @@
 # (shared on most systems).
 case $all_libs in default)
 	all_libs=shared
-	case $FULLARCH in i?86-*-linux*)
+	case $FULLARCH in i?86-*-linux*|i?86-*-freebsd*)
 		# shared libraries are not the default on Linux
 		# -- see README.Linux
+		# Likewise for FreeBSD
 		case $make_shared_lib in false)
 			all_libs=static
 			;;

-- 
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.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list