← 返回命令列表

Linux command

luac 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Compile Lua script to bytecode

luac -o [output.luac] [script.lua]

Compile multiple scripts

luac -o [combined.luac] [script1.lua] [script2.lua]

Parse and syntax check only

luac -p [script.lua]

List compiled bytecode

luac -l [script.lua]

List with full debug info

luac -l -l [script.lua]

Strip debug info from output

luac -s -o [stripped.luac] [script.lua]

Show version

luac -v

说明

luac compiles Lua source code into bytecode. The compiled output loads faster and can be distributed without source code. Syntax checking with -p validates scripts without creating output. This is useful in build processes and CI pipelines to catch errors early. The listing option (-l) shows the bytecode instructions, helping understand Lua's virtual machine and debug compilation issues. Double -l adds local variable and upvalue information. Stripping debug info (-s) reduces file size but removes line numbers and local variable names, making debugging harder. Use for production deployment where size matters. Multiple input files combine into a single output chunk. When executed, each file's code runs in order. Bytecode format is version-specific and not portable between different Lua versions. Lua 5.1, 5.2, 5.3, and 5.4 have incompatible bytecode formats.

参数

-o _FILE_
Output compiled bytecode to file.
-l
List bytecode (use twice for more detail).
-p
Parse only, don't generate output.
-s
Strip debug information.
-v
Print version.
--
Stop handling options.

FAQ

What is the luac command used for?

luac compiles Lua source code into bytecode. The compiled output loads faster and can be distributed without source code. Syntax checking with -p validates scripts without creating output. This is useful in build processes and CI pipelines to catch errors early. The listing option (-l) shows the bytecode instructions, helping understand Lua's virtual machine and debug compilation issues. Double -l adds local variable and upvalue information. Stripping debug info (-s) reduces file size but removes line numbers and local variable names, making debugging harder. Use for production deployment where size matters. Multiple input files combine into a single output chunk. When executed, each file's code runs in order. Bytecode format is version-specific and not portable between different Lua versions. Lua 5.1, 5.2, 5.3, and 5.4 have incompatible bytecode formats.

How do I run a basic luac example?

Run `luac -o [output.luac] [script.lua]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -o _FILE_ do in luac?

Output compiled bytecode to file.