[poky] [PATCH 4/4] image-mklibs.bbclass: add the library optimization functionality
Nitin A Kamble
nitin.a.kamble at intel.com
Tue Feb 1 03:57:22 PST 2011
From: Nitin A Kamble <nitin.a.kamble at intel.com>
Thanks to mark hatle for his help in implementation of this.
Signed-off-by: Nitin A Kamble <nitin.a.kamble at intel.com>
---
meta/classes/image-mklibs.bbclass | 57 +++++++++++++++++++++++++++++++++++++
meta/conf/local.conf.sample | 2 +
2 files changed, 59 insertions(+), 0 deletions(-)
create mode 100644 meta/classes/image-mklibs.bbclass
diff --git a/meta/classes/image-mklibs.bbclass b/meta/classes/image-mklibs.bbclass
new file mode 100644
index 0000000..9fd2bc0
--- /dev/null
+++ b/meta/classes/image-mklibs.bbclass
@@ -0,0 +1,57 @@
+do_rootfs[depends] += "mklibs-native:do_populate_sysroot"
+
+IMAGE_PREPROCESS_COMMAND += "mklibs_optimize_image; "
+
+mklibs_optimize_image () {
+ 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`
+}
+
+EXPORT_FUNCTIONS mklibs_optimize_image
diff --git a/meta/conf/local.conf.sample b/meta/conf/local.conf.sample
index f9953d1..a3667e9 100644
--- a/meta/conf/local.conf.sample
+++ b/meta/conf/local.conf.sample
@@ -74,8 +74,10 @@ EXTRA_IMAGE_FEATURES_mx31ads = "tools-testapps debug-tweaks"
PACKAGE_CLASSES ?= "package_rpm package_ipk"
# A list of additional classes to use when building the system
+# include 'image-mklibs' to reduce shared library files size for an image
# include 'image-prelink' in order to prelink the filesystem image
# include 'image-swab' to perform host system intrusion detection
+# NOTE: if listing mklibs & prelink both, then make sure mklibs is before prelink
USER_CLASSES ?= "image-prelink"
# POKYMODE controls the characteristics of the generated packages/images by
--
1.7.2.2
More information about the poky
mailing list