lrc
The lrocket compiler (lrc) bundles and compiles Lua programs to several formats.
It’s typically invoked by specifying a single lua file that serves as entrypoint.
From thereon lrc automatically resolves any further lua files and modules based on require()
statements in the overall code.
Basic Command-Line Example
# results in the program `main` (or `main.exe` on Windows)
$ lrc main.lua
Target Support
At the moment lrc supports compiling into native executables, shared libraries (experimental), bundled lua files and C code representing either a native executable or a shared library.
If an output filename is given via the -o
-flag and the target format has not been specified via the --otype
-flag, it is derrived from the output file extension (e.g. .exe
for “executable” on Windows or no file extension on Linux or macOS).
The compilation can be tuned using several command line options. A full listing can be found below:
Module Search Options
Option |
Description |
---|---|
|
Lua search path |
|
C modules search path |
|
Static C module search path |
|
Exclude given module from search |
|
Explicitly include module |
|
Examine complex require statements when resolving modules |
The path options --path
, --spath
and --cpath
are used to specify where lrc should look for Lua-modules. They are processed in-order as written in the command-line. To for example priorize the static versions of native modules (.a / .lib), place the --spath
argument before --cpath
.
The syntax for the path-options is based on the standard Lua path syntax:
?
is a wildcard for the required module nameIndividual paths are seperated by
;
;;
is replaced by the Interpreter’s standard-paths
In addition, the suffix ??
can be used to append a standard Lua path pattern or expand the path into multiple paths. This is especially useful for --path
: e.g. lua/??
will be replaced by lua/?.lua;lua/?/init.lua
. For --cpath
and --spath
the library file extensions are chosen based on the current platform and toolchain (i.e. ?.so
, ?.a
, etc.).
The final search-paths calculated by lrc
can be observed by specifying --log-level=debug
.
Output Options
Option |
Description |
---|---|
|
Output filename |
|
Output file format |
|
Output file format |
|
Target lua version |
|
Add specified debugging information to the output target |
|
Enable optimizations |
|
Do not remove intermediate C code after compilation |
If any optimization is enabled, Lua-bytecode is embedded in the target binary instead of the source-code. To prevent the execution of strip
, enable the --debug
option and set it to one of the following options, which control which information is preserved inside the bundle to print stacktraces:
all
: Preserves the full filepath of all modulesproject
: Only preserves the relative filepaths of modules inside or below the project directory (use this option to keep filenames while hiding information about the build environment).module
: Drop all module filepaths, preserving only dot-separated module-names (same path as used forrequire
).
The newest installed Lua version is detected and linked against automatically. To specify a different version use the --lua-version
option.
Executable Options
Option |
Description |
---|---|
|
Copies required shared C libraries to the output directory |
|
Resolve dynamic dependencies of statically linked lua modules (.a) by scanning equally named dynamic modules (.so) |
|
Link against the dynamic variant of the Lua library (default is static) |
|
Link with /SUBSYSTEM:WINDOWS (or -mwindows for MinGW) |
Other options
Option |
Description |
---|---|
|
Show this help message and exit. |
|
Output a shell completion script for the specified shell. |
|
(dev) Log profiling stacktraces to this file (flamegraph format) |
|
Prints version and exits |
|
ascending: none (0), error, warn, info, debug |