-
Notifications
You must be signed in to change notification settings - Fork 931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross-compiling 32 bit LuaJIT on a 64 bit host #664
Comments
IMHO Linux is better suited for embedded development and cross-compilation, anyway. And QEMU full system emulation ought to work on macOS, too. The underlying issue is complicated:
If anyone feels really, really adventurous, they could of course reuse the C parser from the FFI and add (limited) support for CPP to actually parse LuaJIT's own header files. Then compute the struct offsets for the target architecture and finally replace the DynASM-generated macros with their own. Definitely a challenging project. I'm tagging it as an enhancement, but closing now. If anyone really wants to dive into this and contribute a solution, they can request a reopen. |
Hi, thanks for the explanation. I understand why you don't consider it worthwhile to change this. I remember reading once about somebody who was using DWARF debug information to extract the struct layouts for FFI without running the code but since you already have a engine that calculates proper struct offsets from C declarations it seems like a good idea to reuse that. |
I managed to hack around it using a Linux VM, qemu-user-arm (because the Apple M1 truly does not support any 32bit code – it's no longer a macOS software issue) and copious amounts of rsyncing back-and-forth between macOS and the VM. It allows me to compile using all of my macOS cross toolchains using a single 32bit armhf buildvm binary. For some strange reason I sometimes find joy in such things. ;) But I was wondering if it could make sense to pre-build and ship the generated files for all the default configurations supported by LuaJIT. They are around 125k per arch (which is both a lot and almost nothing ;) but this would make the problem go away for many LuaJIT users (who neither modify the code nor customize the compilation options). |
That would mean shipping thousands of configurations: num(archs) * num(toolchains) * num(OS) * (2 ^ num(build_options)).That's not feasible. |
Yes, to ship every possible combination would not be possible. I was thinking about doing the actually existing ARCH*OS (no MIPS for Win32 for example – there should be a dozen or so, right?). The toolchains for a single (OS,ARCH) pair may have different ABIs (ARM softfp vs. hardfp comes to mind) but right now the |
LuaJIT only supports crosscompiling for a 32 bit target on a 32 bit host:
Unfortunately some platforms (macOS) dropped support for 32 bit binaries for several years now. Rosetta 2 (Apple's x86_64 to arm64 translation layer) also does not support 32 bit x86 binaries at all.
The easiest solution would be to stick to compiling on Linux which will probably support 32 bit mode for years to come (and QEMU will ensure user-mode emulation even when CPUs drop 32 bit support in hardware).
Another alternative would be to fix the underlying issue. Does anybody know what prevents LuaJIT from doing crosscompilation with differing word sizes? How difficult would it be to remove this restriction?
The text was updated successfully, but these errors were encountered: