Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can 32bit Lua bytecode work on a 64bit system?

Can a compiled Lua file (32bit *.luac file) work on a 64 Bit system?

like image 616
luac Avatar asked Oct 10 '10 14:10

luac


2 Answers

To quote the luac man page:

The binary files created by luac are portable only among architectures with the same word size and byte order.

So the answer is no. (I've also tested this exact situation with a 32-bit and a 64-bit machine.) One thing you can do is ensure that your Lua interpreter is compiled for 32-bit (even on a 64-bit machine), and I believe Lua would accept it then.

like image 168
Ross Light Avatar answered Nov 15 '22 07:11

Ross Light


I lack the experience to back up my words, but I believe that as long as the 32-bit lua binary is used to run that compiled file, it should work. Or rather, a binary built with similar settings, given the fact Lua offers a fair few compiler options that would affect the output of .luac files and their internal structure.

In general, the rule is not to mix usage of lua executables with .luac files created by another lua executable, as the inner format is highly dependant on the way Lua binaries themselves are compiled.

So if you run it with the 32-bit Lua you created the .luac files with, the answer is yes. If you were to run it with a 64-bit Lua executable, it would be a pretty definite no.

like image 33
Stigma Avatar answered Nov 15 '22 08:11

Stigma