Deadstripping unused code

Topics for the Eclipse Environment
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Deadstripping unused code

Post by rnixon »

A MOD5234 has a very similar pinout and 2MB of Flash. Maybe you can migrate to that platform?
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Deadstripping unused code

Post by tod »

Depending on how much room your HTML/CSS/JS takes up there's a couple of steps you can take. First you are probably using only a portion of the prototype library, I once stripped prototype down to just what I needed (takes some effort), then I ran all the HTML, CSS, and in particular the JavaScript through automated tools that strip white, space commas etc. It saved a lot, unfortunately it can break your js code if you aren't in the habit of putting semicolons at the end of every possible place they are allowed to go. When all was said and done it made a big difference, this too was for a 5270. (Oh you also have to keep two versions of everything, you'll want to maintain the unstripped versions and regenerate the stripped versions for distribution.

I wrote up a blog on some memory impact issues and as much as it pains me to say this, if you're using <iostream> you can save a significant amount of memory by using the C stdio lib instead. Usually I recommend people do just the opposite but the blog post will show you the cost of <iostream> if you're using it.

There is also a strip utility C:\nburn\gcc-m68k\bin\m68k-elf-strip.exe which will discard all symbols from object files. I've never used it.
User avatar
Forrest
Posts: 285
Joined: Wed Apr 23, 2008 10:05 am

Re: Deadstripping unused code

Post by Forrest »

For a size reduction in executable, try enabling -Os [Optimize for Size]. You can do this by right clicking on your project in NBEclipse and under C/C++ Build->Settings, find GNU C++ Compiler->Optimization. By default, it will be set to -O2 in release mode and -O0 in debug mode. If you see -O0, change your configuration to release mode in the top of this screen. Now select optimize for size and the application should rebuild.

Be sure to check your before and after flash and ram. You are probably not going to see a miracle size decrease, but if you are within a percent, you might squeeze in. Of course, sometimes compiler optimization fails and -O2 is actually smaller. Thats why it's best to compare the before and after :)
Forrest Stanley
Project Engineer
NetBurner, Inc

NetBurner Learn Articles: http://www.netburner.com/learn
Post Reply