newlisp and openwrt

Started by dexter, November 09, 2012, 12:51:43 AM

Previous topic - Next topic

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?

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

cormullion

#1
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.)

dexter

#2
No mean to compare



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



As smaller as we can

jopython

#3
Did you strip your newlisp executable?

Lutz

#4
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.

cormullion

#5
Quoteuser Kanen has some experience with OpenWrt systems


ah yes, I remember the https://github.com/kanendosei/kane-box">Kane box...

jopython

#6
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.

dexter

#7
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

kanen

#8
Actually, if you go to https://github.com/kanendosei/kane-box/tree/master/openwrt">https://github.com/kanendosei/kane-box/ ... er/openwrt">https://github.com/kanendosei/kane-box/tree/master/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.


Quote from: "cormullion"
Quoteuser Kanen has some experience with OpenWrt systems


ah yes, I remember the https://github.com/kanendosei/kane-box">Kane box...
. Kanen Flowers http://kanen.me[/url] .

dexter

#9
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