LUAC5.2(1)
π LUAC5.2 β the luac page, bestie edition π
okay so you opened the General Commands Manual for luac, and honestly? you're in for a treat. sit down, grab a strawberry π, and let's get into it.
β¨ NAME β¨
luac β the Lua compiler. that's it, that's the whole name. short, sweet, iconic π
πΈ SYNOPSIS πΈ
luac [ options ] [ filenames ]
that's the vibe. options go in, filenames go in, bytecode comes out. slay.
π¦ DESCRIPTION π¦
so luac is the Lua compiler. what it does is take programs written in the Lua programming language and translate them into binary files containing precompiled chunks that you can later load and execute. it's giving "prep work done in advance so future-you doesn't have to" π
the main advantages of precompiling chunks are:
- faster loading β‘
- protecting source code from accidental user changes π
- off-line syntax checking β
but okay, real talk, bestie β precompiling does not imply faster execution. not me having to say this, but in Lua, chunks are always compiled into bytecodes before being executed, so luac isn't doing anything magical there. all it does is let those bytecodes be saved in a file for later execution. it's just storage, not speed. π
also, precompiled chunks are not necessarily smaller than the corresponding source. like, at all. the main goal in precompiling is faster loading. periodt.
so here's how the command line works: you can mix text files containing Lua source and binary files containing precompiled chunks β no cap, both are welcome π β and luac produces a single output file containing the combined bytecodes for all files given. executing the combined file is equivalent to executing the given files. very "all my friends in one group chat" energy, love that for us.
by default, the output file is named luac.out, but you can change this with the -o option. π
β οΈ okay this part matters: precompiled chunks are not portable across different architectures. and moreover, the internal format of precompiled chunks is likely to change when a new version of Lua is released. so please, PLEASE, make sure you save the source files of all Lua programs that you precompile. keep your receipts, bestie, you will need them π₯
π OPTIONS π
-lβ produce a listing of the compiled bytecode for Lua's virtual machine. listing bytecodes is useful to learn about Lua's virtual machine, so if you're nosy (respectfully) about how the VM works, this is your moment π§ if no files are given, thenluacloadsluac.outand lists its contents. and for the full experience, use-l -lfor a full listing β¨-o fileβ output to file, instead of the defaultluac.out. (you can use'-'for standard output, but not on platforms that open standard output in text mode β tragic, I know.) the output file may be one of the given files because all files are loaded before the output file is written. π be careful not to overwrite precious files. seriously. don't do it.-pβ load files but do not generate any output file. used mainly for syntax checking and for testing precompiled chunks: corrupted files will probably generate errors when loaded. if no files are given, thenluacloadsluac.outand tests its contents. no messages are displayed if the file loads without errors β silence is the flex π€«-sβ strip debug information before writing the output file. this saves some space in very large chunks, but if errors occur when running a stripped chunk, then the error messages may not contain the full information they usually do. in particular, line numbers and names of local variables are lost. π so like, weigh that tradeoff, bestie.-vβ show version information. simple. iconic. π--β stop handling options.-β stop handling options and process standard input. π«Ά
π SEE ALSO π
lua(1)- The documentation at lua.org. π
π DIAGNOSTICS π
error messages should be self explanatory. they said what they said.
π AUTHORS π
R. Ierusalimschy, L. H. de Figueiredo, W. Celes β the legends themselves, the main characters, the blueprint ππ
and that's the whole page! π this version was cooked up from the $Date: 2011/11/16 13:53:40 $ release, so big love to everyone behind it β go forth and precompile responsibly, bestie π¦β¨π
π¦ where this page comes from
- debian bookworm: lua5.2 5.2.4-3 Β· MIT
- debian trixie: lua5.2 5.2.4-3+b3 Β· MIT
- ubuntu jammy: lua5.2 5.2.4-2 Β· MIT
- ubuntu noble: lua5.2 5.2.4-3build2 Β· MIT
- ubuntu questing: lua5.2 5.2.4-3build2
- ubuntu resolute: lua5.2 5.2.4-4 Β· MIT
- ubuntu stonking: lua5.2 5.2.4-4 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms