[vlc-devel] a pitfall when cross-compiling win32 build on 64bit machine
Naohiro KORIYAMA
nkoriyama at gmail.com
Wed Dec 14 09:51:51 CET 2011
2011/12/14 Rémi Denis-Courmont <remi at remlab.net>:
> Naohiro-san hello,
>
> On Wed, 14 Dec 2011 15:48:54 +0900, Naohiro KORIYAMA <nkoriyama at gmail.com>
> wrote:
>> I compile win32 build on OS X Lion.
>>
>> First, it seemed fine, but lua scripts didn't run at all.
>> I installed lua in /usr/local/bin, and it was built as 64bit
> application.
>> And, I found the following in the LUAC man page:
>> The binary files created by luac are portable only among architectures
>> with the same word size and byte order.
>
> Is that so? I thought it was only byte order.
At least on my case, byte order is the same, because my macbook air's
cpu is corei5(x86).
> Then it depends what "word size" is? Only long has a different size on
> x86-64 than on i386, while char, short, int and long long are same.
Difference between x86_64 and i386, long(4,8) and long double(12,16), maybe.
luac's header has size of size_t (long unsigned int 4,8).
If the size in header and the machine's sizeof(size_t) is different,
treated as "bad header".
luadump.c
/*
* make header
*/
void luaU_header (char* h)
{
int x=1;
memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
h+=sizeof(LUA_SIGNATURE)-1;
*h++=(char)LUAC_VERSION;
*h++=(char)LUAC_FORMAT;
*h++=(char)*(char*)&x; /* endianness */
*h++=(char)sizeof(int);
*h++=(char)sizeof(size_t);
*h++=(char)sizeof(Instruction);
*h++=(char)sizeof(lua_Number);
*h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
}
static void LoadHeader(LoadState* S)
{
char h[LUAC_HEADERSIZE];
char s[LUAC_HEADERSIZE];
luaU_header(h);
LoadBlock(S,s,LUAC_HEADERSIZE);
IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
}
>
>> Oops, that's it.
>> After I made luac 32bit version, and use it by "LUAC=luac32
>> ..../win32/configure.sh ...", lua scripts worked on win32 build.
>> I don't know about Linux 64bit environment, on
>> http://wiki.videolan.org/Win32Compile, there is no description about
>> it.
>
> I am not sure anybody ever tried to run the result.
>
> Unfortunately, there is no lua cross-compiler, so there is no easy way to
> fix this.
Yes.
On my case, only difference of word size, so I can easily act, using
32bit luac.
Anyway, I wonder how to switch luac 32bit and 64bit on windows nightly
builds if the environment are the same.
--
KORIYAMA, Naohiro
nkoriyama at gmail.com
More information about the vlc-devel
mailing list