Re:Show HN: Luastatic – Build an executable from a Lua program
by camperman on Monday October 26, 2015 @10:23AM
(#10451611)
You can do this in Luajit with the following trick:
Where main-stub.c looks like this:
The executables produced are very small because you dynamically link to Luajit and statically link to your own Lua code. I have a full media scheduler running at 100 sites which is only 40k. And it runs like a demon on ARM too.
[ Parent
| on HN ]
Re:Show HN: Luastatic – Build an executable from a Lua program
by 0x01 on Monday October 26, 2015 @11:48AM
(#10452177)
That's a neat trick! Is there any reason you can't do this with luac? I tried the equivalent to what you're doing with luac, but gcc complains that "member libmylib.a(luafunc.o) in archive is not an object".
What's the difference between the bytecode generated by luajit compared to luac?
Re:Show HN: Luastatic – Build an executable from a Lua program
by camperman on Monday October 26, 2015 @01:40PM
(#10452946)
Luajit detects the kind of output file passed to the -b option, in this case .o, and writes the data accordingly. It's actually writing compiled architecture-specific object code here which can be linked into a static library. You can also pass it a .c or a .h extension to get c source or headers.
I think luac compiles to bytecode only.