Bootstrap jimsh

The Jim interpreter is small, portable and full-featured. This makes jimsh an ideal tool to bootstrap a development system that requires an interpreter.

Consider the case of a development configuration system such as GNU autotools. Here it is necessary to run fairly complex scripts that invoke external programs (such as the compiler) and perform intensive string processing. The autotools solution uses a combination of Bourne Shell, the m4 Macro Processor and various external tools such as sed. Since this needs to work across a wide range of systems, even those with buggy shells or external tools, many contortions are required. The resulting system is slow, cumbersome and complex.

Now consider the different approach taken by autosetup. Here a scripting language is used that has excellent support for string processing, data structures (arrays/dicts and lists) and running external programs — Tcl. The only problem is bootstrap. What if the target system doesn’t have a suitable Tcl interpreter available? The solution is a bootstrap version of Jim Tcl is included in the distribution as a single source file and simply requires a C compiler to create the interpreter. In fact, autosetup automatically determines if no suitable and interpreter is available and seamlessly builds and runs the bootstrap interpreter.

$ ./configure 
No installed jimsh or tclsh, building local bootstrap jimsh0
Host System...x86_64-apple-darwin10.7.0
Build System...x86_64-apple-darwin10.7.0
C compiler...ccache cc -g -O2
C++ compiler...ccache c++ -g -O2
Checking for stdlib.h...ok

A script to create the bootstrap interpreter source is included in the jimtcl git repository

$ sh make-bootstrap-jim >jimsh0.c
$ time cc -o jimsh0 jimsh0.c
real   0m1.339s
user   0m1.121s
sys    0m0.109s
$ ./jimsh0
Welcome to Jim version 0.71

Steve Bennett (

comments powered by Disqus