The main advantages of pre-compiling chunks are: faster loading, protecting source code from user changes, and off-line syntax error detection. The binary files created by luac are portable to all architectures.
Pre-compiling does not imply faster execution because in Lua chunks are always compiled into bytecodes before being executed. luac simply allows those bytecodes to be saved in a file for later execution.
luac produces a single output file containing the bytecodes for all source files given. By default, the output file is named luac.out, but you can change this with the -o option.
You can use "-" to indicate stdin as a source file.
luac can also load and list binary files with the -u option.
Binary files produced by differents runs of luac (even in different machines) can be combined into one large file, using cat(1). The result is still a valid binary file and can be loaded with a single call to lua_dofile or dofile.
The internal format of the binary files produced by luac may change when a new version of Lua is released. We try to maintain compatibility even for binary files, but sometimes it cannot be done. So, save the source files of all Lua programs that you precompile.
-c compile (this is the default).
-u undump, i.e., load and list the given binary files. If no files are given, then luac undumps luac.out. Listing a binary file is useful to learn Lua's virtual machine. Listing is also useful to test the integrity of binary files: corrupted files will probably generate errors when undumped. To test without listing, use -q. For a thourough integrity test, use -t.
-d turn debugging on. Individual chunks may still control the generation of debug information with $debug and $nodebug. If debugging is on, then listings show the names of the local variables.
-D "name" predefine symbol name for conditional compilation. By default, luac does not predefine any symbols, not even the built-in functions.
-l produce a listing of the compiled bytecode for Lua's virtual machine. This is the default when undumping.
-n Save numbers in native format. By default, numbers are saved in text form, for maximum portability. Binary files with numbers in native format are slightly faster to load, but are not completely portable.
-o "filename" output to filename, instead of the default luac.out. The output file cannot be a source file.
-O optimize. Debug information is removed and duplicate constants are coalesced.
-p parse sources files but do not generate any output file. Used mainly for syntax checking.
-q quiet; produces no listing. This is the default when compiling.
-t perform a thourough integrity test when undumping. Code that passes this test is completely safe, in the sense that it will not break the interpreter. However, there is no guarantee that such code does anything sensible. (None can be given, because the halting problem is unsolvable.)
-U "name" undefine symbol name for conditional compilation.
-v print version information.
-V verbose; print the names of the source files as they are processed.
luac.out default output file