Internally, ml-build generates a temporary wrapper library containing a single call of SMLofNJ.exportFn as part of the library's module-initialization code. Once this is done, CM is started, CM.mk_standalone is invoked (with the main project description file, the generated wrapper library file, and the heap image name as arguments), and a bootlist file is written. If all these steps were successful, ml-build invokes the (bare) SML/NJ runtime with a special option, causing it to bootstrap using the bootlist file.
Each line of the bootlist file specifies one module to be linked into the final stand-alone program. The runtime system reads these lines one-by-one, loads the corresponding modules, and executes their initialization code. Since the last module has been arranged (by way of using the wrapper library from above) to contain a call of SMLofNJ.exportFn, initialization of this module causes the program's heap image to be written and the bootstrap procedure to terminate.