aboutsummaryrefslogtreecommitdiffstats
path: root/meta/classes/image-mklibs.bbclass
diff options
context:
space:
mode:
authorNitin A Kamble <nitin.a.kamble@intel.com>2011-01-25 08:43:10 -0800
committerRichard Purdie <rpurdie@linux.intel.com>2011-02-09 22:45:47 +0000
commit068417289a4aeddc1cb18a7b102cd542ab283a92 (patch)
tree56728c9f3b93e73299c82de0def747f01880c1f8 /meta/classes/image-mklibs.bbclass
parentcfc40419885c1049e1345f4fd03f183114192402 (diff)
downloadopenembedded-core-contrib-068417289a4aeddc1cb18a7b102cd542ab283a92.tar.gz
image-mklibs.bbclass: add the library optimization functionality
If you want to enable the mklibs library size optimization for your image then, edit the MKLIBS_OPTIMIZED_IMAGES line in the local.conf like this: MKLIBS_OPTIMIZED_IMAGES ?= "poky-image-minimal your-own-image" Also this will enable the mklibs library size optimization for all images. MKLIBS_OPTIMIZED_IMAGES ?= "all" on qemux86 machine this reduced the rootfs size of poky image-minimal image from 7.9MB to 7.2MB. That is around 11% image foot print reduction. That image had 38 elf executables. Generally the size optimization by mklibs is reversely proportional to the number of elf executables in the rootfs. So bigger images will see less optimization, and smaller images will see large image size reductions. Thanks to mark hatle for his help in implementation of this. Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
Diffstat (limited to 'meta/classes/image-mklibs.bbclass')
-rw-r--r--meta/classes/image-mklibs.bbclass69
1 files changed, 69 insertions, 0 deletions
diff --git a/meta/classes/image-mklibs.bbclass b/meta/classes/image-mklibs.bbclass
new file mode 100644
index 0000000000..0e72b018c0
--- /dev/null
+++ b/meta/classes/image-mklibs.bbclass
@@ -0,0 +1,69 @@
+do_rootfs[depends] += "mklibs-native:do_populate_sysroot"
+
+IMAGE_PREPROCESS_COMMAND += "mklibs_optimize_image; "
+
+mklibs_optimize_image_doit() {
+ rm -rf ${WORKDIR}/mklibs
+ mkdir -p ${WORKDIR}/mklibs/dest
+ cd ${IMAGE_ROOTFS}
+ du -bs > ${WORKDIR}/mklibs/du.before.mklibs.txt
+ for i in `find .`; do file $i; done \
+ | grep ELF \
+ | grep "LSB executable" \
+ | grep "dynamically linked" \
+ | sed "s/:.*//" \
+ | sed "s+^\./++" \
+ > ${WORKDIR}/mklibs/executables.list
+
+ case ${TARGET_ARCH} in
+ powerpc | mips )
+ dynamic_loader="/lib/ld.so.1"
+ ;;
+ x86_64)
+ dynamic_loader="/lib/ld-linux-x86-64.so.2"
+ ;;
+ i586 )
+ dynamic_loader="/lib/ld-linux.so.2"
+ ;;
+ arm )
+ dynamic_loader="/lib/ld-linux.so.3"
+ ;;
+ * )
+ dynamic_loader="/unknown_dynamic_linker"
+ ;;
+ esac
+
+ mklibs -v \
+ --ldlib ${dynamic_loader} \
+ --sysroot ${PKG_CONFIG_SYSROOT_DIR} \
+ --root ${IMAGE_ROOTFS} \
+ --target `echo ${TARGET_PREFIX} | sed 's/-$//' ` \
+ -d ${WORKDIR}/mklibs/dest \
+ `cat ${WORKDIR}/mklibs/executables.list`
+
+ cd ${WORKDIR}/mklibs/dest
+ for i in *
+ do
+ cp $i `find ${IMAGE_ROOTFS} -name $i`
+ done
+
+ cd ${IMAGE_ROOTFS}
+ du -bs > ${WORKDIR}/mklibs/du.after.mklibs.txt
+
+ echo rootfs size before mklibs optimization: `cat ${WORKDIR}/mklibs/du.before.mklibs.txt`
+ echo rootfs size after mklibs optimization: `cat ${WORKDIR}/mklibs/du.after.mklibs.txt`
+}
+
+mklibs_optimize_image() {
+ for img in ${MKLIBS_OPTIMIZED_IMAGES}
+ do
+ if [ "${img}" == "${PN}" ] || [ "${img}" == "all" ]
+ then
+ mklibs_optimize_image_doit
+ break
+ fi
+ done
+}
+
+
+EXPORT_FUNCTIONS mklibs_optimize_image
ghlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
insert GPL v2 text here

Font Exception
As a special exception, if you create a document which uses this font, and
embed this font or unaltered portions of this font into the document, this font
does not by itself cause the resulting document to be covered by the GNU
General Public License. This exception does not however invalidate any other
reasons why the document might be covered by the GNU General Public License. If
you modify this font, you may extend this exception to your version of the
font, but you are not obligated to do so. If you do not wish to do so, delete
this exception statement from your version.