A question: Cross compilation feature

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

A question: Cross compilation feature


Dear eLua community,

I haven't used the cross-lua feature a lot. Just today it occurred
to me -- Apart from saving a few kilobytes on flash, is there a reason
for not running luac on bare metal? Has this been done before?

I'd like to use this feature but I'd like it if I can access the compiler
from the shell and save the luac.out on my /mmc.

I can implement this but is it the right way to go?

Best,
Raman
jschievink jschievink
Reply | Threaded
Open this post in threaded view
|

Re: A question: Cross compilation feature

Maybe a kind of chacheing system would be better? It could work like this: When a script is executed, the cache is checked for the compiled binary of that script. When the source was changed or the binary not found -> Compile the spurce code and save it in the cache folder.
If no SD is inserted, caching could be automatically disabled.
A similar system is used in PHP (called XCache I think) to speed up page serving.

- Jonas

>
> Dear eLua community,
>
> I haven't used the cross-lua feature a lot. Just today it occurred
> to me -- Apart from saving a few kilobytes on flash, is there a reason
> for not running luac on bare metal? Has this been done before?
>
> I'd like to use this feature but I'd like it if I can access the compiler
> from the shell and save the luac.out on my /mmc.
>
> I can implement this but is it the right way to go?
>
> Best,
> Raman
>
>
>
> --
> View this message in context: http://elua-development.2368040.n2.nabble.com/A-question-Cross-compilation-feature-tp7577699.html
> Sent from the eLua Development mailing list archive at Nabble.com.
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
raman raman
Reply | Threaded
Open this post in threaded view
|

Re: A question: Cross compilation feature


Dear Jonas,

> Maybe a kind of chacheing system would be better? It could work like this:
> When a script is executed, the > cache is checked for the compiled binary
> of that script. When the source was changed or the binary not found ->
> Compile the spurce code and save it in the cache folder.
> If no SD is inserted, caching could be automatically disabled.
> A similar system is used in PHP (called XCache I think) to speed up page serving.

I was thinking of something simpler. I was wondering -- if you can compile luac with the
toolchain you use for your board (with eLua), the bytecode should also get executed
without issues on the same MCU -- just like a native compiler. With this, you don't have
to deal with endianness or variable size.

Best,
Raman



BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: A question: Cross compilation feature

In reply to this post by raman
Hi,

On Thu, Sep 27, 2012 at 12:41 AM, raman <[hidden email]> wrote:
>
> Dear eLua community,
>
> I haven't used the cross-lua feature a lot. Just today it occurred
> to me -- Apart from saving a few kilobytes on flash, is there a reason
> for not running luac on bare metal? Has this been done before?

You could run luac on bare metal. However, I personally fail to see
the benefits of this.

>
> I'd like to use this feature but I'd like it if I can access the compiler
> from the shell and save the luac.out on my /mmc.
>
> I can implement this but is it the right way to go?

Once agian, what are the benefits? WIth cross compilation you get a
set of goodies:

- reduced memory consumption on target (since the Lua parser can
apparently eat quite a bit of memory)
- if you save the resulting bytecode file in ROMFS, you automatically
enable a bunch of memory optimizations (like reading bytecode directly
from flash and pseudo R/O strings).

Best,
Bogdan

>
> Best,
> Raman
>
>
>
> --
> View this message in context: http://elua-development.2368040.n2.nabble.com/A-question-Cross-compilation-feature-tp7577699.html
> Sent from the eLua Development mailing list archive at Nabble.com.
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: A question: Cross compilation feature

In reply to this post by raman
On 26 September 2012 23:41, raman <[hidden email]> wrote:
> I haven't used the cross-lua feature a lot. Just today it occurred
> to me -- Apart from saving a few kilobytes on flash, is there a reason
> for not running luac on bare metal? Has this been done before?
>
> I'd like to use this feature but I'd like it if I can access the compiler
> from the shell and save the luac.out on my /mmc.
>
> I can implement this but is it the right way to go?

The Lua interpreter already has the compiler to bytecode inside it.
Implementing a shell command to parse a source file and dump the
bytecode instead of executing it shouldn't be too hard.

Bogdan: I assume the advantage is slightly faster startup time for
repeated runs, and the ability to develop code on the board itself.

    M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
raman raman
Reply | Threaded
Open this post in threaded view
|

Re: A question: Cross compilation feature


Dear Martin, dear Bogdan,

Sorry for the late reply.

> The Lua interpreter already has the compiler to bytecode inside it.
> Implementing a shell command to parse a source file and dump the
> bytecode instead of executing it shouldn't be too hard.

Certainly Martin. I have already implemented this. I can now use luac
from the eLua shell. I'm using this quite frequently now.

> Bogdan: I assume the advantage is slightly faster startup time for
> repeated runs, and the ability to develop code on the board itself.

Bogdan: Like Martin said, I think it gives the possibility of doing
development on the board. Second: Personally, I'd like to avoid having
to constantly eject the memory card, move files into it and put it back
for every luac invocation. I thought it was just a bit more convenient.

Best,
Raman

Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: A question: Cross compilation feature

On 15/10/2012, raman <[hidden email]> wrote:

> Certainly Martin. I have already implemented this. I can now use luac
> from the eLua shell. I'm using this quite frequently now.

It sounds like a useful addition. "Patches are welcome" :)

>> Bogdan: I assume the advantage is slightly faster startup time for
>> repeated runs, and the ability to develop code on the board itself.
>
> Bogdan: Like Martin said, I think it gives the possibility of doing
> development on the board. Second: Personally, I'd like to avoid having
> to constantly eject the memory card, move files into it and put it back
> for every luac invocation. I thought it was just a bit more convenient.

What do you use for a text editor? Don't tell me you're using lua-ed :-O

    M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
raman raman
Reply | Threaded
Open this post in threaded view
|

Re: A question: Cross compilation feature


>> Certainly Martin. I have already implemented this. I can now use luac
>> from the eLua shell. I'm using this quite frequently now.

> It sounds like a useful addition. "Patches are welcome" :)

Perfect. I'll send you a patch soon.

>>> Bogdan: I assume the advantage is slightly faster startup time for
>>> repeated runs, and the ability to develop code on the board itself.
>>
>> Bogdan: Like Martin said, I think it gives the possibility of doing
>> development on the board. Second: Personally, I'd like to avoid having
>> to constantly eject the memory card, move files into it and put it back
>> for every luac invocation. I thought it was just a bit more convenient.

> What do you use for a text editor? Don't tell me you're using lua-ed :-O
I haven't tried lua-ed yet. Can my LM3S crunch this without giving me
"out of memory" messages? I'm sure this is nothing for a Mizar :)

I'll give this try soon.

Best,
Raman
Marcelo Politzer Marcelo Politzer
Reply | Threaded
Open this post in threaded view
|

Re: A question: Cross compilation feature

In reply to this post by raman


2012/10/15 raman <[hidden email]>

Dear Martin, dear Bogdan,

Sorry for the late reply.

> The Lua interpreter already has the compiler to bytecode inside it.
> Implementing a shell command to parse a source file and dump the
> bytecode instead of executing it shouldn't be too hard.

Certainly Martin. I have already implemented this. I can now use luac
from the eLua shell. I'm using this quite frequently now.

> Bogdan: I assume the advantage is slightly faster startup time for
> repeated runs, and the ability to develop code on the board itself.

Bogdan: Like Martin said, I think it gives the possibility of doing
development on the board. Second: Personally, I'd like to avoid having
to constantly eject the memory card, move files into it and put it back
for every luac invocation. I thought it was just a bit more convenient.

 
Another option is to use the `recv /mmc/your_file.lc' to transfer files to the SD card.

Best,
Raman





--
View this message in context: http://elua-development.2368040.n2.nabble.com/A-question-Cross-compilation-feature-tp7577699p7577711.html
Sent from the eLua Development mailing list archive at Nabble.com.
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev



--
Best,
Marcelo


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
raman raman
Reply | Threaded
Open this post in threaded view
|

Re: A question: Cross compilation feature

In reply to this post by Martin Guy

Dear Martin, dear eLua community,

I have the patch for compiling Lua programs with luac
on the eLua terminal. Please look for attachment.

luac by default will create luac.out in /mmc. The regular
(desktop) luac command line options can be used on the
eLua terminal with no exceptions.

To enable this, you must specify an additional parameter
in the scons build syntax -- 'luac=1' ('luac=0' by default)

Example:
scons cpu=lm3s8962 toolchain=codesourcery luac=1
prog

With this, you can invoke luac from your eLua terminal.
Please note: If you choose not to include luac in the eLua
build, you will still have cross-lua which can be built with
the regular scons syntax (Example: scons -f cross-lua.py).

Please let me know if this works.

Best,
Raman

luac.elua.patch