Fixed problem related to vec_ld in c++ mode.
[official-gcc.git] / boehm-gc / doc / README.darwin
blob3cd1b818b196badbf4269cfe29353223a66f772c
1 Darwin/MacOSX Support - July 22, 2003
2 ====================================
4 Important Usage Notes
5 =====================
7 GC_init() MUST be called before calling any other GC functions. This 
8 is necessary to properly register segments in dynamic libraries. This
9 call is required even if you code does not use dynamic libraries as the
10 dyld code handles registering all data segments.
12 When your use of the garbage collector is confined to dylibs and you
13 cannot call GC_init() before your libraries' static initializers have
14 run and perhaps called GC_malloc(), create an initialization routine
15 for each library to call GC_init():
17 #include <gc/gc.h>
18 void my_library_init() { GC_init(); }
20 Compile this code into a my_library_init.o, and link it into your
21 dylib. When you link the dylib, pass the -init argument with
22 _my_library_init (e.g. gcc -dynamiclib -o my_library.dylib a.o b.o c.o
23 my_library_init.o -init _my_library_init). This causes
24 my_library_init() to be called before any static initializers, and
25 will initialize the garbage collector properly. 
27 Note: It doesn't hurt to call GC_init() more than once, so it's best,
28 if you have an application or set of libraries that all use the
29 garbage collector, to create an initialization routine for each of
30 them that calls GC_init(). Better safe than sorry. 
32 The incremental collector is still a bit flaky on darwin. It seems to 
33 work reliably with workarounds for a few possible bugs in place however
34 these workaround may not work correctly in all cases. There may also
35 be additional problems that I have not found. 
37 Implementation Information
38 ==========================
39 Darwin/MacOSX support is nearly complete. Thread support is reliable on 
40 Darwin 6.x (MacOSX 10.2) and there have been reports of success on older
41 Darwin versions (MacOSX 10.1). Shared library support had also been
42 added and the gc can be run from a shared library. There is currently only
43 support for Darwin/PPC although adding x86 support should be trivial.
45 Thread support is implemented in terms of mach thread_suspend and 
46 thread_resume calls. These provide a very clean interface to thread
47 suspension. This implementation doesn't rely on pthread_kill so the
48 code works on Darwin < 6.0 (MacOSX 10.1). All the code to stop the
49 world is located in darwin_stop_world.c.
51 The original incremental collector support unfortunatelly no longer works
52 on recent Darwin versions. It also relied on some undocumented kernel
53 structures. Mach, however, does have a very clean interface to exception
54 handing. The current implementation uses Mach's exception handling. 
56 Much thanks goes to Andrew Stone, Dietmar Planitzer, Andrew Begel, 
57 Jeff Sturm, and Jesse Rosenstock for all their work on the 
58 Darwin/OS X port.
60 -Brian Alliet
61 brian@brianweb.net
64 Older Information (Most of this no longer applies to the current code)
65 ======================================================================
67 While the GC should work on MacOS X Server, MacOS X and Darwin, I only tested
68 it on MacOS X Server.
69 I've added a PPC assembly version of GC_push_regs(), thus the setjmp() hack is
70 no longer necessary. Incremental collection is supported via mprotect/signal.
71 The current solution isn't really optimal because the signal handler must decode
72 the faulting PPC machine instruction in order to find the correct heap address.
73 Further, it must poke around in the register state which the kernel saved away
74 in some obscure register state structure before it calls the signal handler -
75 needless to say the layout of this structure is no where documented.
76 Threads and dynamic libraries are not yet supported (adding dynamic library
77 support via the low-level dyld API shouldn't be that hard).
79 The original MacOS X port was brought to you by Andrew Stone.
82 June, 1 2000
84 Dietmar Planitzer
85 dave.pl@ping.at
87 Note from Andrew Begel:
89 One more fix to enable gc.a to link successfully into a shared library for
90 MacOS X. You have to add -fno-common to the CFLAGS in the Makefile. MacOSX
91 disallows common symbols in anything that eventually finds its way into a
92 shared library. (I don't completely understand why, but -fno-common seems to
93 work and doesn't mess up the garbage collector's functionality).
95 Feb 26, 2003
97 Jeff Sturm and Jesse Rosenstock provided a patch that adds thread support.
98 GC_MACOSX_THREADS should be defined in the build and in clients.  Real
99 dynamic library support is still missing, i.e. dynamic library data segments
100 are still not scanned.  Code that stores pointers to the garbage collected
101 heap in statically allocated variables should not reside in a dynamic
102 library.  This still doesn't appear to be 100% reliable.  
104 Mar 10, 2003
105 Brian Alliet contributed dynamic library support for MacOSX.  It could also
106 use more testing.