LUAC(1)

πŸ“¦
version 5.5.1 Β· 2 versions
, in arch rolling, centos-stream 10, centos-stream 9, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– LUAC(1) β€” the general commands manual, but make it cute πŸ’–

okay bestie, sit down, hydrate, because we're talking about luac, the Lua compiler πŸ‘‘


✨ NAME ✨

luac β€” the Lua compiler, no cap πŸŽ€


✨ SYNOPSIS ✨

luac [ options ] [ filenames ]

that's it. that's the whole vibe check. options, then filenames, go πŸ¦‹


✨ DESCRIPTION ✨

so luac is literally the Lua compiler. it takes programs written in the Lua programming language and translates them into binary files containing precompiled chunks that you can load and execute later. it's giving meal prep but for bytecode πŸ“

the main advantages of precompiling chunks are:

  • faster loading ⚑
  • protecting your source code from accidental user changes πŸ›‘οΈ
  • off-line syntax checking βœ…
and like, important β€” precompiling does not imply faster execution. in Lua, chunks are always compiled into bytecodes before being executed anyway. luac just lets those bytecodes be saved in a file for later execution. so it's not a speed hack, it's a storage situation, iykyk πŸ’…

also, precompiled chunks are not necessarily smaller than the corresponding source. nope. the main goal in precompiling is faster loading. periodt πŸ’œ

on the command line you can mix text files containing Lua source and binary files containing precompiled chunks, 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, fr fr 🫢

by default the output file is named luac.out, but you can change that with the -o option. your file, your rules πŸ’–

⚠️ 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, for the love of everything, make sure you save the source files of all Lua programs that you precompile 😭 keep the originals bestie, do not delete them 🌸

✨ OPTIONS ✨

  • -l β€” produce a listing of the compiled bytecode for Lua's virtual machine 🧚 listing bytecodes is genuinely useful if you wanna learn about Lua's virtual machine. if no files are given, then luac loads luac.out and lists its contents. use -l -l for a full listing πŸ‘‘
  • -o file β€” output to file, instead of the default luac.out. (you can use '-' for standard output, but not on platforms that open standard output in text mode 🫠) 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 πŸ’€
  • -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, then luac loads luac.out and tests its contents. no messages are displayed if the file loads without errors β€” silence is the success signal ✨
  • -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, tiny file, worse crime scenes πŸ”
  • -v β€” show version information πŸ’«
  • -- β€” stop handling options. that's the end of the option zone πŸ›‘
  • - β€” stop handling options and process standard input 🌈

✨ SEE ALSO ✨

  • lua(1) πŸ‘―
  • the documentation at lua.org πŸ“š

✨ DIAGNOSTICS ✨

error messages should be self explanatory. she tells you what's wrong, bestie, you just gotta read it πŸ™ˆ


✨ AUTHORS ✨

R. Ierusalimschy, L. H. de Figueiredo, W. Celes πŸ’œ the icons who made this whole thing happen, we thank them 🫢


and that's the whole page, gorgeous πŸ’… this was the $Date: 2011/11/16 13:53:40 $ edition of the general commands manual β€” yes that date is real, it's vintage, it's iconic, it's archival πŸŽ€ go compile something cute βœ¨πŸ¦‹πŸ‘‘