Page 1 of 1

newlisp and openwrt

Posted: Fri Nov 09, 2012 8:51 am
by dexter
As the title
I am porting newlisp to openwrt.

My device is TP-LINK TL_WR703N
MIPS with linux kernel 3.3.8

I cloned openwrt svn trunk, builded toolchain and SDK

My problem is ,Is there a way to reduce the size of newlisp binary file ?

As far as now, it is 284k, But my device only left 502kb
I found out that lua is about 150kb
Anyone can help me a little?

Code: Select all

OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
    nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o

CFLAGS = -Wall -ffunction-sections -fdata-sections  -c -Os   -DLINUX -I$(TARGET_DIR)/usr/include/
LDFLAGS = -L$(TARGET_DIR)/usr/lib/  -W1,--gc-sections -lm -ldl 
CC = mips-openwrt-linux-gcc
LD = mips-openwrt-linux-ld


default: $(OBJS)
    $(CC) $(OBJS)  -o newlisp $(LDFLAGS)   #for openwrt 
#    $(CC) $(OBJS) -g -lm -ldl -lreadline -ltermcap -o newlisp # slackware
#    $(CC) $(OBJS) -g -lm -ldl -lreadline -lncurses -o newlisp # other Linux Dist
#    $(CC) $(OBJS) -g -lm -ldl -o newlisp # without readline support
    $(STRIP) newlisp

.c.o:
    $(CC) $(CFLAGS) $<

$(OBJS): primes.h protos.h makefile_linux_openwrt

And, I also cut the readline library to save space, Is this ok for the newlisp's performence?


Thanks

Re: newlisp and openwrt

Posted: Fri Nov 09, 2012 10:46 am
by cormullion
I can't answer your question, but I'm wondering whether comparing to Lua makes sense. Last time I looked, a basic Lua binary didn't have the overheads (features) of a newLisp binary, ie file system interface, networking, maths, statistics, financials, XML, web server, parallel and distributed computing, PCRE regular expressions, step debugger, and so on. These were installable extras for Lua. Has that changed? (I like Lua, by the way, and the modular approach works well.)

Re: newlisp and openwrt

Posted: Fri Nov 09, 2012 11:32 am
by dexter
No mean to compare

Just wonder if there is way to reduce the binary file size.

As smaller as we can

Re: newlisp and openwrt

Posted: Sat Nov 10, 2012 2:25 pm
by jopython
Did you strip your newlisp executable?

Re: newlisp and openwrt

Posted: Sat Nov 10, 2012 6:39 pm
by Lutz
280k seems a lot to me without readline and utf8, but I don't know OpenWrt and don't have a Linux system handy at the moment to check. Perhaps somebody else can report numbers on Linux or other Mips CPU systems.

On FreeBSD, I get 211k when compiling without -DSUPPORT_UTF8 and -DREADLINE. I suggest taking out nl-utf8.o of the OBJS definition, because you haven't specified SUPPORT_UTF8. On FreeBSD both options account for about 20k.

I don't think stripping the executable will bring anything because you didn't specify the -g (debugging) flag in CFLAGS, which stores symbol names in the executable.

As Cormullion pointed out, there is a lot of highlevel stuff already built into the newlisp executable which you would have to store as modules on your system when using Lua or any other scripting language. Also consider that the simple built-in ffi with 'import' lets you do 95% of function imports from other C-libraries on your OpenWrt system.

I believe, user Kanen has some experience with OpenWrt systems, perhaps he as some suggestions.

Re: newlisp and openwrt

Posted: Sun Nov 11, 2012 11:55 am
by cormullion
user Kanen has some experience with OpenWrt systems
ah yes, I remember the Kane box...

Re: newlisp and openwrt

Posted: Sun Nov 11, 2012 4:19 pm
by jopython
In order to shave kilobytes, will it be possible to remove compilation options for the matrix, financial, trigonometry functions?
I am not sure why this decision to add these functions to the 'core' of a general purpose language.

Re: newlisp and openwrt

Posted: Mon Nov 12, 2012 2:48 am
by dexter
Thanks all guys

I will look at kane.

I stripped newlisp

removed nl-utf8.o

Now it is 280k

I am still working on reducing it.

I think it is possible to be less than 200k

Re: newlisp and openwrt

Posted: Wed Nov 14, 2012 11:49 pm
by kanen
Actually, if you go to https://github.com/kanendosei/kane-box/ ... er/openwrt -- you will see a Makefile for OpenWRT which works and creates a semi-reasonable version of newLisp.

You just have to put the newlisp Makefile in the right place ( ~/openwrt/package/newlisp directory ) and it will grab and compile the proper source files (from kane-box.com, actually). I don't have it working with 10.4.x of newLisp, but that can be done, if anyone needs it.
cormullion wrote:
user Kanen has some experience with OpenWrt systems
ah yes, I remember the Kane box...

Re: newlisp and openwrt

Posted: Fri Nov 16, 2012 3:24 am
by dexter
It seems kane-box have not been updated for a while

I could not download the kane-box newlisp

But I just did what you said ,with newlisp 10.4.4

it works just fine

Continue to reduce the size