Reputation: 16748
I am compiling a Lua script into a binary on MacOS Catalina.
luac -s -o bin/my-binary.luac src/my-code.lua"
However, the application consuming the compiled script runs a 32-bit version of Lua and can't read the bytecode of the 64-bit compiled Lua script. (Error message: bad header in precompiled chunk).
Can I somehow (cross)compile the Lua script on current MacOS to a 32-bit binary? My alternative would be doing the compilation with Docker but maybe there is an even simpler approach.
Upvotes: 2
Views: 610
Reputation: 26754
I don't see any option for cross-compilation or changing the bitness, but you may be able to tweak the Lua code to produce the code you need. Here is the maillist thread for Lua 5.1 that recommends using #define LUAC_STR_SIZE_TYPE int
.
If this doesn't work, you may be able to change ldump.c
to produce 32-bit compatible code. The source code has the following comment (5.4): All high-level dumps go through dumpVector; you can change it to change the endianness of the result
. You may be able to update it to change bitness by changing handling of DIBS
, dumpSize
, and several other places.
Upvotes: 2