Page 1 of 2

Deadstripping unused code

Posted: Tue Mar 06, 2012 2:39 pm
by sblair
It doesn't appear that by default the Linker is deadstripping unused functions when compiling. Does anyone know if there are options to enable this?

I admit that I'm quite used to the Codewarrior tools which will deadstrip any unused vars and code, including inside libraries which saves a TON of space. With the amount of libraries linked in and trying to add in AJAX I'm really bumping into the ceiling on flash space and would like to have it deadstrip to make space.

Thanks,
Scott

Re: Deadstripping unused code

Posted: Wed Mar 07, 2012 3:17 pm
by sblair
Anyone?

:?:

Re: Deadstripping unused code

Posted: Wed Mar 07, 2012 3:57 pm
by tod
See if this answer on StackOverflow does you any good. I believe the more recent NNDK's are using the GCC 4.2.1 toolchain so you can also look at the gcc docs to see if -dead-strip or strip-unneeded are supported. There is a GUI setting for the linker to optimize for size, not sure how much that gets you.

Re: Deadstripping unused code

Posted: Wed Mar 07, 2012 4:22 pm
by pbreed
The basic GCC linker does not do this.
The correct answer is to split up a bunch of files into smaller compliation units so the linker can be smart.
We did this for the SBL2E and greatly reduced the space used.

I have an active project to rearrange the system files and do this, alas it probably will not bear fruit for at least 6 months.

Does anyone know of any automatic/semi automatic refactoring tools that will do this?


Paul

Re: Deadstripping unused code

Posted: Wed Mar 07, 2012 4:33 pm
by sblair
That sucks. I didn't realize how spoiled I've been by the CodeWarrior tools for the last 10 years. I just took it for granted everyone would have this feature by now. It's a godsend for doing embedded development!

Re: Deadstripping unused code

Posted: Wed Mar 07, 2012 4:49 pm
by rnixon
Which platform are you using? Even if everything is included, the final apps I build are still pretty small. When you do a build, what does eclipse say you are using for compressed space?

Re: Deadstripping unused code

Posted: Wed Mar 07, 2012 9:18 pm
by sblair
I'm over a 100% of space used with everything in there. Right now I'm leaving the AJAX prototype.js pulled out to get it to compile. I'm on a Mod5270B. I'd kill for a version with more Flash.

Re: Deadstripping unused code

Posted: Wed Mar 07, 2012 9:25 pm
by seulater
might not be practical for your app but you can always use a SD card to hold your web site files on.
Previously, we were using Flex for our web site, which pushed us out of flash area as Flex is a pig on final outputs.
So we added a micro SD card to out boards and placed the whole site on that.
Now we use Silvelight, and its far better for size. As a comparison, the Flex site was 480k, the same site in silverlight was 12k

Re: Deadstripping unused code

Posted: Wed Mar 07, 2012 9:43 pm
by sblair
Yeah, unfortunately that ship has pretty much sailed as I just had my carrier board built already. I wasn't expecting to be this close on space at all when I turned my guy loose on designing it.

It was the recent attempt to add both AJAX support and IUI for the IOS webpage support that pushed me so far over the edge. With the amount of libraries involved in the basic Netburner setup I'm a bit shocked that it doesn't sound like there is an option available to deadstrip. That was such a huge feature for me in the CodeWarrior stuff the few time I wanted to pull in string libraries so that it only brought in the space for the couple functions I used rather than the entire library.

Re: Deadstripping unused code

Posted: Wed Mar 07, 2012 9:50 pm
by seulater
i dont know if this may help. I have a LCD project where i have something like 20 different fonts and many different screen images.
all my fonts are in their own files. like Lucida_20.cpp, Lucida_22.cpp and so on.

i included the entire font set just in case they want a quick change to another font, but some projects use only 2 fonts and others may use 4.
so what i do to keep the size down is in eclipse you can right click on the file name and click exclude from build.