this will tell you how many times each library is needed (if it isn't on the list, it can likely just be removed --- not always though, need to remember dlopen and/or plugins may use it too ... in "module" mode)

now open binaudit in your text editor and get to work, starting with the ones that are needed only once ... you can build them in statically

The ones that are used the most would benefit the most tools by improving their compiles (I will discuss that later)

CFLAGS
-Os (optimize for speed unless it will increase size)
-finline-small-functions (inline if it is smaller to inline than call it)
-finline-functions-called-once -fearly-inline (requires gcc update)
-ffunction-sections -fdata-sections with -Wl,--gc-sections LDFLAG
pdf explanation by Denys Vlasenko (busybox maintainer)
(allows compiler to remove functions and data that aren't actually used even if they are in the same object file as one that is)
-fno-unwind-tables -fno-asynchronous-unwind-tables (don't include unnecessary unwind info)

Rich Felker wrote:

By default, modern GCC generates DWARF2 debug/unwind tables in the .eh_frame section of the object files/binaries. This adds significant bloat (as much as 15%) to the size of the busybox binary, including the portion mapped/loaded into memory at runtime (possibly a big issue for NOMMU targets), and the section is not strippable with the strip command due to being part of the loaded program text. I've since done some further checking - both testing and asking the GCC developers about it - and it seems the solution is to add to the CFLAGS -fno-unwind-tables and -fno-asynchronous-unwind-tables. If debugging is disabled, this will prevent GCC from outputting DWARF2 tables entirely. But since busybox builds with -g by default, the interesting case is what happens then. I originally thought these options would break debugging, but they don't; instead, they tell GCC to output the DWARF2 tables in the .debug_frame section instead of the newish .eh_frame section (used for exception handling). With these options added, busybox_unstripped is still fully debuggable, and the final busybox binary loses the 15% bloat factor from the DWARF2 tables.

LDFLAGS
--gc-sections (see above)
--as-needed (don't explicity link all libraries passed on the command line - try to see if any are useless ... all the locations of functions accessed indirectly via direct dependencies get stored in the binary when they can be loaded at runtime much more effectively - assuming the libraries get updated periodically, the locations will all be wrong and take much much longer to load)
NOTE: gcc should have a --warn-as-needed to inform developers which libraries are unneeded when their crappy build scripts are broken_________________Web Programming - Pet Packaging 100 & 101Last edited by technosaurus on Tue 09 Oct 2012, 01:26; edited 5 times in total

Hi technosaurus; I wondered if this could do a statistical analysis of lib. usage in common apps.
I did a sudo analysis myself that showed a small percentage of libs. are actually in common use.

This is all about rules for which libs. to include in static builds.
Once the libs. are identified, then scripts for statically building them.
I don`t know if a build script "scrap" can be used many times like this.

Goingnuts and I have done several x11, xaw and gtk1 apps as multicall binaries.... Gtk2 apps tend to use plugins - thus requiring significant patches... However there is an in between method where you mix static and dynamic libs based on analysis of dependencies. It gets complicated when you have to build pic versions of static libs so they can be statically linked into plugins (like png for imlib) and further complicated if you have another app that links to those libs directly (such as jwm with png support) requires changing the build to link to the imlib plugins for jwm. This is fine if you are doing a 1 time build of an embedded system with limited resources, but a royal pain to maintain for a distro. Thus the reason we hand picked a few compatible apps (sometimes even specific versions) and limited them to the minimum functionality needed to use/build/rebuild a system either from scratch using any distro's packages or so that if your whole shared library system gets corrupted, you can still recover comfortably with an intact desktop environment and still do basic everyday tasks like editing text, browsing the web or your file system, answering email and of course wasting time even if your libc gets corrupted._________________Web Programming - Pet Packaging 100 & 101

The advantage of statically compiling a multicall binary is that unused functions get compiled out. Busybox also has the capacity to "prefer applets" and call them as a function or by forking itself (both are much faster than running a separate binary... even moreso if that binary has to find and load shared libs) the only compression is the help text. Really it wouldn't hurt much to put a full busybox in the initramfs and copy it over. The only reason busybox applets sometimes fail is because the scripts weren't specifically written for it (tinycore scripts all work because they were) But I did notice that upx slows busybox down and the extra compression is negligible._________________Web Programming - Pet Packaging 100 & 101

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum