[SOLVED] Luajit: how to I "luajit -b <some_file>" so that love2d on Android would understand the format?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

[SOLVED] Luajit: how to I "luajit -b <some_file>" so that love2d on Android would understand the format?

Post by 4aiman »

Hello everyone!

I wonder if there is someone who can explain me if that's possible to create a raw bytecode for ARM on a Linux desktop?
The help mentions that -a (or arch) parameter can be used to supply a target arch, but I've found no examples of how to specify ARM.

I've tried to supply at least something so that luajit would throw some exception and an explanation, but both

Code: Select all

luajit -b conf.lua conf.txt -a arm
luajit -b conf.lua conf.txt2
generate same bytecode w/o any errors shown to me.

Is it even possile?
Last edited by 4aiman on Sun Oct 30, 2016 10:10 pm, edited 2 times in total.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Luajit: How to make bytecode for ARM in Linux x64?

Post by raidho36 »

Lua bytecode is executed by Lua's interpreter. It's always the same. LuaJIT compiles bytecode into native assembly instructions.
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Luajit: How to make bytecode for ARM in Linux x64?

Post by ivan »

Just a small note on the terminology:
"bytecode" are the instructions that run on a virtual machine/interpreter like Lua, Java, etc
"assembly" is what you probably mean, and refers to the instructions that run on a physical processor.

In my experience,Lua code can be profiled and optimized to run really fast.
I'll go out on a limb and say that you're approaching this problem incorrectly -
don't worry if LuaJIT can be optimized to run faster - it already runs pretty darn fast.

I would expect that per-compiling Lua code may only improve loading times (not the execution).
Again, you need profiling before trying to optimize anything.
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Re: Luajit: How to make bytecode for ARM in Linux x64?

Post by 4aiman »

Are you saying I should rename the thread?
Still, LuaJIT-enabled Love2d on Android tells me that the bytecode generated by luajit is incompatible.
So, the confusion is originated from there.

I don't want to optimize anything :)
I want 3 things: smaller size (saves me 1-2 MBytes), faster loading time (it's not that much, but there is some difference on low-end HW) and code obfuscation (as a way to make cheating at least a bit more difficult).

I've figured it out (possibly wrong) that will take me to pre-compile a bunch of *.lua files with luajit, make *.love out of those, and use that *.love within love2d on Android.
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Luajit: How to make bytecode for ARM in Linux x64?

Post by slime »

User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Re: Luajit: How to make bytecode for ARM in Linux x64?

Post by 4aiman »

So... If I compile love2d for android with luajit 2.0 OR desktop love2d with luajit 2.1 then the result (some_file2.lua) of

Code: Select all

luajit -b some_file.lua some_file2.lua
will run on both my desktop and my android device?
Fuzzlix
Citizen
Posts: 60
Joined: Thu Oct 13, 2016 5:36 pm

Re: Luajit: How to make bytecode for ARM in Linux x64?

Post by Fuzzlix »

4aiman wrote:So... If I compile love2d for android with luajit 2.0 OR desktop love2d with luajit 2.1 then the result (some_file2.lua) of

Code: Select all

luajit -b some_file.lua some_file2.lua
will run on both my desktop and my android device?
no.
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Re: Luajit: How to make bytecode for ARM in Linux x64?

Post by 4aiman »

Then how do I "luajit -b <some_file>" so that love2d on Android would understand the format?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Luajit: how to I "luajit -b <some_file>" so that love2d on Android would understand the format?

Post by bartbes »

My version of luajit lacks any options for cross-"compiling". You may have to either build a luajit that can, or if that's impossible, build an arm version of luajit, then use that to compile to bytecode. If you wanted to, you could even write some love code to dump all of your files to the save dir, since that already has an arm version of luajit.
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Re: Luajit: how to I "luajit -b <some_file>" so that love2d on Android would understand the format?

Post by 4aiman »

Thanks for idea, bartbes!

I've found this after your hint: http://stackoverflow.com/questions/2944 ... e-bytecode.
Had no idea I can dump a file from within a file.

Guess, that will do just fine.
I'll mark this as solved.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 224 guests