8 raco demod: Demodularizing Programs
The raco demodularize command (usually used with the shorthand raco demod) takes a Racket module and flattens all of its dependencies into a single compiled module. A file "‹name›.rkt" is demodularized into "‹name›_rkt_merged.zo".
The demodularized ".zo" file can be run by passing it as an argument to the racket command-line program, or it can be turned into an executable with raco exe.
A large single module generated by the demodularizer may trigger size limits in the compiler that prevent whole-module optimizations. Set the PLT_CS_COMPILE_LIMIT environment variable to raise the limit, and check 'info logging at the 'linklet topic (e.g., set PLTSTDERR to info@linklet) for information about when compilation is restricted to smaller functions.
The raco demod command accepts these flags:
-o ‹file› —
writes the flattened module to ‹file› instead of "‹name›_‹ext›_merged.zo" for an input file "‹name›.‹ext›". -e ‹path› or --exclude ‹path› —
excludes the module in ‹path› from flattening, as well as all of its dependencies. -M or --compile-any —
flattens the module to machine-independent form, instead of recompiling the flattened module to the current platform and Racket virtual machine; the output generated with -M loads more slowly than a machine-specific form, but raco decompile can show the flattened module in a format that is closer to source. -r or --recompile —
(re)compiles the module to machine-dependent form after flattening; this mode is the default except on BC, where flattening can work in terms of bytecode files. --work ‹dir› —
uses ‹dir› to cache compiled modules in an intermediate form for flattening; using --work with the same ‹dir› for multiple uses of raco demod can greatly speed up demodularization, and since the cache is based on raco make, it works even with different input files or when modules to be flattened have changed since the last use of the cache. -g or --garbage-collect —
aggressively prunes definitions that are unreferenced on the assumption that the right-hand side of a definition has no side effect; due to that unchecked assumption, this conversion may not preserve the behavior of the input module.
Changed in version 1.10 of package compiler-lib: Added -M/--compile-any, --work, and support for Racket CS.