简体   繁体   中英

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

编译后的Lua文件(32位* .luac文件)可以在64位系统上工作吗?

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.

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.

You didn't say why you want to deliver compiled Lua files (source code can be smaller, and loads quite quickly). In any case, an alternative to raw source is squish .

https://github.com/c0i/lua32

just use 32-bit bytecode on all 32/64 Bit system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM