=== Top of the Swiki === Attachments ===

FAQ: Bootstrapping

How do you bootstrap a Squeak image? Meaning, if I don't have an image and only sources, is it possible to build a new image? Or, with an existing image, can I compile source files and create another brand new image?

i) You don't. Some bits is this Squeak are descended from Smalltalk-76. They have been loaded and saved in a 'core image' many times. It is, theoretically possible to start from nothing (since it has been done in the past, back before the earth cooled), but t'ain't easy.

ii) Use the SystemTracer. A SystemTracer reads every object in the system, and constructs a new '.image' file byte-by-byte. Transformations can be done along the way. TK estimates that the main line Squeak has been through the SystemTracer only 16 times since 1977.
Look at the code in the standard system for the basics, and consider looking at my ( Tim Rowledge) code for converting the compiled method format using the tracer. Go to http://sumeru.stanford.edu/tim/pooters/squeak.html to see more. Basically you can do just about anything using the tracer if you're careful, patient and precise.

iii) In general, the complete source code of a Smalltalk system is not a complete definition of the contents of the image (even for Squeak), though arguably it should be. There are usually a number of pools and dictionaries and such whose contents were defined interactively as needed back in the depths of time. However, these could be hunted down and proper initialization code written for them. Basking in the ignorance of never having actually bootstrapped an image, this is what I would do (I think :-b): first define a special compiler outside of the image you are creating (duh, since you don't have an image to begin with), then give the compiled code (and all related source and information) to a special image creator/interpreter to package everything up, do the initializations, and create all the oops and object structures and such - it would also need to link each CompiledMethod to the sources file and lots of other little details (as Tim said - t'ain't easy). Budd's "Little Smalltalk" has this capability I believe (for a greatly simplified implementation). All this assumes you have a VM that understands your image format and compiled code to run the image on when you get through - if not,.... The more I think about it the uglier it gets, but you get the idea. -- Dwight Hughes

iv) You might be interested in how another Smalltalk (GNU Smalltalk) does its bootstrapping. The sources for GNU Smalltalk are self contained and its virtual machine knows how to bootstrap an image from the system classes' source code. You can download it from ftp.gnu.org or one of its mirrors.