Author Topic: Compiled Lua scripts and incompatibilities with different OS and Cpus  (Read 3357 times)

0 Members and 1 Guest are viewing this topic.

Offline PPK

  • Administrator
  • Emperor
  • *****
  • Posts: 1 481
  • Karma: +209/-22
  • PtokaX developer
Few weeks ago someone have problem with compiled script on 32bit system that was not working for unknown reason on 64bit version. I don't know why it was not working, but today on lua mailing list was some info about that problem. So here it is, why compiled lua script is not working on different OSes and Cpu architectures.
Precompiled chunks are dependant upon several factors:
* Lua version
* Endianness
* sizeof(int)
* sizeof(size_t)
* sizeof(Instruction) (which is typically a typedef onto lu_int32)
* lua_Number type
What that means ?
1) Lua script compiled with 32bit x86 lua should work with 32bit x86 PtokaX on windoze, linux or freebsd (that is where i know that PtokaX is working). It will not work with any 64bit amd64 version. On windoze because size_t have different sizes. On linux and freebsd because int and size_t have different sizes.
2 ) Lua script compiled with 64bit amd64 lua on windoze will work only with 64bit amd64 PtokaX on windoze. It will not work on 32bit version for same reasons as above. And it should not work on linux or freebsd because theyr int is 64bit when windoze have int always 32bit.
3 ) Lua script compiled with 64bit amd64 lua on linux or freebsd will work only with 64bit amd64 PtokaX on linux or freebsd. Again it will not work on 32bit and should not work on 64bit amd64 PtokaX on windoze.
Any other Oses or Cpu architectures probably have similar or more reasons why compiled script will not work ::)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

PtokaX forum