lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


* On 2014-04-11 13:11:40 +0200, Dirk Zoller wrote:
 
> we target many platforms with the software that embeds Lua.
> For some of them it is more practical to cross compile on another
> system than setting up and running the builds on the target.
> 
> A limitation I noticed seems to be that compiled Lua bytecode
> is not portable. So I have to run at least the luac on a machine
> that at least has the same byte-order and wordsize as the target.
> 
> This is a bit a pain, as we would otherwise host all compilers
> on one big box. Now we keep some extra build systems alive just
> for this which we could otherwise retire.
> 
> Anybody else struggling with this?
> Is a platform independent byte-code desirable?

I used to have a few patched lua versions around to produce bytecode for
various embedded platforms. These days I switched to compiling lua with
the appropriate cross compiler and run the platform specific luac with
the Qemu user emulator to compile lua source files for that particular
target.

With qemu it's possible to run a program for a different architecture
just as if it is running on the host. This is mips lua running on an
x86_64 linux machine:

$ uname -a
Linux lapdoos 3.9.0 #13 SMP PREEMPT Thu Nov 14 21:32:22 CET 2013 x86_64 GNU/Linux

$ file lua
lua: ELF 32-bit MSB executable, MIPS, MIPS32 version 1 (SYSV),
dynamically linked (uses shared libs), not stripped

$ qemu-mips ./lua
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> 

-- 
:wq
^X^Cy^K^X^C^C^C^C