[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Cross-compiler
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 11 Aug 2008 23:09:04 -0300
> Attached are modified versions of ldump.c, lundump.h, and luac.c to
> allow for cross-compilation.
I haven't tested it but it's nice to see actual code...
> This code lets you specify:
> * the endianness of the target platform
> * the size of int as 8, 16, or 32 (no 64-bit support right now)
> * lua_Number as an int (8, 16, or 32 bits) or a float (32 or 64 bits)
When I thought once about adding support for cross-compilation in luac,
I intended to do it via a string like this one:
"I2,S4,NR4,EB"
which means that the target machine has 2-byte integers, 4-byte size_t,
number is 4-byte real, endianness is big-endian. A 32-bit machine with
longs could be
"I4,S4,NI4,EN"
Endianness here is "native", but any omitted spec means "native".
You get the idea...
This would simplify the interface between luac.c and ldump.c because luac.c
could simply hand that string to ldump.c and the DumpTargetInfo would not
have to be exposed. The DumpState would contain all that info.
Furthermore, we'd be able to collect a list of cross-compilation strings
for common platforms. And the strings are self-documented.
Now, do you intend to be able to load cross-compiled chunks in luac as
well, so that luac could output native chunks from those?
> ldump.c exports a new function called "luaU_dump_crosscompile" that
> works like luaU_dump except that it takes a DumpTargetInfo structure.
I'd call it luaU_xdump...
> luaU_dump_crosscompile supports different sizes of size_t but luac
> does not allow it to be set from the command line. Are there any
> targets where sizeof(int) is different from sizeof(size_t)?
Old DOS compilers used to have medium and large models, in which
sizeof(int) was different from sizeof(size_t), I guess, because
in large models one would be able to address "far" data.
--lhf