-
Notifications
You must be signed in to change notification settings - Fork 108
/
HowToBuild
216 lines (172 loc) · 8.53 KB
/
HowToBuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
How To Build On Win32
---------------------
Contents:
- Overview
- Checking out sources to build out-of-the-box
- Building out of the box
- Building a Specific Plugin Dll
- Building the VM Simulator Support Libraries
- Building an MSI installer (Newspeak)
- Optimization level and gcc version (please read!)
- Debugging with gdb
- Debugging with Visual Studio
Overview
--------
The "Cog" VM comes in a bewildering variety of forms. The first distinction
is between Squeak/Croquet VMs that run Squeak, Pharo, Cuis, Croquet images
and their ilk, and between Newspeak VMs that run Newspeak.
Another distinction is between Stack, Cog and Sista VMs. Stack VMs are those
with context-to-stack mapping that optimise message sending by keeping method
activations on a stack instead of in contexts. These are pure interpreters but
significantly faster than the standard context-based Interpreter VM. Cog VMs
add a JIT to the mix, compiling methods used more than once to maxchine code on
the fly. Sista VMs, as yet unrealised and in development, add support for
adaptive optimization that does speculative inlining at the bytecode-to-bytecode
level. These are targeted for release in 2015.
Another distinction is between "v3" VMs and Spur VMs. "v3" is the original
object representation for Squeak as described in the back-to-the-future paper.
Spur, as described on the www.mirandabanda.org blog, is a faster object
representation which uses generation scavenging, lazy forwarding for fast
become, and a single object header format common to 32 and 64 bit versions.
Another distinction is between normal single-threaded VMs that schedule "green"
Smalltalk processes above a single-threaded VM, and "multi-threaded" VMs that
share the VM between any number of native threads such that only one native
thread owns the VM at any one time, switching between threads on FFI calls and
callbacks or on Smalltalk process switches when Smalltalk processes are owned
by threads. This multi-threaded support is as yet experimental.
The final distinction is between production, assert and debug VMs. Production
VMs are fully optimized, although they may include debugging symbols, and as
their name implies are for use in production. Assert and debug VMs include
many assert checks that are disabled in the production VMs. These asserts are
very helpful in debugging VM problems but significantly impact performance.
The difference between assert and debug VMs is that assert VMs are compiled
with moderate optimization, which improves the performance of the asserts,
whereas debug VMs are compiled with no optimization at all, providing maximum
debuggability with minimum performance.
This directory tree provides build directories for some of this matrix. For
example, squeak.cog.v3 contains a build directory for Smalltalk Cog VMs using
the old object representation, newspeak.stack.spur contains a build directory
for Newspeak Stack VMs using the Spur object representation. Build as desired.
Checking out sources to build out-of-the-box
--------------------------------------------
Check-out the repository from github:
git clone http://www.github.com/OpenSmalltalk/opensmalltalk-vm oscogvm
cd ./oscogvm
more README.md
Building out of the box
-----------------------
The standard build configurations are the MinGW tools under Cygwin.
The build system also supports Visual Studio Community (tested with 2017), but
requires Cygwin tools, especially GNU Make, to run.
Cygwin 1. Install the tools:
- Install
either cygwin 64bits version from www.cygwin.com.
either mingw 64bits version and msys from www.mingw.com.
If installing Cygwin make sure you install the MinGW support, which is in the
list of packages called "mingw64-i686-gcc-core,mingw64-i686-gcc-g++,mingw64-i686-headers,mingw64-i686-runtime".
Note that the .appveyor.yml file may be used as example to automate installation of these tools.
.appveyor.yml calls scripts/installCygwin.bat that you can use to build your own cygwin.
Alternatively, an installation of mingw32 and msys may work, but has not been tested.
Cygwin 2. Build
Then cd to the build directory of your choice, e.g.
building/win32x86/squeak.cog.spur/
Then execute
./mvm
This builds debug, assert and production versions of the VM in builddbg/vm,
buildast/vm and build/vm. If the configuration includes multi-threaded builds
it will also create VMs in buildmtdbg/vm, buildmtast/vm and buildmt/vm. The
system builds two VMs in each build/vm directory, e.g. Squeak.exe and
SqueakConsole.exe. The latter is to be used with console applications that wish
to access standard i/o.
In order to only build the production vm, you can launch the command:
./mvm -f
For building with clang instead of gcc, it is possible to pass options to make via mvm after --:
./mvm -f -- CC=i686-w64-mingw32-clang
If building from mingw32, it may be necessary to omit the tool prefix:
./mvm -f -- TOOLPREFIX=''
MSVC 1. Install the tools:
- follow step Cygwin 1. Install the tools
- Make sure that the tools directory (e.g., C:\cygwin\bin) is in your PATH environment variable
- Install Visual Studio Community from https://visualstudio.microsoft.com/downloads/
MSVC 2. Build
Open a x86 Native Tools Command Prompt from Visual Studio.
Then cd to the build directory of your choice, e.g.
building/win32x86\squeak.cog.spur\
Then execute
..\common\SETPATH.BAT
to add the cygwin tools to your path (edit SETPATH if they are not installed in
c:\cygwin64)
Then execute
..\common\MAKEDEBUG.BAT
..\common\MAKEASSERT.BAT
..\common\MAKEFAST.BAT
to make each of the three VMs.
Both Builds
Each build directory contains two files
plugins.int
plugins.ext
that determine the set of plugins to be taken from the supplied plugins
directory (which defaults to ../../src/plugins), and which are to be linked
into the VM (plugins.int) or compiled as external dlls to be dynamically
linked at run-time (plugins.ext). Tailor these files as you wish.
The Newspeak builds include an installer. See Building an MSI installer below.
Finally, at the building/win32x86 level the makeall script will run all the
mvm scripts it can find.
Building a Specific Plugin Dll
------------------------------
To make only a specific dll one must use the target of the plugin dll (or .lib)
to be made. e.g.
$ cd squeak.cog.spur
$ make build/vm/BochsIA32Plugin.dll
Building the VM Simulator Support Libraries
------------------------------------
If you want to get the Cog VM simulator working you'll need to build one or more
of the processor simulator plugins, each of which has support libraries that
must be built:
Processor Plugin Support Library
x86 BochsIA32Plugin building/linux32x86/bochsx86
x86_64/x64 BochsX64Plugin building/linux32x86/bochsx64
ARMv5 GdbARMPlugin building/linux32x86/gdbarm32
cd to the relevant directories; run conf.COG and then the build script, e.g.
$ cd building/linux32x86/bochsx86
$ ./conf.COG
$ ./makeem
Then when Squeak VMs are built they will include the plugin(s) for which support
libraries have been provided.
Building an MSI installer (Newspeak)
------------------------------------
The Newspeak builds include an installer subdirectory. The installer build
creates an MSI installer that provides a platform-conformat install experience
for the VM. First build the VM then cd to the installer and make, e.g.:
$ cd newspeak.cog.v3
$ ./mvm
$ cd installer
$ make
Optimization level and gcc version
----------------------------------
There used to be issues with gcc version > 4.2.1. Any of the following flags may break the build at -O2:
-ftree-pre
-fpartial-inlining
-fcaller-saves
However, with removal of some Undefined Behavior in source code, this list might well be out of date.
See http://smallissimo.blogspot.fr/2013/02/compiling-squeak-cog-virtual-machine-on.html
Debugging with gdb
------------------
Note that even the stripped production VM can be used for debug using the
unstripped VM to provide symbols, e.g.
U:\ gdb bin/Squeak.exe
...
(no debugging symbols found)
(gdb) file SqueakUnstripped.exe
(gdb) run trunk.image
Note that on Cygwin, while cross-compilation works well, cross debugging does
not work at all. One has to debug 32-bit executables on a 32-bit installation
with a 32-bit gdb, and 64-bit executables on a 64-bit installation with a 64-bit
gdb.
Debugging with Visual Studio
----------------------------
Even though the MSVC build outline above does not use MSVC project files,
debugging is straight-forward.
1. Open Visual Studio
2. use Open Folder... to open {build,buildast,builddbg}/vm as desired
3. use Open File... to open the desired executable, e.g. Squeak.exe