compilation - How to compile Lua scripts into a single executable, while still gaining the fast LuaJIT compiler? -
how can compile lua scripts single executable file, while gaining super fast performance benefits of luajit?
background:
- my lua scripts web application created (e.g. host http://example.com)
- my current technology stack nginx (web server), lua/luajit (language retrieve dynamic content)
- i have around 50+
.lua
files make web application (from models/views/controllers) - freebsd 9 operating system
for simplicity sake in deployment, i'd compile down of .lua scripts run web application down single executable.
is possible , how?
it appears lua official comes library called srlua
- what negatives compiling down .lua single executable (e.g. performance worse, etc)?
translate of lua source code files object files , put them in static library:
for f in *.lua; luajit -b $f `basename $f .lua`.o done ar rcus libmyluafiles.a *.o
then link libmyluafiles.a
library main program using -wl,--whole-archive -lmyluafiles -wl,--no-whole-archive -wl,-e
.
this line forces linker include object files archive , export symbols.
for example, file named foo.lua can loaded local foo = require("foo")
within application.
details -b
option can found on running luajit.
Comments
Post a Comment