FSF GCC merge 02/23/03
[official-gcc.git] / boehm-gc / doc / README.win32
blobb1a6ec5966491054687e795495ed6ad68d32971c
1 The collector has at various times been compiled under Windows 95 & NT,
2 with the original Microsoft SDK, with Visual C++ 2.0, 4.0, and 6, with
3 the GNU win32 environment, with Borland 4.5,  with Watcom C, and recently
4 with the Digital Mars compiler.  It is likely that some of these have been
5 broken in the meantime.  Patches are appreciated.
7 It runs under both win32s and win32, but with different semantics.
8 Under win32, all writable pages outside of the heaps and stack are
9 scanned for roots.  Thus the collector sees pointers in DLL data
10 segments.  Under win32s, only the main data segment is scanned.
11 (The main data segment should always be scanned.  Under some
12 versions of win32s, other regions may also be scanned.)
13 Thus all accessible objects should be accessible from local variables
14 or variables in the main data segment.  Alternatively, other data
15 segments (e.g. in DLLs) may be registered with the collector by
16 calling GC_init() and then GC_register_root_section(a), where
17 a is the address of some variable inside the data segment.  (Duplicate
18 registrations are ignored, but not terribly quickly.)
20 (There are two reasons for this.  We didn't want to see many 16:16
21 pointers.  And the VirtualQuery call has different semantics under
22 the two systems, and under different versions of win32s.)
24 The collector test program "gctest" is linked as a GUI application,
25 but does not open any windows.  Its output appears in the file
26 "gc.log".  It may be started from the file manager.  The hour glass
27 cursor may appear as long as it's running.  If it is started from the
28 command line, it will usually run in the background.  Wait a few
29 minutes (a few seconds on a modern machine) before you check the output.
30 You should see either a failure indication or a "Collector appears to
31 work" message.
33 The cord test program has not been ported (but should port
34 easily).  A toy editor (cord/de.exe) based on cords (heavyweight
35 strings represented as trees) has been ported and is included.
36 It runs fine under either win32 or win32S.  It serves as an example
37 of a true Windows application, except that it was written by a
38 nonexpert Windows programmer.  (There are some peculiarities
39 in the way files are displayed.  The <cr> is displayed explicitly
40 for standard DOS text files.  As in the UNIX version, control
41 characters are displayed explicitly, but in this case as red text.
42 This may be suboptimal for some tastes and/or sets of default
43 window colors.)
45 In general -DREDIRECT_MALLOC is unlikely to work unless the
46 application is completely statically linked.
48 The collector normally allocates memory from the OS with VirtualAlloc.
49 This appears to cause problems under Windows NT and Windows 2000 (but
50 not Windows 95/98) if the memory is later passed to CreateDIBitmap.
51 To work around this problem, build the collector with -DUSE_GLOBAL_ALLOC.
52 This is currently incompatible with -DUSE_MUNMAP.  (Thanks to Jonathan
53 Clark for tracking this down.)
55 For Microsoft development tools, rename NT_MAKEFILE as
56 MAKEFILE.  (Make sure that the CPU environment variable is defined
57 to be i386.)  In order to use the gc_cpp.h C++ interface, all
58 client code should include gc_cpp.h.
60 Clients may need to define GC_NOT_DLL before including gc.h, if the
61 collector was built as a static library (as it normally is in the
62 absence of thread support).
64 For GNU-win32, use the regular makefile, possibly after uncommenting
65 the line "include Makefile.DLLs".  The latter should be necessary only
66 if you want to package the collector as a DLL.  The GNU-win32 port is
67 believed to work only for b18, not b19, probably dues to linker changes
68 in b19.  This is probably fixable with a different definition of
69 DATASTART and DATAEND in gcconfig.h.
71 For Borland tools, use BCC_MAKEFILE.  Note that
72 Borland's compiler defaults to 1 byte alignment in structures (-a1),
73 whereas Visual C++ appears to default to 8 byte alignment (/Zp8).
74 The garbage collector in its default configuration EXPECTS AT
75 LEAST 4 BYTE ALIGNMENT.  Thus the BORLAND DEFAULT MUST
76 BE OVERRIDDEN.  (In my opinion, it should usually be anyway.
77 I expect that -a1 introduces major performance penalties on a
78 486 or Pentium.)  Note that this changes structure layouts.  (As a last
79 resort, gcconfig.h can be changed to allow 1 byte alignment.  But
80 this has significant negative performance implications.)
81 The Makefile is set up to assume Borland 4.5.  If you have another
82 version, change the line near the top.  By default, it does not
83 require the assembler.  If you do have the assembler, I recommend
84 removing the -DUSE_GENERIC.
86 There is some support for incremental collection.  This is
87 currently pretty simple-minded.  Pages are protected.  Protection
88 faults are caught by a handler installed at the bottom of the handler
89 stack.  This is both slow and interacts poorly with a debugger.
90 Whenever possible, I recommend adding a call to
91 GC_enable_incremental at the last possible moment, after most
92 debugging is complete.  Unlike the UNIX versions, no system
93 calls are wrapped by the collector itself.  It may be necessary
94 to wrap ReadFile calls that use a buffer in the heap, so that the
95 call does not encounter a protection fault while it's running.
96 (As usual, none of this is an issue unless GC_enable_incremental
97 is called.)
99 Note that incremental collection is disabled with -DSMALL_CONFIG.
101 James Clark has contributed the necessary code to support win32 threads.
102 Use NT_THREADS_MAKEFILE (a.k.a gc.mak) instead of NT_MAKEFILE
103 to build this version.  Note that this requires some files whose names
104 are more than 8 + 3 characters long.  Thus you should unpack the tar file
105 so that long file names are preserved.  To build the garbage collector
106 test with VC++ from the command line, use
108 nmake /F ".\gc.mak" CFG="gctest - Win32 Release"
110 This requires that the subdirectory gctest\Release exist.
111 The test program and DLL will reside in the Release directory.
113 This version relies on the collector residing in a dll.
115 This version currently supports incremental collection only if it is
116 enabled before any additional threads are created.
117 Version 4.13 attempts to fix some of the earlier problems, but there
118 may be other issues.  If you need solid support for win32 threads, you
119 might check with Geodesic Systems.  Their collector must be licensed,
120 but they have invested far more time in win32-specific issues.
122 Hans
124 Ivan V. Demakov's README for the Watcom port:
126 The collector has been compiled with Watcom C 10.6 and 11.0.
127 It runs under win32, win32s, and even under msdos with dos4gw
128 dos-extender. It should also run under OS/2, though this isn't
129 tested. Under win32 the collector can be built either as dll
130 or as static library.
132 Note that all compilations were done under Windows 95 or NT.
133 For unknown reason compiling under Windows 3.11 for NT (one
134 attempt has been made) leads to broken executables.
136 Incremental collection is not supported.
138 cord is not ported.
140 Before compiling you may need to edit WCC_MAKEFILE to set target
141 platform, library type (dynamic or static), calling conventions, and
142 optimization options.
144 To compile the collector and testing programs use the command:
145     wmake -f WCC_MAKEFILE
147 All programs using gc should be compiled with 4-byte alignment.
148 For further explanations on this see comments about Borland.
150 If gc compiled as dll, the macro ``GC_DLL'' should be defined before
151 including "gc.h" (for example, with -DGC_DLL compiler option). It's
152 important, otherwise resulting programs will not run.
154 Ivan Demakov (email: ivan@tgrad.nsk.su)