1
# patches for the Boehm GC for PyPy under Windows
4
How to build a pypy compatible version of the Boehm collector
5
for Windows and Visual Studio .net 2003.
7
First of all, download the official Boehm collector suite
8
from http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc.tar.gz
9
At the time of writing (2005-10-06) this contains version gc6.5 .
11
Unpack this folder somewhere, for instance to "d:\tmp".
12
Change to this folder using
17
Then copy the file NT_THREADS_MAKEFILE to Makefile:
19
copy NT_THREADS_MAKEFILE Makefile
21
This file is the general-purpose gc dll makefile. For some internal
22
reasons, this file's defaults are bad for PyPy. The early initialisation
23
in DllMain() inhibits the changes necessary for PyPy. Use this script to
24
do a patch: (assuming that you have d:\pypy\dist\pypy\translator\goal)
26
python d:\pypy\dist\pypy\translator\goal\win32\gc_patch_windows.py
28
Now, your makefile is patched a little bit. In particular,
30
ALL_INTERIOR_POINTERS is now undefined, which PyPy wants to have
31
NO_GETENV is specified, since we don't want dependencies
33
and the name of the .lib and .dll files is changed to gc_pypy.???
35
Now you need to build your gc, either as a debug or as a release
36
build. First of all, make sure that you have your environment prepared.
37
Please note that you will need to use Microsoft's cmd, as cygwin bash
38
doesn't correctly handle the batch file in the next step.
40
With my setup, I have to do
42
"e:\Programme\Microsoft Visual Studio .NET 2003\Vc7\bin\vcvars32.bat"
44
After that, you can either build a release or a debug gc.
46
After a successful build, you need to enable gc_pypy.dll for your compiler.
47
There are many ways to install this. The following recommendation just
48
works without changing your environment variables. I think this is the
49
easiest way possible, but this is a matter of taste. What I did is:
51
nmake CFG="gc - Win32 Release"
53
After the build, you will find a gc_pypy.dll file in the Release folder.
54
Copy this file to c:\windows\system32 or any other folder that is always
55
in your PATH variable.
57
Also, copy Release\gc_pypy.lib to (in my case)
58
"e:\Programme\Microsoft Visual Studio .NET 2003\Vc7\lib";
60
finally, copy d:\tmp\gc6.5\include to
61
"e:\Programme\Microsoft Visual Studio .NET 2003\Vc7\include"
62
and rename this folder to "gc", so that "gc/gc.h" is valid.
66
In case of a debug build, replace "Release" by "Debug", and also copy
67
gc_pypy.pdb to your lib folder. This allows you to use source-level
68
debugging. Please note: If you want to both build the default gc.dll
69
and gc_pypy.dll, please delete the Debug resp. Release folders in
70
between. The generated .sbr files are in the way.
72
Please use the above recipe and report any bugs to me.
73
In case of trouble, I also can provide you with pre-built dlls.
74
Note: We also could have solved this by including the gc source
75
into the PyPy build. This may or may not become necessary if something
76
changes dramatically, again. As long as this is not needed, I prefer
79
Summary transcript of the steps involved: (please adjust paths)
83
copy NT_THREADS_MAKEFILE Makefile
84
python d:\pypy\dist\pypy\translator\goal\win32\gc_patch_windows.py
85
"e:\Programme\Microsoft Visual Studio .NET 2003\Vc7\bin\vcvars32.bat"
86
nmake CFG="gc - Win32 Release"
87
copy Release\gc_pypy.dll c:\windows\system32
88
copy Release\gc_pypy.lib "e:\Programme\Microsoft Visual Studio .NET 2003\Vc7\lib"
89
mkdir "e:\Programme\Microsoft Visual Studio .NET 2003\Vc7\include\gc"
90
copy include "e:\Programme\Microsoft Visual Studio .NET 2003\Vc7\include\gc"
96
'"ALL_INTERIOR_POINTERS"': '"NO_GETENV"',
99
for ending in "lib exp map pdb bsc dll pch".split():
100
REPLACE["gc.%s" % ending] = "gc_pypy.%s" % ending
102
def change_settings(src):
103
for old, new in REPLACE.items():
104
newsrc = src.replace(old, new)
106
raise ValueError, "this makefile does not contain %s" % old
112
for name in os.listdir("."):
113
if name.lower() == 'makefile':
116
raise ValueError, 'Makefile not found'
120
source = change_settings(file(name).read())
121
file(name, "w").write(source)
122
print "Updated your Makefile to fit PyPy's needs. Your lib will be named gc_pypy.dll"
123
print "and gc_pypy.lib. Please put them into appropriate places, see __doc__."