Running Lua Bytecode
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 41
- Joined: Thu Sep 05, 2013 8:48 pm
Running Lua Bytecode
I'm using version 0.10.1 and cannot find the appropriate way to compile to byte code. Ive tried luac -o, and luajit -b for luajit version 2.0.5 as well as string.dump(love.filesystem.read(file)). None of these work. What's the full process for running and compiling Löve2D code to byte code?
-
- Party member
- Posts: 134
- Joined: Tue Mar 29, 2011 11:05 pm
Re: Running Lua Bytecode
luajit -b should work but I'm pretty sure you have to supply both the input file-name and the output filename otherwise you get nothing.
luajit -b main.lua main2.lua
should work, however you can also overwrite the file with
luajit -b main.lua main.lua
in which case you would lose the original source.
I've used this method in a batch file (win7) after I have copied the entire source folder to a secondary location, then apply the byte-code compiler to the files I need to, leaving the raw source folder completely untouched (because bad things will happen!).
How to run the file? Assuming the files have the same name as the raw source files, then Love2d/Luajit will just read it automatically regardless if it is plain source or byte-code, so you don't have to do anything else.
Therefore compiling to byte-code is completely unnecessary and not recommended unless you are doing so for specific reasons.
luajit -b main.lua main2.lua
should work, however you can also overwrite the file with
luajit -b main.lua main.lua
in which case you would lose the original source.
I've used this method in a batch file (win7) after I have copied the entire source folder to a secondary location, then apply the byte-code compiler to the files I need to, leaving the raw source folder completely untouched (because bad things will happen!).
How to run the file? Assuming the files have the same name as the raw source files, then Love2d/Luajit will just read it automatically regardless if it is plain source or byte-code, so you don't have to do anything else.
Therefore compiling to byte-code is completely unnecessary and not recommended unless you are doing so for specific reasons.
Last edited by drunken_munki on Mon Apr 03, 2017 9:09 pm, edited 1 time in total.
-
- Prole
- Posts: 41
- Joined: Thu Sep 05, 2013 8:48 pm
Re: Running Lua Bytecode
It's mostly for performance. I did what you said before and it's telling me the byte code is incompatible. Or its saying '=' expected near char(23)
-
- Party member
- Posts: 134
- Joined: Tue Mar 29, 2011 11:05 pm
Re: Running Lua Bytecode
Did you try luajit v2.0?
That version should be 100% compatible with lua 5.1 (that Love 0.10.x uses).
Otherwise I'm not sure
That version should be 100% compatible with lua 5.1 (that Love 0.10.x uses).
Otherwise I'm not sure
Re: Running Lua Bytecode
Performance does not improves with using bytecode - the whole "improvement" is a one-time minuscule fraction of a second boost when the script is loaded (because it doesn't need to be compiled into bytecode first), then there's no difference. LuaJIT bytecode is not machine code, when you load it Lua will execute it just the same and the JIT will compile it into native assembly instructions all over again anyway. Bytecode is much larger in file size all by itself and is less compressible than source code text, further increasing file size. Finally, the one valid reason to use bytecode being obfuscation (not performance), defeated by the fact that "disassembling" Lua bytecode into almost source-identical text is trivial - a minor inconvenience to would-be hacker, no obstacle.
-
- Prole
- Posts: 41
- Joined: Thu Sep 05, 2013 8:48 pm
Re: Running Lua Bytecode
I just built and tested with LuaJIT 2.0, same thing: "Incompatible byte code"
-
- Prole
- Posts: 32
- Joined: Thu Aug 28, 2014 8:38 am
- Location: Russia
- Contact:
Re: Running Lua Bytecode
Love2D Exporter (Soft)
Не следует обманывать инспектора (Love2D Game)
Новогодняя ёлка (Love2D Game)
Создание танка на движке Love2D (Love2D Tank, Article)
Love2D-Helpers (Tools)
Не следует обманывать инспектора (Love2D Game)
Новогодняя ёлка (Love2D Game)
Создание танка на движке Love2D (Love2D Tank, Article)
Love2D-Helpers (Tools)
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests