5.4.23  Library Freezing

We have seen how to define a Mythryl library and compile it using Mythryl’s make function.

Using this approach, each time the make command is issued, all source files contributing to the library are checked and their last-modified times compared with the last-modified time of the library proper; if the compiled library code is out of date, the logically minimum amount of recompilation needed is done to reconstruct it.

This is exactly the behavior one wants during development, but scanning the source files does take time, and for production deployment of a library, say on an embedded Linux box with limited memory, one may not even want to have the source code around.

Mythryl supplies the freeze function for such production deployment. Freezing a library compiles it into a binary freezefile form in which the source code is no longer needed. When the Mythryl make command sees such a freezefile, it does not even look for the library sourcefiles, or even the library .lib file.

Continuing the previous example, here is how we would construct a freezefile for it:

    linux$ my

    eval:  make "factor.lib";
        src/app/makelib/main/makelib-g.pkg:   Running   .lib file    factor.lib
          parse/libfile-parser-g.pkg:   Reading   make   file   factor.lib                                            on behalf of <toplevel>
makelib/compilable/thawedlib-tome.pkg:   Parsing   source file   factor.api
makelib/compilable/thawedlib-tome.pkg:   Parsing   source file   factor.pkg
makelib/compilable/thawedlib-tome.pkg:   Parsing   source file   main.pkg
    .../compile/compile-in-dependency-order-g.pkg:   Compiling source file   factor.api                                              to object file   factor.api.compiled
    .../compile/compile-in-dependency-order-g.pkg:   Compiling source file   factor.pkg                                              to object file   factor.pkg.compiled
    .../compile/compile-in-dependency-order-g.pkg:   Compiling source file   main.pkg                                                to object file   main.pkg.compiled
        src/app/makelib/main/makelib-g.pkg:   New names added.

    eval:  freeze "factor.lib";
        src/app/makelib/main/makelib-g.pkg:   Running   .lib file    factor.lib
          parse/libfile-parser-g.pkg:   Reading   make   file   factor.lib                                            on behalf of <toplevel>
    .../compile/compile-in-dependency-order-g.pkg:   Loading                 factor.api
    .../compile/compile-in-dependency-order-g.pkg:   Loading                 factor.pkg
    .../compile/compile-in-dependency-order-g.pkg:   Loading                 main.pkg

       .../freezefile/freezefile-g.pkg:   Creating  library       factor.lib.frozen

    eval:  ^D

    linux$ ls -l
    -rw-r--r-- 1 cynbe cynbe    48 2009-03-09 02:19 factor.api
    -rw-r--r-- 1 cynbe cynbe   283 2009-03-09 02:19 factor.api.compiled
    -rw-r--r-- 1 cynbe cynbe   172 2009-03-09 02:28 factor.lib
    -rw-r--r-- 1 cynbe cynbe  5409 2009-03-12 13:57 factor.lib.frozen
    -rw-r--r-- 1 cynbe cynbe   488 2009-03-09 02:18 factor.pkg
    -rw-r--r-- 1 cynbe cynbe  1107 2009-03-09 02:18 factor.pkg.compiled
    -rw-r--r-- 1 cynbe cynbe  1161 2009-03-09 02:34 main.pkg
    -rw-r--r-- 1 cynbe cynbe  3391 2009-03-09 02:34 main.pkg.compiled

Here the new factor.lib.frozen library archive file logically replaces all the other files shown, including the four .compiled object code files, the .api and .pkg source files and the master factor.lib library definition file. All of these files may now be removed if desired.

To load the freezefile into Mythryl you still do make "factor.lib" but as long as factor.lib.frozen exists, makelib does not even look for the factor.lib file.

(Of course, as often as not, the factor library is listed as needed by some other .lib file and is pulled in automatically as part of the make without explicit mention on your part.)

To unfreeze the library, just remove the factor.lib.frozen file. Mythryl’s make will then revert to its usual behavior of checking all sourcefile timestamps and automatically recompiling as needed.

Comments and suggestions to: