Tuesday, January 18, 2011

Compiling Lua on the fly with tcc.

tcc is quite fast.

This is in the "src" directory of Lua 5.1.4 (I added a small file with the definitions for the missing string functions).

$ time tcc *[^ca].c lgc.c lfunc.c -run lua.c -e 'print "hello!"'

real 0m0.165s
user 0m0.140s
sys 0m0.030s

Fun, even if fairly useless.

The performance of the lua interpreter that I had compiled statically, was about 1/2 of that compiled with gcc, so it is not a racer by all means - if you need speed, you will look at luajit.


markuman said...

how did you do this? tcc has many undefined symbols, such as main, floor, pow, etc

Andrew Yourtchenko said...

http://stdio.be/tcc-lua.html shows the entire log. Hope it helps!

Andrew Yourtchenko said...

http://stdio.be/tcc-lua.html - now hopefully with a hyperlink!