[Gc] [RFC] patch, MPROTECT_VDB support for Darwin

Andreas Tobler toa at pop.agri.ch
Tue Feb 6 12:18:36 PST 2007


Hi,

this patch was a bit expensive until I found out what the reason for the 
failure could have been. Anyway, in comparison to the duration of the 
lifetime of this problem it was a short time I needed to find it out ;)

Here you see the problem:

http://permalink.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/848


Well, the exact reason I still don't understand fully. But I think it 
has to do with the fact that ld builds multi-modules by default which 
can not have common symbols. To achieve common symbols we pass 
-single_module to the linker.

See here for an explanation about:

http://developer.apple.com/documentation/DeveloperTools/Conceptual/MachOTopics/index.html

under Executing Mach-O Files. (Search for common symbols)

I hope I got it right somehow.

I tested the patch under ppc32 Darwin, i686 and x86_64 Darwin. I also 
tested it under ppc64 Darwin but here I have no luck atm since I'm stuck 
with something else. I get nasty Bus Errors which I can not isolate.

Here a big thanks go to Brad Lucier who gave me access to a dual G5. 
Thanks Brad, I really appreciate.

The second part of the patch is the preparation for ppc64 support for 
Darwin. Here I pass 3 of 4 tests right now.

Maybe an experienced thread degugger who owns a G5 can enter the game 
and help me to track this issue.

Hans, the introduction of the gc_ldflags, is this the right way to do 
it? I followed the instructions to add target specific issues there.
But I did not find another possibility as to add it this way. Well, I 
could have added it to the configure.ac only but then ....

I welcome comments!

Thanks

Andreas


2007-02-06  Andreas Tobler  <a.tobler at schweiz.org>

	* configure.host (gc_ldflags): Introduce new gc_ldflags. Use it for
	Darwin to pass -Wl,-single_module to the linker.
	* configure.ac: Substitue the new GC_LDFLAGS.
	* configure: Regenerate.
	* Makefile.am (libgc_la_LDFLAGS): Use the GC_LDFLAGS.
	* Makefile.in: Regenerate.
	* include/private/gcconfig.h: Enable MPROTECT_VDB for all Darwin
	targets. Remove comments.
	Prepare ppc64 support for Darwin.
-------------- next part --------------
Index: configure.host
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/configure.host,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 configure.host
--- configure.host	10 Oct 2005 22:33:34 -0000	1.1.1.1
+++ configure.host	6 Feb 2007 19:49:52 -0000
@@ -18,8 +18,10 @@
 
 # It sets the following shell variables:
 #   gc_cflags	Special CFLAGS to use when building
+#   gc_ldflags  Special LDFLAGS to use when linking libgc.so|dylib|dll|sl
 
 gc_cflags=""
+gc_ldflags=""
 
 # We should set -fexceptions if we are using gcc and might be used
 # inside something like gcj.  This is the zeroth approximation:
@@ -56,6 +58,9 @@
   mips-tx39-*|mipstx39-unknown-*)
 	gc_cflags="${gc_cflags} -G 0"
 	;;
+  *-*-darwin*)
+	gc_ldflags="${gc_ldflags} -Wl,-single_module"
+	;;
   *)
 	;;
 esac
Index: configure.ac
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/configure.ac,v
retrieving revision 1.20
diff -u -r1.20 configure.ac
--- configure.ac	25 Jan 2007 23:43:10 -0000	1.20
+++ configure.ac	6 Feb 2007 19:49:55 -0000
@@ -43,7 +43,9 @@
 . ${srcdir}/configure.host
 
 GC_CFLAGS=${gc_cflags}
+GC_LDFLAGS=${gc_ldflags}
 AC_SUBST(GC_CFLAGS)
+AC_SUBST(GC_LDFLAGS)
 
 AC_ARG_ENABLE(threads,
   [AC_HELP_STRING([--enable-threads=TYPE], [choose threading package])],
Index: Makefile.am
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/Makefile.am,v
retrieving revision 1.8
diff -u -r1.8 Makefile.am
--- Makefile.am	7 Jul 2006 21:10:07 -0000	1.8
+++ Makefile.am	6 Feb 2007 19:49:55 -0000
@@ -91,7 +91,7 @@
 # linuxthread semaphore functions get linked:
 libgc_la_LIBADD = @addobjs@ $(THREADDLLIBS) $(UNWINDLIBS)
 libgc_la_DEPENDENCIES = @addobjs@
-libgc_la_LDFLAGS = -version-info 1:2:0
+libgc_la_LDFLAGS = @GC_LDFLAGS@ -version-info 1:2:0
 
 EXTRA_libgc_la_SOURCES = alpha_mach_dep.S \
     mips_sgi_mach_dep.s mips_ultrix_mach_dep.s \
Index: include/private/gcconfig.h
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/include/private/gcconfig.h,v
retrieving revision 1.22
diff -u -r1.22 gcconfig.h
--- include/private/gcconfig.h	11 Jan 2007 19:32:44 -0000	1.22
+++ include/private/gcconfig.h	6 Feb 2007 19:50:10 -0000
@@ -748,25 +748,28 @@
 #     define DATAEND (_end)
 #   endif
 #   ifdef DARWIN
+#     define OS_TYPE "DARWIN"
+#     define DYNAMIC_LOADING
 #     if defined(__ppc64__)
 #       define ALIGNMENT 8
 #       define CPP_WORDSZ 64
+#       define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
+#       define CACHE_LINE_SIZE 64
+#       ifndef HBLKSIZE
+#         define HBLKSIZE 4096
+#       endif
 #     else
 #       define ALIGNMENT 4
+#       define STACKBOTTOM ((ptr_t) 0xc0000000)
 #     endif
-#     define OS_TYPE "DARWIN"
-#     define DYNAMIC_LOADING
       /* XXX: see get_end(3), get_etext() and get_end() should not be used.
 	 These aren't used when dyld support is enabled (it is by default) */
 #     define DATASTART ((ptr_t) get_etext())
 #     define DATAEND	((ptr_t) get_end())
-#     define STACKBOTTOM ((ptr_t) 0xc0000000)
 #     define USE_MMAP
 #     define USE_MMAP_ANON
 #     ifdef GC_DARWIN_THREADS
-       /* This is potentially buggy. It needs more testing. See the comments in
-	  os_dep.c.  It relies on threads to track writes. */
-/* #       define MPROTECT_VDB */
+#       define MPROTECT_VDB
 #     endif
 #     include <unistd.h>
 #     define GETPAGESIZE() getpagesize()
@@ -1282,10 +1285,8 @@
 #     define STACKBOTTOM ((ptr_t) 0xc0000000)
 #     define USE_MMAP
 #     define USE_MMAP_ANON
-      /* This is potentially buggy. It needs more testing. See the comments in
-	 os_dep.c.  It relies on threads to track writes. */
 #     ifdef GC_DARWIN_THREADS
-/* #       define MPROTECT_VDB -- disabled for now.  May work for some apps. */
+#       define MPROTECT_VDB
 #     endif
 #     include <unistd.h>
 #     define GETPAGESIZE() getpagesize()
@@ -1880,8 +1881,6 @@
 #     define USE_MMAP
 #     define USE_MMAP_ANON
 #     ifdef GC_DARWIN_THREADS
-       /* This is potentially buggy. It needs more testing. See the comments in
-	  os_dep.c.  It relies on threads to track writes. */
 #       define MPROTECT_VDB
 #     endif
 #     include <unistd.h>


More information about the Gc mailing list