Building Images

$Revision: 5.0.2.17 $

The document introduction.htm provides an overview of the Allegro CL documentation with links to all major documents. The document index.htm is an index with pointers to every documented object (operators, variables, etc.) The revision number of this document is below the title. These documents may be revised from time to time between releases.

1.0 Comparison with earlier releases
2.0 Comparison with excl:dumplisp
3.0 Comparison with excl:generate-application
4.0 The template of a call to build-lisp-image
5.0 Arguments to build-lisp-image 1: defaults inherited from the running image
6.0 Arguments to build-lisp-image 2: defaults not inherited from running image
7.0 Use of custom.cl
8.0 Building an image to include patches
9.0 Comparison of build-lisp-image with version 4.3's build/install_lisp
10.0 Minimal top levels
    10.1 Using the default minimal top-level
    10.2 Requiring the normal top-level in a minimal top-level lisp
    10.3. Top-level variables

There are many links to excl:build-lisp-image in this document. In fact, essentially all relevant information about excl:build-lisp-image is contained in this document.

The function excl:build-lisp-image can be used to create a new image (dxl) file. This will be a fresh image, fresh in the sense that it inherits little from the running image (only values of certain global variables used as argument defaults). Typical reasons for building images with excl:build-lisp-image include:

excl:build-lisp-image is a lisp function, so it is called from a running Lisp. We distinguish between the image of the running image, the running image, from the image being created, the new image.

excl:build-lisp-image spawns a separate process. On Windows, a "Create image" window displays information about the build process (you may have to expose this window). On Unix, information is printed to the listener. You will see many prompts: do not attempt to type to them.

1.0 Comparison with earlier releases

UNIX: in earlier versions of Allegro CL on Unix, images were created using a shell script build/install_lisp. This created a new executable image file from constituent parts (.o files at the start of the process, .fasl files once a proto-lisp had been built). The overriding defect of this method of creating custom images was that a suitable C compiler was often needed for the new Lisp image to be built. That was not a problem when C compilers were bundled with hardware, but such bundling is no longer standard. Starting with 5.0, building a new image is done entirely within Lisp.

WINDOWS: building a custom image from constituent parts was not supported in earlier releases of Allegro CL on Windows (releases up to 3.0.2). Customizations and patches were loaded at startup time. It was possible to dump (using save-image) a customized image but this generally inherited indiscriminately from the running image.

Release 4.3.2, an interim release on Windows, was something of a hybrid (using a separate executable named config.exe). The 4.3.2 behavior was unique to that single release.

2.0 Comparison with excl:dumplisp

Images can also be created with excl:dumplisp, as described in the documentation for that function and in the document dumplisp.htm. An image created by excl:dumplisp is essentially a copy of the currently running image, with all loaded functionality included and all values of variables preserved. In contrast, excl:build-lisp-image spawns a separate process which builds a new image out of constituent parts. The currently running image supplies only default values for certain arguments. The new image does not capture loaded or newly-defined functionality of the running image (thus, if the function user::foo is defined in the currently running image, it will not be defined in the new image created by excl:build-lisp-image).

This is why excl:build-lisp-image can be used to create a new image with new patches. Patches in the currently running image are not captured by the newly created image. Instead (as described below), patch files are built into the newly created image but the patches in the current image are not involved.

Note that excl:build-lisp-image calls excl:dumplisp in the spawned process. All arguments accepted by excl:dumplisp are also accepted by excl:build-lisp-image except the name argument (which is accepted but ignored since the required argument to excl:build-lisp-image specifies the new image name).

3.0 Comparison with excl:generate-application

excl:generate-application itself calls excl:build-lisp-image. generate-application is designed to produce a directory of files suitable for shipping to another machine or site (note that you must be licensed to distribute software built in Allegro CL – contact your Franz Inc. sales representative if you are unsure of licensing terms). In contrast, excl:build-lisp-image builds a single image file only. See the description of excl:generate-application and the document delivery.htm.

4.0 The template of a call to build-lisp-image

The "BUILD" module must be loaded for excl:build-lisp-image to work (that is, "BUILD" should be on the *modules* list). It will be loaded automatically when excl:build-lisp-image is called. You can force loading of the module by evaluating

(require :build)

excl:build-lisp-image takes one required and many keyword arguments. The required argument must be a string naming a file, with or without path information. If no path information is specified, the image file will be placed in the current directory (as returned by excl:current-directory). If relative path information is supplied, it will be resolved relative to the current directory. The image file name must have an extension (type). If it does not, it will not be found when Lisp is started. The standard extension (type) of an image file is .dxl but any extension will do. Note that on Windows machines, .dxl is registered and associated with Allegro CL, so double-clicking on a dxl file (in the Windows Explorer, say) executes lisp.exe with `-I <that file>.dxl' as arguments. When lisp.exe is called without an image specified with –I, it looks for an image (dxl) file with the same name (i.e. lisp) and in the same directory. You can copy lisp.exe to <anything else>.exe if you want it to find a different image file named <anything else>.dxl automatically.

Here is the template for a call to excl:build-lisp-image:

(excl:build-lisp-image image-file
                       &key ...keywords...
                             ...dumplisp-keywords...)

5.0 Arguments to build-lisp-image 1: defaults inherited from the running image

Certain defaults for keyword arguments to excl:build-lisp-image are inherited from the currently running image. It is important to understand that these inheritances are the only effect that values in the currently running image have on the new image being built.

Argument Default Description
:case-mode *current-case-mode* Sets the case mode of the new Lisp image. The default is the case mode of the running image. The value can be one of.

:case-sensitive-lower
:case-insensitive-lower
:case-sensitive-upper
:case-insensitive-upper (the standard Common Lisp value)

:dst excl:*daylight-saving-time-observed* Controls daylight savings time inclusion in time computations. If t, United States Daylight Savings Time schedules are used. If nil, daylight savings time is assumed to never be in force. There is no direct support for non-United States schedules. Users outside the United States can contact Franz Inc. technical support (bugs@franz.com) for assistance in implementing a different schedule.
:include-clim t if clim is in the currently running image, nil if it is not. UNIX only.  When non-nil, include CLIM in the resulting image.
:include-common-graphics This argument is no longer supported. Windows only.  If you are building a development image, specify :include-ide true and Common Graphics and the IDE will be in the image. If building an application image, use the project system in the IDE.
:include-compiler t if the compiler is in the currently running image, nil if it is not.

When building a standard runtime image (i.e. when the :runtime argument (in the next table) is specified :standard), the compiler cannot be in the image created. Thus, either this argument must be specified nil or both this argument and :discard-compiler must be specified t.

When non-nil, include the compiler as the resulting image is being built.  Whether the compiler is in the built image depends on the value of the :discard-compiler argument.

When nil, the compiler will not be available at any point during the image building process or in the built image.

See the :discard-compiler option in the next table.

:include-composer t if Allegro Composer is in the currently running image, nil if it is not. UNIX only.  When non-nil, include Composer in the resulting image.
:include-debugger t (The default for this argument is not inherited from the running image, so this argument belongs in the next table. It is repeated here to be with the other :include-* arguments.)

When non-nil, include the debugger in the resulting image.

:include-devel-env t if the development environment is in the currently running image (i.e. :develenv is on the *modules* list), nil if it is not. When non-nil, include the non-graphical development environment in the resulting image. The file sys:;develenv.cl (i.e. develenv.cl in the Allegro directroy) lists the modules (as arguments to require) that make up the development environment. This argument must be specified nil when :runtime is non-nil since some modules are not allowed in a runtime image.
:include-ide t if the IDE is in the currently running image, nil if it is not. Windows only.  When non-nil, include the graphical development environment in the resulting image.
:include-tpl t if the top level is in the currently running image, nil if it is not. When non-nil, include the normal top-level in the resulting image. When nil a minimal top level, as described in 10.0 Minimal top levels below, is available. Also specify nil when supplying your own top level.
:include-xcw t if Common Windows is in the currently running image, nil if it is not. UNIX only.  When non-nil, include Common Windows in the resulting image.
:init-file-names excl:*init-file-names* The value should be a list of strings naming files without directory information, like

(".clinit.cl" "clinit.cl")

The directories to be searched for these files is determined at runtime (the current directory and the home directory – see startup.htm).

The default comes from the value of the indicated variable in the running image.   See also :read-init-files below.

:load-local-names-info *load-local-names-info* The value of this argument serves as the default value for *load-local-names-info* in the image to be built. By default, the value is inherited from the value in the running image. The value can be t or nil.
:load-source-file-info *load-source- file-info* The value of this argument serves as the default value for *load-source- file-info* in the image to be built. By default, the value is inherited from the value in the running image. The value can be t or nil.
:load-xref-info *load-xref -info* The value of this argument serves as the default value for *load-xref -info* in the image to be built. By default, the value is inherited from the value in the running image. The value can be t or nil.

When buuilding a runtime (i.e. :runtime is non-nil), it is best to explicitly specify this argument nil.

:pll-file (excl:pll-file) The value can be a string naming an existing pll file or nil. The default is the pll file used by the running image (as returned by excl:pll-file). If nil, no pll file will be used by the new image. Instead, data that would be placed in the pll file (code vectors and string constants) are placed in the Lisp heap.

If the value has no directory information (i.e. is just a filename or a filename and a file type), the pll file will be looked for on startup as described in the pll-file entry. If directory information is included, that location (relative to the current directory is relative), will be looked in but nowhere else. The file type default to .pll if unspecified. Note that some pll files have type .epll.

Note that build-lisp-image does not create a pll file so it is an error to specify a non-existent file as the value of this argument.

Pll files are created by the program cvdcvt. See the definition of that program and also the discussion of pll files in miscellaneous.htm. See also generate-application and delivery.htm.

:print-startup-message excl:*print-startup-message* The value of excl:*print-startup-message* is set to the value of this keyword argument in the new image being created.
:read-init-files excl:*read-init-files* Specifies the value of excl:*read-init-files* in the new image. The value can be:

t, meaning look in both the current directory and the home directory for init files and load sys:siteinit.cl;

nil, meaning read no initialization files;

:nohome, meaning look only in the current directory and load sys:siteinit.cl.

The default is the value of excl:*read-init-files* in the running image.

See the document startup.htm for information on initialization files and the meaning of the current and the home directories. See also :init-file-names above.

:record-source-file-info *record-source- file-info* The value of this argument serves as the default value for *record-source- file-info* in the image to be built. By default, the value is inherited from the value in the running image.

When buuilding a runtime (i.e. :runtime is non-nil), it is best to explicitly specify this argument nil.

:record-xref-info *record-xref- info* The value of this argument serves as the default value for *record-xref- info* in the image to be built. By default, the value is inherited from the value in the running image.
:restart-app-function *restart-app-function* Causes *restart-app-function* to be set to this value. The value must be a symbol (it cannot be a function object). See startup.htm or delivery.htm.
:restart-init-function *restart-init-function* Causes *restart-init-function* to be set to this value. The value must be a symbol (it cannot be a function object). See startup.htm or delivery.htm.

Note that the value of this variable on Windows in an image that starts the IDE, is cg:start-ide.

6.0 Arguments to build-lisp-image 2: defaults not inherited from running image

Most of the remaining keyword arguments are listed in the next table. The keyword arguments to excl:dumplisp are also acceptable to excl:build-lisp-image. None of these arguments inherit values from the currently running image.

Argument Default value Description/compatibility notes
:autoload-warning nil If non-nil, then a report of autoloadable functions will be made to autoloads.out.  If a string, it is interpreted as a filename which will be used in place of autoload.out for the report.

An autoloadable function is one for which the function definition is in fact not present in the image. Instead are instructions to load a particular file, usually a fasl file out of the bundle in the Allegro directory. Once the file is loaded, the true function definition is used to evaluate the call to the function that triggered the autoload.

The autoloading feature is designed to keep unneeded functionality from unnecessarily increasing the size of the running image, but to make use of functionality transparent to users. If you are building an image for use locally (say, making an image with patches) this report is likely of no interest since autoloading is typically transparent, as we said. If however, you are creating an application, you may want to know what functionality might be autoloaded since you are not permitted to distribute the files.bu bundle file from where most autoloading is done. For this reason, generate-application changes the default for this argument to t.

The format of autoload.out is two columns, a fasl file name on the left and the function that triggers its loading on the right. Some files are loaded by many functions and so appear many times on the left.

:build-executable lisp (unix)

lisp.exe (Windows)

Specifies the name of the Lisp executable that will be invoked when the process that builds the new image file is spawned. It is unusualy to specify a value for this argument, but you may wish to do so.

Note: if build-lisp-image is being called by generate-application, the value of this argument is used by generate-application as well. The specified executable will be the one copied to the application directory. See delivery.htm.

:c-heap-size nil Allows specification of the total size of the C heap.  See the note immediately following this table.
:c-heap-start nil Allows specification of the start of the C heap. This value must be above the value of :lisp-heap-start.  See the note immediately following this table.. See release_notes.htm#About the Lisp heap for information on the initial value of this argument.
:debug-on-error t Windows only. Allows debugging of problems that occur while loading the input files. (The argument is accepted on UNIX but because of the use of pipes in the build process, it is ineffective.) See FAQ item 3-8.1 for information on debugging on UNIX.
:copy-shared-libraries See generate-application and delivery.htm. This argument is only relevant when used with generate-application.
:discard-arglists nil Value can be nil, :medium, and t.

nil means keep all arglist information;

:medium means discard actual symbols used and use dummy ones (thus reducing the number of symbols in the new image at the cost of the information contained in argument names);

t means discard all arglist information.

:discard-compiler nil Allows the compiler to be discarded after the input files are loaded. This might be necessary for some applications. :include-compiler must be t if this argument is t.
:discard-local-name-info t Controls throwing away local name information loaded from .fasl files as a result of the compiler switch comp:save-local-names-switch. If t, local name information is discarded. If nil, it is maintained.
:discard-source-file-info (null <value
of :load-source
-file-info
argument>)
Controls throwing away source file information.  A non-nil value both discards source file info in the image being created and causes the initial value of *record-source-file-info* and *load-source-file-info*  to be nil.
:discard-xref-info (null <value
of :load-xref-info
argument>)
Controls throwing away of cross reference information.  A non-nil value both discards cross reference info in the image being created and causes the initial value of *record-xref-info* and *load-xref-info* to be nil.

When building a runtime (i.e. :runtime is non-nil), the value of this argument must be nil. (This is counter-intuitive but since both :load-xref-info and :record-xref-info must be nil, there will be no xref info to discard.)

:dribble-file nil Allows specifying a dribble file which contains a transcript of the entire process of building the image. The value, if supplied, must be a string naming a file.
:exit-after-image-build t Windows only. Causes the running Lisp to exit after image creation. (The argument is accepted on UNIX but because of the use of pipes in the build process, it is ineffective.) See FAQ item 3-8.1 for information on debugging on UNIX.
:generate-fonts nil UNIX only. Generate (X) fonts from server specified by :server-name.
:include-* [See text at right] All :include-* arguments except :include-debugger, documented just below, are documented in 5.0 Arguments to build-lisp-image 1: defaults inherited from the running image above since their default values are inherited from the running image.
:include-debugger t When non-nil, include the debugger in the resulting image.
:internal-debug nil Causes the forms used to build the image to be saved in a file build.out. If the value is a string, it should name a file to use in place of build.out.
:lisp-heap-size nil Allows specification of the total size to which the Lisp heap is expected to grow. The value for an image is printed by (room t) output (as Lisp Heap Limit). If you see gaps in room output, you may wish to build an image with a larger heap. See gc.htmSee the note immediately following this table.
:lisp-heap-start nil Allows specification of the start of the Lisp heap.  The value must be a decimal integer below the value of :c-heap-start.  See the note immediately following this table. See release_notes.htm#About the Lisp heap for information on the initial value of this argument.
:lisp-files nil Allows Lisp files to be loaded before the image is created.   The value of this argument is nil or a list of files to load.  The files can be a pathname, string or symbol.  In the case of a symbol, it is given to cl:require to load. These files are loaded after custom.cl is loaded, as described below.

This argument is ignored by excl:generate-application. Instead, files to load are specified by the required input-files argument.

:newspace See text at right. Species the size of the newspace in the new image. See the document gc.htm for information on newspace sizes. Default value is 2mb if the :include-devel-env value is non-nil, 6k (or larger) otherwise. The value should be an integer, like 2000000 for 2 megabytes.
:oldspace See text at right. Species the amount of free oldspace in the new image. See the document gc.htm for information on oldspace sizes. Default value is 2mb if the :include-devel-env value is non-nil, 256k otherwise. The value should be an integer, like 2000000 for 2 megabytes.
:opt-debug 2 The initial value of the debug optimization quality in the new image. Value must be one of 0, 1, 2, 3. See compiling..htm#8.0 Declarations and optimizations for information on how these values are used.
:opt-safety 1 The initial value of the safety optimization quality in the new image. Value must be one of 0, 1, 2, 3 but 0 is strongly discouraged. See compiling..htm#8.0 Declarations and optimizations for information on how these values are used.
:opt-space 1 The initial value of the space optimization quality in the new image. Value must be one of 0, 1, 2, 3. See compiling..htm#8.0 Declarations and optimizations for information on how these values are used.
:opt-speed 1 The initial value of the speed optimization quality in the new image. Value must be one of 0, 1, 2, 3. See compiling..htm#8.0 Declarations and optimizations for information on how these values are used.
:post-load-form nil A form to be evaluated just after the files given by :lisp-files are loaded.
:pre-load-form nil A form to be evaluated just before the files given by :lisp-files are loaded.
:preserve-documentation
-strings
t If non-nil, then preserve documentation strings in the new image being created. Note that Allegro CL does not use documentation strings in general except in the Integrated Development Environment (on Windows).
:presto nil Determines whether Allegro Presto is enabled or not in the new image and can specify the initial value of excl:*libfasl*. Possible values are:

t -- enable Allegro Presto and make intial value of excl:*libfasl* t.
nil -- disable Allegro Presto and make initial value of excl:*libfasl* nil (but that value is iggnored anyway since Allegro Presto is disabled).
:enable -- enable Allegro Presto and make initial value of excl:*libfasl* nil.

.See loading.htm for information on presto or libfasl loading.

:presto-flush-to-code-file nil If specified non-nil, the value must name a file. sys:flush-codevectors is called with the value as the first argument and nil as the second argument. This argument is processed just before :presto-lib is processed.
:presto-lib nil If specified non-nil, the value must name a file. sys:presto-build-lib is called with the value as its single argument (putting all stub definitions into that file). See loading.htm for information on presto (libfasl) loading.
:restart-app-function This argument is documented in 5.0 Arguments to build-lisp-image 1: defaults inherited from the running image above since its default value is inherited from the running image. (In the first version of this document for ACL 5.0, this argument was incorrectly put in this table.)
:restart-init-function This argument is documented in 5.0 Arguments to build-lisp-image 1: defaults inherited from the running image above since its default value is inherited from the running image. (In the first version of this document for ACL 5.0, this argument was incorrectly put in this table.)
:runtime nil Value can be nil, :standard, or :dynamic. Must be nil unless you have a runtime license and have installed necessary functionality. (Standard runtime is included with enterprise editions of Allegro CL. Contact your sales representative for information on adding Allegro CL Runtime to a professional edition or Allegro CL Dynamic Runtime to a professional or enterprise edition.)

See runtime.htm for more information. See particularly the discussion in that document of what values other arguments (such as :include-compiler and :include-devel-env) must be.

Users upgrading from Allegro CL 4.3.x, note that runtime behavior and licensing have significantly changed.

:server-name nil Specifies X server from which to get fonts. Ignored if :generate-fonts is nil.
:show-window :showna Windows only.  The value of the :show-window keyword to run-shell-command, used to start the process to build the image being created. See the page for run-shell-command to see the other allowable values for this argument.
:splash-from-file nil Windows only. Allows specification of a splash bitmap file. If non-nil, the value must be a string naming a bitmap file.
:temporary-directory See text at right. Default value is architecture dependent. Temporary files created during the build will be stored in this directory, either the default or the specified location.
:us-government nil Must be specified t by any user employed by or acting on behalf of the United States Government. The only effect is to change the copyright banner to include language required by US copyright laws relating to US Government use. All other users can specify nil or leave unspecified. Only for the United States Federal Government. State and local governments in the United  States and all governmental entities outside the United States can specify nil or leave unspecified.
:user-shared-libraries nil Allows loading DLLs (Windows) or shared objects (.so or .sl, UNIX) files into the new image.
:verbose nil Causes informative messages to be printed while the image is created.
:wait nil Windows only. When non-nil, it requires the ACL Creating Image window to be manually closed. This allows the contents to be inspected before the window disappears.

Table note: Finding available memory addresses

To successfully allocate the heap, you will need to move the starting address of the Lisp heap to a location large enough to support a contiguous address range specified by the heap size you chose. If you evaluate the following forms in Allegro CL, a memory map of the current state of virtual memory on your machine will be printed (except on the IBM RS/6000 where the output file will say only that the information is not available):

(ff:defforeign 'memory-status-dump :entry-point "memory_status_dump")
(memory-status-dump "foo.xxx")

The output differs for different platforms, but in all (except the RS/6000) cases, a set of address ranges is provided showing what ranges are allocated.

On Windows, if the filename argument is 0, then the Console is used as output.

Permissions on Windows are shown in the last four characters in the output:

You will need to locate a large chunk of free memory and specify to excl:build-lisp-image as a starting address that will support your heap size.

7.0 Use of custom.cl

The file sys:custom.cl in the Allegro directory is loaded into the new image at the end of the building process but just before the files specified by :lisp-files are loaded. If you are running excl:generate-application, sys:custom.cl is loaded before the files specified by the (required) input-files argument are loaded.

8.0 Building an image to include patches

During the build, all patch files in <Allegro Directory>/update relevant to the products included in the image (as coded by the filenames) are loaded into the image during the build.

9.0 Comparison of build-lisp-image with version 4.3's build/install_lisp

For users moving from version 4.3.x of Allegro CL on Unix, here are the arguments to install_lisp and their excl:build-lisp-image equivalents if any.

Install_lisp argument Equivalent (or nearly) build-lisp-image argument Comments
binary= The required image-name argument NONE
case_mode= :case-mode NONE
CC= NONE CC= specified the C compiler to use to build the Lisp image. C compilers are no longer necessary.
clim2=

clim2xm=

:include-clim NONE
composer= :include-composer NONE
compiler= :include-compiler

:discard-compiler

If :include-compiler is t, the compiler will be present during the build. If :discard-compiler is t, the compiler will be discarded at the end of the build. If :discard-compiler is nil and :include-compiler is t, the compiler will be present in the new image. This ability to have the compiler during the build and discard it later allows better control while building specialized images. It was not an option in 4.3.x.
config_debug= :debug-on-error Not precisely equivalent. config_debug=yes caused the 4.3.x build process to print much more information on what it is doing while it did it but there was no interactive component. :debug-on-error allows interactive debugging.
debug= :opt-debug NONE
devel= :include-devel-env NONE
dst= :dst NONE
estimated_max_heap_size= :lisp-heap-size NONE
ffhole= :c-heap-size NONE
:generate_fonts= :generate-fonts NONE
gov_flags= :us-government NONE
home= NONE Lisp home is the location of the lisp executable file (lisp.exe on Windows, lisp on Unix) or the value of –H command line argument. No value is stored in image in 5.0.
ics= NONE International character set Lisp is a separate product. Start with an ICS image to build an ICS image.
initial_oldspace= NONE Changes in build process make this argument (which specified an initial oldspace size to be modified to oldspace= at the end of the build process) unnecessary.
lso_file= :pll-file Note the file extension (type) change from lso to pll.
main_obj= NONE See main.htm for information on using your own main().
newspace= :newspace NONE
nis= NONE Changes in the implementation (essentially, the fact that the executable lisp.exe contains no data modified at runtime and the image is separate makes this argument unnecessary.
oldspace= :oldspace NONE
pure= :pll-file In 4.3.x, certain constants like code vectors could be placed in an lso file, in the image text section, or in the Lisp heap. In 5.0, such data can be placed in a pll file or in the Lisp heap (if :pll-file is nil). The text section can no longer be used.
restart_function= NONE The restart function is no longer supported. See :restart-app-function and :restart-init-function which provide similar functionality.
safety= :opt-safety NONE
server_name= :server-name NONE
speed= :opt-speed NONE
temp= :temporary-directory NONE
xcw= :include-xcw Common Windows (loaded by this argument) is no longer supported but is used by Composer. UNIX only.
xref= :load-xref-info   :record-xref-info NONE
+presto :presto NONE
+clean NONE This argument cleaned up certain files in build/. New procedure means no files are written except temporarily and those are cleaned automatically.
*.fasl :lisp-files NONE
*.o NONE :use-shared-libraries provides similar functionality. Also see main.htm.
*.so :use-shared-libraries NONE
*.a NONE Only shared object libraries (dll's on Windows, .so and .sl files on Unix) are supported.
*.cvs NONE Build a pll file with cvdcvt. See miscellaneous.htm.

10.0 Minimal top levels

When building a lisp image, specifying nil for include-tpl will cause a greatly reduced top-level functionality to be built into the lisp. The sole purpose of this minimal top-level is to reduce the space used by the full top-level. Applications which do not require a top-level or which provide their own will often specify include-tpl nil. The minimal top level described here will be available in such images.

The entire text of the minimal top level functionality is given below. Note that this code is loaded only if include-tpl is nil. The top-level code when include-tpl is non-nil is quite different.

(defpackage :top-level
  (:nicknames :tpl)
  (:use :common-lisp :excl)
  (:import-from :excl excl::read-eval-print-loop)
  ;; These are the function handlers for the top-level commands.
  ;; They are user visible.
  (:export #:*read-eval-print-loop*	; user-defined read-eval-print-loop
	   #:*read*			; the top-level reader
	   #:*eval*			; the top-level evaler
	   #:*print*			; the top-level printer
	   ))
(provide :tpl-user)
(in-package :top-level)
;; simple default tpl handlers:
(defvar *read-eval-print-loop* 'default-read-eval-print-loop)
(setq *read* 'read)
(setq *eval* 'eval)
(setq *print* 'print)
(defvar *start-hooks* nil)
(declaim (special *break-level*))
(setq *break-level* 0)
(defun start-interactive-top-level (*terminal-io*
				    function args
				    &key initial-bindings
				    &aux vars vals)
  (declare (:discard-source-file-info))
  (setf (getf (excl::stream-property-list *terminal-io*) 'initial-listener)
    sys::*current-process*)
  ;; Compute the list of special variables and bindings for progv.
  (dolist (b initial-bindings)
    (unless (member (car b) vars :test #'eq)
      (push (car b) vars)
      (push (eval (cdr b)) vals)))
  (progv vars vals
    (setq vars nil vals nil)		;free up space
    (apply function args)))

(defun top-level-read-eval-print-loop ()
  (declare (:discard-source-file-info))
  (loop
    (setq *evalhook* nil *applyhook* nil)
    (catch ':top-level-reset (read-eval-print-loop :level 0))
    ))
(defun read-eval-print-loop (&key &allow-other-keys)
  (declare (:discard-source-file-info))
  (let (pop-type cval1 cval2)
    (loop
      (multiple-value-setq (pop-type cval1 cval2)
	(catch 'top-level-break-loop
	  (funcall *read-eval-print-loop*)))
      ;; If we get here and pop-type is not null, then a throw
      ;; to 'top-level-break-loop was done (by a different toplevel)
      (case pop-type
	((:pop :debug-pop)
	 (when (plusp cval1)
	   (excl::funcall-in-package :debug-pop :debugger
				     nil (1- cval1) (1- cval2))))
	(error "user toplevel can't handle this pop type: ~s" pop-type)))))
(defun default-read-eval-print-loop ()
  (loop
    ;; print the prompt
    (fresh-line *terminal-io*)
    (princ "// " *terminal-io*)
    (let* ((exp (funcall *read*))
	   (res (funcall *eval* exp)))
      (funcall *print* res))))

10.1 Using the default minimal top-level

The minimal top-level is set up by default to issue a "//" prompt.  It only accepts lisp evaluable expressions as "commands", and does not interpret any other top-level
commands.

Example on a sparc:

% lisp -I umsloadxcomp.dxl -qq
Loading /release/duane/acl50/src/libacl50pf23.so.
Mapping umsloadxcomp.dxl...done.
Mapping umclxcomp.pll.
Allegro CL 5.0.pre-final.23 [SPARC] (8/10/98 16:40)
Copyright (C) 1985-1998, Franz Inc., Berkeley, CA, USA.  All Rights Reserved.
// (room)
area  address(bytes)        cons        symbols        other bytes
                        8 bytes each  24 bytes each
                        (free:used)   (free:used)      (free:used)
Top #x81dc000
New #x8180000(376832)     918:3158      254:0         246536:37944
New #x8124000(376832)      -----         -----            -----
Old #x8000c40(1192896)    781:15523     135:5628      518896:397344
Root pages: 34
Lisp heap limit: 67108864
NIL 
// (exit)
; Exiting Lisp
%

10.2 Requiring the normal top-level in a minimal top-level lisp

If the power of the normal top-level is needed after a (non-runtime) minimal top-level lisp is built, :toplevel can be required. However, simply requiring :toplevel is not enough to start the regular top-level listener; instead, the listener must be invoked recursively, either by an error or by any command (such as cl:inspect) that starts a new listener level. At that time, top-level commands (such as :zoom, etc) can be invoked.

Note however that when :toplevel is required, the read-eval-print-loop is re-set, and so a :reset command will make it appear as if the Lisp had always had a normal top-level.

Example1:

;; In this example, an error can be debugged after the fact by requiring
;; the normal top-level.
% lisp -I umsloadxcomp.dxl -qq
Loading /release/duane/acl50/src/libacl50pf23.so.
Mapping umsloadxcomp.dxl...done.
Mapping umclxcomp.pll.
Allegro CL 5.0.pre-final.23 [SPARC] (8/10/98 16:40)
Copyright (C) 1985-1998, Franz Inc., Berkeley, CA, USA.  All Rights Reserved.
// (require :toplevel)
; Fast loading /release/duane/acl50/src/code/toplevel.fasl
;   Fast loading /release/duane/acl50/src/code/frame.fasl
;     Fast loading /release/duane/acl50/src/code/r/rframe.fasl
T 
// a
Error: Attempt to take the value of the unbound variable `A'.
  [condition type: UNBOUND-VARIABLE]
Restart actions (select using :continue):
 0: Try evaluating A again.
 1: Use :A instead.
 2: Set the symbol-value of A and use its value.
 3: Use a value without setting A.
[1] USER(1): :zo
; Autoloading for TOP-LEVEL::ZOOM-COMMAND:
; Fast loading /release/duane/acl50/src/code/tpl-debug.fasl
; Autoloading for package "DEBUGGER":
;   Fast loading /release/duane/acl50/src/code/debug.fasl
Evaluation stack:
 ->(EXCL::INTERNAL-INVOKE-DEBUGGER "Error" #<UNBOUND-VARIABLE @ #x81b9f8a> ...)
   (ERROR #<UNBOUND-VARIABLE @ #x81b9f8a>)
   (SYS::..CONTEXT-SAVING-RUNTIME-OPERATION)
   (EVAL A)
   (TPL:TOP-LEVEL-READ-EVAL-PRINT-LOOP)
   (TPL:START-INTERACTIVE-TOP-LEVEL #<BIDIRECTIONAL-TERMINAL-STREAM [initial terminal io] fd 0/1 @ #x80439ba>
                                    #<Function TOP-LEVEL-READ-EVAL-PRINT-LOOP @ #x804d22a> ...)
(to see any ghost frames, the disassembler must be loaded)
[1] USER(2): :res
USER(1): 

Example 2:

;; Note in this example a variable is inspected after setting it,
;; to indicate the state of the lisp before the new top-level is
;; pulled into the lisp.  Note also that we wrap a progn which will
;; return a final nil value, so as not to see a huge printout due to
;; the lack of *print-level*/*print-length* controls.
% lisp -I umsloadxcomp.dxl -qq
Loading /release/duane/acl50/src/libacl50pf23.so.
Mapping umsloadxcomp.dxl...done.
Mapping umclxcomp.pll.
Allegro CL 5.0.pre-final.23 [SPARC] (8/10/98 16:40)
Copyright (C) 1985-1998, Franz Inc., Berkeley, CA, USA.  All Rights Reserved.
// (progn (setq x (excl::get-objects 7)) nil)
NIL 
// (require :toplevel)
; Fast loading /release/duane/acl50/src/code/toplevel.fasl
;   Fast loading /release/duane/acl50/src/code/frame.fasl
;     Fast loading /release/duane/acl50/src/code/r/rframe.fasl
T 
// (inspect x)
; Autoloading for INSPECT:
; Fast loading /release/duane/acl50/src/code/inspect.fasl
A simple T vector (5649) @ #x81a506a
   0-> fixnum 5629 [#x000057f4]
   1-> The symbol CL:NIL
   2-> The symbol T
   3-> The symbol EXCL::ER-WNAERR
   4-> The symbol EXCL::ER-GENERAL-ERROR-HANDLER-ZERO
   5-> The symbol EXCL::ER-GENERAL-ERROR-HANDLER-ONE
   6-> The symbol EVAL
   7-> The symbol EXCL::INTERPRETED-FUNCALL
   8-> The symbol EXCL::+_2OP
   9-> The symbol EXCL::GC-AFTER
  10-> The symbol EXCL::*WITHOUT-INTERRUPTS*
  11-> The symbol EQUAL
  12-> The symbol *PACKAGE*
  13-> The symbol *LISP-PACKAGE*
  14-> The symbol *KEYWORD-PACKAGE*
  15-> The symbol EXCL::INTERN*
  16-> The symbol EXCL::FASL-FIND-PACKAGE
  17-> The symbol EXCL::CONVERT-TO-INTERNAL-FSPEC
  18-> The symbol *COMPILER-PACKAGE*
  19-> The symbol *SYSTEM-PACKAGE*
  20-> The symbol EXCL::CONVERT-TO-EXTERNAL-FSPEC
  21-> The symbol SYS::LISP-BREAKPOINT
  22-> The symbol EXCL::HANDLE-PENDING-SIGNAL
  23-> The symbol EXCL::SET-FUNCTION
  24-> The symbol EXCL::.INV-MACRO-FUNCTION
   ...
 5648-> The symbol NIL
[1i] USER(1): 

10.3. Top-level variables

The following variables are maintained or used by the minimal top-level:

Variable Notes
tpl:*read* Must be non-nil - the function to be used to read top-level input. Initially set to cl:read.
tpl:*eval* Must be non-nil - the function to be used to evaluate top-level input. Initially set to cl:read.
tpl:*print* Must be non-nil - the function to be used to print top-level input. Initially set to cl:print.
tpl:*read-eval-print-loop* Must be non-nil - the function to be used as the read-eval-print-loop. Initially set to the tpl::default-read-eval-print-loop as shown in the code above, where tpl::default-read-eval-print-loop is also defined. This variable only exists in minimal top-level lisps. This variable does not have a separate descriptions page.

If tpl:*read-eval-print-loop* is set to a value other than tpl::default-read-eval-print-loop, then the three read/eval/print variables are not used. Normally, this variable should not be set unless it is desired to remove all possible user interaction with lisp. If a replacement top-level is supplied, it is recommended that all possible errors be handled explicitly with handlers.

The top-level variables in the table with links are also discussed in 9.0 Top-level variables in top_level.htm.

Copyright (C) 1998-1999, Franz Inc., Berkeley, CA. All Rights Reserved.