5

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

luac
  • 51
  • 1
  • 2

4 Answers4

5

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.

Ross Light
  • 4,769
  • 1
  • 26
  • 37
  • You beat me to it. I was looking for that source but somehow failed to find that particular page. Bad googlefu for me today. :) – Stigma Oct 10 '10 at 16:35
2

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.

Stigma
  • 1,686
  • 13
  • 27
2

https://github.com/c0i/lua32

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

Jimmy KD
  • 633
  • 7
  • 14
0

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.

Doug Currie
  • 40,708
  • 1
  • 95
  • 119