Compile on x86, run on ARM?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Compile on x86, run on ARM?

Baker, Derek
Hi,

Is it possible to run compiled Lua on an architecture other than that
which it was compiled on? For instance, can I compile a lua script to
bytecode on an x86 platform and run the bytecode on an ARM platform?

I'm trying that now on a very simple script, and get the error:

    lua: unknown number format in test.byt

when trying to run it. This happens when compiling on x86 and trying to
run on ARM as well as compiling on ARM and trying to run on x86. All
running Linux, btw.

Thanks,
Derek
Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Stefan Schwarzbach
Hi Derek,

I'm not sure, but could there be a problem with the byte order of values
bigger than 8bits? Little endian vs. Big endian.
I'm not a lua developer so this is more a notice than an answer

Greetings,
Stefan


Baker, Derek schrieb:

> Hi,
>
> Is it possible to run compiled Lua on an architecture other than that
> which it was compiled on? For instance, can I compile a lua script to
> bytecode on an x86 platform and run the bytecode on an ARM platform?
>
> I'm trying that now on a very simple script, and get the error:
>
>    lua: unknown number format in test.byt
>
> when trying to run it. This happens when compiling on x86 and trying
> to run on ARM as well as compiling on ARM and trying to run on x86.
> All running Linux, btw.
>
> Thanks,
> Derek
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Brian Weed-2
In reply to this post by Baker, Derek
I think some ARM chips don't support float (or double).  Maybe that is
the problem.

Brian

Baker, Derek wrote:

> Hi,
>
> Is it possible to run compiled Lua on an architecture other than that
> which it was compiled on? For instance, can I compile a lua script to
> bytecode on an x86 platform and run the bytecode on an ARM platform?
>
> I'm trying that now on a very simple script, and get the error:
>
>    lua: unknown number format in test.byt
>
> when trying to run it. This happens when compiling on x86 and trying
> to run on ARM as well as compiling on ARM and trying to run on x86.
> All running Linux, btw.
>
> Thanks,
> Derek
>

Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Asko Kauppi
In reply to this post by Stefan Schwarzbach

I could easily help you with this.

ARM can be placed into both big and little endian mode; do you know  
which one you have?

-asko


Stefan Schwarzbach kirjoitti 6.2.2006 kello 19.44:

> Hi Derek,
>
> I'm not sure, but could there be a problem with the byte order of  
> values
> bigger than 8bits? Little endian vs. Big endian.
> I'm not a lua developer so this is more a notice than an answer
>
> Greetings,
> Stefan
>
>
> Baker, Derek schrieb:
>> Hi,
>>
>> Is it possible to run compiled Lua on an architecture other than that
>> which it was compiled on? For instance, can I compile a lua script to
>> bytecode on an x86 platform and run the bytecode on an ARM platform?
>>
>> I'm trying that now on a very simple script, and get the error:
>>
>>    lua: unknown number format in test.byt
>>
>> when trying to run it. This happens when compiling on x86 and trying
>> to run on ARM as well as compiling on ARM and trying to run on x86.
>> All running Linux, btw.
>>
>> Thanks,
>> Derek
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Baker, Derek
At the moment, we're running on an eval board, and no one seems to know
if it's little or big. Is there any way to tell using some Linux tool?

Thanks for you help.

Derek

Asko Kauppi wrote:

> I could easily help you with this.
>
> ARM can be placed into both big and little endian mode; do you know  
> which one you have?
>
> -asko
>
>
> Stefan Schwarzbach kirjoitti 6.2.2006 kello 19.44:
>
>  
>> Hi Derek,
>>
>> I'm not sure, but could there be a problem with the byte order of  
>> values
>> bigger than 8bits? Little endian vs. Big endian.
>> I'm not a lua developer so this is more a notice than an answer
>>
>> Greetings,
>> Stefan
>>
>>
>> Baker, Derek schrieb:
>>    
>>> Hi,
>>>
>>> Is it possible to run compiled Lua on an architecture other than that
>>> which it was compiled on? For instance, can I compile a lua script to
>>> bytecode on an x86 platform and run the bytecode on an ARM platform?
>>>
>>> I'm trying that now on a very simple script, and get the error:
>>>
>>>    lua: unknown number format in test.byt
>>>
>>> when trying to run it. This happens when compiling on x86 and trying
>>> to run on ARM as well as compiling on ARM and trying to run on x86.
>>> All running Linux, btw.
>>>
>>> Thanks,
>>> Derek
>>>
>>>
>>>      
Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

David Given
On Monday 06 February 2006 19:47, Baker, Derek wrote:
> At the moment, we're running on an eval board, and no one seems to know
> if it's little or big. Is there any way to tell using some Linux tool?

Try 'arch'.

--
+- David Given --McQ-+
|  [hidden email]    | "Home is where, when you have to go there, they
| ([hidden email]) | have to take you in." --- Cordelia Naismith
+- www.cowlark.com --+

Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Bennett Todd
In reply to this post by Baker, Derek
2006-02-06T19:47:48 Derek Baker:
> At the moment, we're running on an eval board, and no one seems to know
> if it's little or big. Is there any way to tell using some Linux tool?

I'm almost there, with one little problem. I don't know lua well
enough to do it there, so I'm doing it with perl.

; perl -le 'print((1<<24)+(2<<16)+(3<<8)+4)'
16909060
; perl -e 'print pack("N",16909060)'|od -b
0000000 001 002 003 004
0000004
; perl -e 'print pack("V",16909060)'|od -b
0000000 004 003 002 001
0000004
;

According to the doc in perldoc -f pack:

    N An unsigned long in "network" (big-endian) order.
    V An unsigned long in "VAX" (little-endian) order.

They look opposite to me, but sobeit. If the first octet printed by
od -b is 1, then it's big-endian, and if it's 4 then it's
little-endian (presuming they're all in ascending or descending
order, if they're scrambled then it's middle-endian).

So that's our test number. On PPC:

: minimac; perl -e 'print pack("I",16909060)'|od -b
0000000 001 002 003 004
0000004
: minimac;

On x86:

: pic; perl -e 'print pack("I",16909060)'|od -b
0000000 004 003 002 001
0000004
: pic;

-Bennett

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Matthew Percival
In reply to this post by Baker, Derek
G'Day,

> Is it possible to run compiled Lua on an architecture other than that
> which it was compiled on? For instance, can I compile a lua script to
> bytecode on an x86 platform and run the bytecode on an ARM platform?

        I compiled Lua on an x86 and run it on an ARM processor.  If you have
your arm-linux- toolchain already prepared, this is one of the easier
programs to crosscompile.  From recollection, all I did was
edit ./config so that everything was set up for Linux, and changed gcc
to arm-linux-gcc, then changed ln to arm-linux-ln in ./Makefile.  It was
a very pain-free process.

        -- Matthew

Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Taj Khattra
In reply to this post by Baker, Derek
> At the moment, we're running on an eval board, and no one seems to know
> if it's little or big. Is there any way to tell using some Linux tool?

the exit status of the program below should be 0 if little, 1 if big:

static union { int x; char endian; } little = { 1 };
main() { exit(!little.endian); }
Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Asko Kauppi
In reply to this post by Baker, Derek

-bash-2.05b$ uname -a
Linux kepponen 2.4.22-xfs #1 Sun Jun 12 21:17:17 PDT 2005 armv5b  
unknown unknown GNU/Linux

The 'b' is for big endian (NSLU2)

"The x86 architecture is little endian. Many ARM processors support  
either mode, but usually are used in little endian mode."
http://www.handhelds.org/minihowto/porting-software.html

-aka


Baker, Derek kirjoitti 6.2.2006 kello 21.47:

> At the moment, we're running on an eval board, and no one seems to  
> know
> if it's little or big. Is there any way to tell using some Linux tool?
>
> Thanks for you help.
>
> Derek
>
> Asko Kauppi wrote:
>> I could easily help you with this.
>>
>> ARM can be placed into both big and little endian mode; do you  
>> know  which one you have?
>>
>> -asko
>>
>>
>> Stefan Schwarzbach kirjoitti 6.2.2006 kello 19.44:
>>
>>
>>> Hi Derek,
>>>
>>> I'm not sure, but could there be a problem with the byte order  
>>> of  values
>>> bigger than 8bits? Little endian vs. Big endian.
>>> I'm not a lua developer so this is more a notice than an answer
>>>
>>> Greetings,
>>> Stefan
>>>
>>>
>>> Baker, Derek schrieb:
>>>
>>>> Hi,
>>>>
>>>> Is it possible to run compiled Lua on an architecture other than  
>>>> that
>>>> which it was compiled on? For instance, can I compile a lua  
>>>> script to
>>>> bytecode on an x86 platform and run the bytecode on an ARM  
>>>> platform?
>>>>
>>>> I'm trying that now on a very simple script, and get the error:
>>>>
>>>>    lua: unknown number format in test.byt
>>>>
>>>> when trying to run it. This happens when compiling on x86 and  
>>>> trying
>>>> to run on ARM as well as compiling on ARM and trying to run on x86.
>>>> All running Linux, btw.
>>>>
>>>> Thanks,
>>>> Derek
>>>>
>>>>
>>>>

Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Asko Kauppi
In reply to this post by Matthew Percival

Derek's issue was about compiled lua bytecode, not compiling Lua  
itself. :)

-asko


Matthew Percival kirjoitti 7.2.2006 kello 0.00:

> G'Day,
>
>> Is it possible to run compiled Lua on an architecture other than that
>> which it was compiled on? For instance, can I compile a lua script to
>> bytecode on an x86 platform and run the bytecode on an ARM platform?
>
> I compiled Lua on an x86 and run it on an ARM processor.  If you have
> your arm-linux- toolchain already prepared, this is one of the easier
> programs to crosscompile.  From recollection, all I did was
> edit ./config so that everything was set up for Linux, and changed gcc
> to arm-linux-gcc, then changed ln to arm-linux-ln in ./Makefile.  
> It was
> a very pain-free process.
>
> -- Matthew
>

Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Baker, Derek
In reply to this post by Asko Kauppi
# uname -a
Linux imx21 2.4.20-celf3 #2 Fri Apr 29 21:43:58 UTC 2005 armv5EJl unknown

So I think the "l" at the end of "armv5EJl" indicates little endian. Is
that correct?

Derek

Asko Kauppi wrote:

>
> -bash-2.05b$ uname -a
> Linux kepponen 2.4.22-xfs #1 Sun Jun 12 21:17:17 PDT 2005 armv5b
> unknown unknown GNU/Linux
>
> The 'b' is for big endian (NSLU2)
>
> "The x86 architecture is little endian. Many ARM processors support
> either mode, but usually are used in little endian mode."
> http://www.handhelds.org/minihowto/porting-software.html
>
> -aka
>
>
> Baker, Derek kirjoitti 6.2.2006 kello 21.47:
>
>> At the moment, we're running on an eval board, and no one seems to know
>> if it's little or big. Is there any way to tell using some Linux tool?
>>
>> Thanks for you help.
>>
>> Derek
>>
>> Asko Kauppi wrote:
>>> I could easily help you with this.
>>>
>>> ARM can be placed into both big and little endian mode; do you know  
>>> which one you have?
>>>
>>> -asko
>>>
>>>
>>> Stefan Schwarzbach kirjoitti 6.2.2006 kello 19.44:
>>>
>>>
>>>> Hi Derek,
>>>>
>>>> I'm not sure, but could there be a problem with the byte order of  
>>>> values
>>>> bigger than 8bits? Little endian vs. Big endian.
>>>> I'm not a lua developer so this is more a notice than an answer
>>>>
>>>> Greetings,
>>>> Stefan
>>>>
>>>>
>>>> Baker, Derek schrieb:
>>>>
>>>>> Hi,
>>>>>
>>>>> Is it possible to run compiled Lua on an architecture other than that
>>>>> which it was compiled on? For instance, can I compile a lua script to
>>>>> bytecode on an x86 platform and run the bytecode on an ARM platform?
>>>>>
>>>>> I'm trying that now on a very simple script, and get the error:
>>>>>
>>>>>    lua: unknown number format in test.byt
>>>>>
>>>>> when trying to run it. This happens when compiling on x86 and trying
>>>>> to run on ARM as well as compiling on ARM and trying to run on x86.
>>>>> All running Linux, btw.
>>>>>
>>>>> Thanks,
>>>>> Derek
>>>>>
>>>>>
>>>>>
Reply | Threaded
Open this post in threaded view
|

Re: Compile on x86, run on ARM?

Asko Kauppi

yes. :)

Which is weird since if you're having problems with x86 it's not the  
endian issue, then.

You might want to check the code actually giving that error; Lua  
source is fairly simple to grasp, unlike many other open source  
projects I've seen. Perhaps it's due to having only 3 major  
developers, who are quite feature cautious.

-asko


Baker, Derek kirjoitti 7.2.2006 kello 15.41:

> # uname -a
> Linux imx21 2.4.20-celf3 #2 Fri Apr 29 21:43:58 UTC 2005 armv5EJl  
> unknown
>
> So I think the "l" at the end of "armv5EJl" indicates little  
> endian. Is that correct?
>
> Derek
>
> Asko Kauppi wrote:
>>
>> -bash-2.05b$ uname -a
>> Linux kepponen 2.4.22-xfs #1 Sun Jun 12 21:17:17 PDT 2005 armv5b  
>> unknown unknown GNU/Linux
>>
>> The 'b' is for big endian (NSLU2)
>>
>> "The x86 architecture is little endian. Many ARM processors  
>> support either mode, but usually are used in little endian mode."
>> http://www.handhelds.org/minihowto/porting-software.html
>>
>> -aka
>>
>>
>> Baker, Derek kirjoitti 6.2.2006 kello 21.47:
>>
>>> At the moment, we're running on an eval board, and no one seems  
>>> to know
>>> if it's little or big. Is there any way to tell using some Linux  
>>> tool?
>>>
>>> Thanks for you help.
>>>
>>> Derek
>>>
>>> Asko Kauppi wrote:
>>>> I could easily help you with this.
>>>>
>>>> ARM can be placed into both big and little endian mode; do you  
>>>> know  which one you have?
>>>>
>>>> -asko
>>>>
>>>>
>>>> Stefan Schwarzbach kirjoitti 6.2.2006 kello 19.44:
>>>>
>>>>
>>>>> Hi Derek,
>>>>>
>>>>> I'm not sure, but could there be a problem with the byte order  
>>>>> of  values
>>>>> bigger than 8bits? Little endian vs. Big endian.
>>>>> I'm not a lua developer so this is more a notice than an answer
>>>>>
>>>>> Greetings,
>>>>> Stefan
>>>>>
>>>>>
>>>>> Baker, Derek schrieb:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Is it possible to run compiled Lua on an architecture other  
>>>>>> than that
>>>>>> which it was compiled on? For instance, can I compile a lua  
>>>>>> script to
>>>>>> bytecode on an x86 platform and run the bytecode on an ARM  
>>>>>> platform?
>>>>>>
>>>>>> I'm trying that now on a very simple script, and get the error:
>>>>>>
>>>>>>    lua: unknown number format in test.byt
>>>>>>
>>>>>> when trying to run it. This happens when compiling on x86 and  
>>>>>> trying
>>>>>> to run on ARM as well as compiling on ARM and trying to run on  
>>>>>> x86.
>>>>>> All running Linux, btw.
>>>>>>
>>>>>> Thanks,
>>>>>> Derek
>>>>>>
>>>>>>
>>>>>>