Skip to contentSkip to conversation

About minimal image

PATCH Kang Kai 2 participants 5 messages Apr 22, 2011 – Apr 27, 2011

lore
Share & tools
lore

Kang Kai

author
#0 lore raw

Hi Mark,

I have read your mail about minimal image posted on Feb 19 on this mail list. We try to reduce image size by what your provided:

1. eglic configurability
2. using mklibs

Right now after migrate eglic configurability to my local yocto branch, and I only enable 4 options ("locale-code nsswitch rtld-debug posix-clang-wchar ", pls. check in attachment) of eglibc to make compile pass.

When after create minimal image, the rootfs (tar.bz2) is still about 3.4M, same size as without configure eglibc.

Could you give me some directions what should we do next step? We also hope some information about how to use mklibs to reduce packages and image size?

Thanks and Regards,
Kai

From 410f884c4bd0b2037d1df22ccdcd0bfb3c54ffdc Mon Sep 17 00:00:00 2001
From: Kang Kai <[email protected]>
Date: Thu, 21 Apr 2011 15:23:27 +0800
Subject: [PATCH] eglibc: migrate configurability from oe

migrate configurability from oe, try to shrink minimal image size

---
 meta/recipes-core/eglibc/eglibc-options.inc |   51 +++++++++++++++++++++++++++
 meta/recipes-core/eglibc/eglibc.inc         |   14 +++++++
 2 files changed, 65 insertions(+), 0 deletions(-)
 create mode 100644 meta/recipes-core/eglibc/eglibc-options.inc
meta/recipes-core/eglibc/eglibc-options.inc new file +51 -0
new file mode 100644
index 0000000..0af0aab
@@ -0,0 +1,51 @@
+def eglibc_cfg(feature, features, tokens, cnf ):
+	if type(tokens) == type(""):
+		tokens = [tokens]
+	if type(features) == type([]) and feature in features:
+		cnf.extend([token + ' = y' for token in tokens])
+	else:
+		cnf.extend([token + ' = n' for token in tokens])
+
+# Map distro features to eglibc options settings
+def features_to_eglibc_settings(d):
+        cnf = ([])
+        distro_features = (bb.data.getVar('DISTRO_FEATURES_EGLIBC', d, True) or '').split() 
+        eglibc_cfg('ipv6',      distro_features, 'OPTION_EGLIBC_ADVANCED_INET6', cnf)
+        eglibc_cfg('backtrace',      distro_features, 'OPTION_EGLIBC_BACKTRACE', cnf)
+        eglibc_cfg('big-macros',      distro_features, 'OPTION_EGLIBC_BIG_MACROS', cnf)
+        eglibc_cfg('bsd',      distro_features, 'OPTION_EGLIBC_BSD', cnf)
+        eglibc_cfg('cxx-tests',      distro_features, 'OPTION_EGLIBC_CXX_TESTS', cnf)
+        eglibc_cfg('catgets',      distro_features, 'OPTION_EGLIBC_CATGETS', cnf)
+        eglibc_cfg('charsets',      distro_features, 'OPTION_EGLIBC_CHARSETS', cnf)
+        eglibc_cfg('crypt',      distro_features, 'OPTION_EGLIBC_CRYPT', cnf)
+        eglibc_cfg('crypt-ufc',      distro_features, 'OPTION_EGLIBC_CRYPT_UFC', cnf)
+        eglibc_cfg('db-aliases',      distro_features, 'OPTION_EGLIBC_DB_ALIASES', cnf)
+        eglibc_cfg('envz',      distro_features, 'OPTION_EGLIBC_ENVZ', cnf)
+        eglibc_cfg('fcvt',      distro_features, 'OPTION_EGLIBC_FCVT', cnf)
+        eglibc_cfg('fmtmsg',      distro_features, 'OPTION_EGLIBC_FMTMSG', cnf)
+        eglibc_cfg('fstab',      distro_features, 'OPTION_EGLIBC_FSTAB', cnf)
+        eglibc_cfg('ftraverse',      distro_features, 'OPTION_EGLIBC_FTRAVERSE', cnf)
+        eglibc_cfg('getlogin',      distro_features, 'OPTION_EGLIBC_GETLOGIN', cnf)
+        eglibc_cfg('idn',      distro_features, 'OPTION_EGLIBC_IDN', cnf)
+        eglibc_cfg('inet',      distro_features, 'OPTION_EGLIBC_INET', cnf)
+        eglibc_cfg('inet-anl',      distro_features, 'OPTION_EGLIBC_INET_ANL', cnf)
+        eglibc_cfg('libm',      distro_features, 'OPTION_EGLIBC_LIBM', cnf)
+        eglibc_cfg('libm-big',      distro_features, 'OPTION_EGLIBC_LIBM_BIG', cnf)
+        eglibc_cfg('locales',      distro_features, 'OPTION_EGLIBC_LOCALES', cnf)
+        eglibc_cfg('locale-code',      distro_features, 'OPTION_EGLIBC_LOCALE_CODE', cnf)
+        eglibc_cfg('memusage',      distro_features, 'OPTION_EGLIBC_MEMUSAGE', cnf)
+        eglibc_cfg('nis',      distro_features, 'OPTION_EGLIBC_NIS', cnf)
+        eglibc_cfg('nsswitch',      distro_features, 'OPTION_EGLIBC_NSSWITCH', cnf)
+        eglibc_cfg('rcmd',      distro_features, 'OPTION_EGLIBC_RCMD', cnf)
+        eglibc_cfg('rtld-debug',      distro_features, 'OPTION_EGLIBC_RTLD_DEBUG', cnf)
+        eglibc_cfg('spawn',      distro_features, 'OPTION_EGLIBC_SPAWN', cnf)
+        eglibc_cfg('streams',      distro_features, 'OPTION_EGLIBC_STREAMS', cnf)
+        eglibc_cfg('sunrpc',      distro_features, 'OPTION_EGLIBC_SUNRPC', cnf)
+        eglibc_cfg('utmp',      distro_features, 'OPTION_EGLIBC_UTMP', cnf)
+        eglibc_cfg('utmpx',      distro_features, 'OPTION_EGLIBC_UTMPX', cnf)
+        eglibc_cfg('wordexp',      distro_features, 'OPTION_EGLIBC_WORDEXP', cnf)
+        eglibc_cfg('posix-clang-wchar',      distro_features, 'OPTION_POSIX_C_LANG_WIDE_CHAR', cnf)
+        eglibc_cfg('posix-regexp',      distro_features, 'OPTION_POSIX_REGEXP', cnf)
+        eglibc_cfg('posix-regexp-glibc',      distro_features, 'OPTION_POSIX_REGEXP_GLIBC', cnf)
+        eglibc_cfg('posix-wchar-io',      distro_features, 'OPTION_POSIX_WIDE_CHAR_DEVICE_IO', cnf)
+        return "\n".join(cnf)
meta/recipes-core/eglibc/eglibc.inc +14 -0
index 8314cb1..d5016bf 100644
@@ -28,6 +28,7 @@ DEPENDS = "virtual/${TARGET_PREFIX}gcc-intermediate linux-libc-headers"
 PROVIDES = "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc"
 PROVIDES += "virtual/libintl virtual/libiconv"
 inherit autotools
+require eglibc-options.inc
 
 LEAD_SONAME = "libc.so"
 
@@ -37,3 +38,16 @@ INHIBIT_DEFAULT_DEPS = "1"
 ARM_INSTRUCTION_SET = "arm"
 
 PACKAGES = "glibc catchsegv sln nscd ldd localedef glibc-utils glibc-dev glibc-doc glibc-locale libsegfault glibc-extra-nss glibc-thread-db glibc-pcprofile"
+
+
+DISTRO_FEATURES_EGLIBC = "locale-code nsswitch rtld-debug posix-clang-wchar "
+#DISTRO_FEATURES_EGLIBC = "ipv6 backtrace big-macros bsd cxx-tests catgets charsets \
+#                          crypt crypt-ufc db-aliases envz fcvt fmtmsg fstab ftraverse \
+#                          getlogin idn inet inet-anl libm libm-big locales locale-code \
+#                          memusage nis nsswitch rcmd rtld-debug spawn streams sunrpc utmp \
+#                          utmpx wordexp posix-clang-wchar posix-regexp posix-regexp-glibc posix-wchar-io \
+#                          "
+OE_FEATURES := "${@features_to_eglibc_settings(d)}"
+do_configure_prepend() {
+	echo '${OE_FEATURES}' > ${B}/option-groups.config
+}
Signature · 1 line
1.7.1
author
#1 lore raw

Hi Mark,

I have read your mail about minimal image posted on Feb 19 on this mail list. We try to reduce image size by what your said:

1. eglic configurability
2. using mklibs

Right now after migrate eglic configurability to my local yocto branch, and I only enable 4 options ("locale-code nsswitch rtld-debug posix-clang-wchar ", pls. check in attachment) of eglibc just to make compile pass.

When after create minimal image, the rootfs (tar.bz2) is still about 3.4M, same size as without adding configurability to eglibc.

Could you give me some directions what should we do in next step? We also hope some information about how to use mklibs to reduce packages and image size?

Thanks and Regards,
Kai

From 410f884c4bd0b2037d1df22ccdcd0bfb3c54ffdc Mon Sep 17 00:00:00 2001
From: Kang Kai <[email protected]>
Date: Thu, 21 Apr 2011 15:23:27 +0800
Subject: [PATCH] eglibc: migrate configurability from oe

migrate configurability from oe, try to shrink minimal image size

---
 meta/recipes-core/eglibc/eglibc-options.inc |   51 +++++++++++++++++++++++++++
 meta/recipes-core/eglibc/eglibc.inc         |   14 +++++++
 2 files changed, 65 insertions(+), 0 deletions(-)
 create mode 100644 meta/recipes-core/eglibc/eglibc-options.inc
meta/recipes-core/eglibc/eglibc-options.inc new file +51 -0
new file mode 100644
index 0000000..0af0aab
@@ -0,0 +1,51 @@
+def eglibc_cfg(feature, features, tokens, cnf ):
+	if type(tokens) == type(""):
+		tokens = [tokens]
+	if type(features) == type([]) and feature in features:
+		cnf.extend([token + ' = y' for token in tokens])
+	else:
+		cnf.extend([token + ' = n' for token in tokens])
+
+# Map distro features to eglibc options settings
+def features_to_eglibc_settings(d):
+        cnf = ([])
+        distro_features = (bb.data.getVar('DISTRO_FEATURES_EGLIBC', d, True) or '').split() 
+        eglibc_cfg('ipv6',      distro_features, 'OPTION_EGLIBC_ADVANCED_INET6', cnf)
+        eglibc_cfg('backtrace',      distro_features, 'OPTION_EGLIBC_BACKTRACE', cnf)
+        eglibc_cfg('big-macros',      distro_features, 'OPTION_EGLIBC_BIG_MACROS', cnf)
+        eglibc_cfg('bsd',      distro_features, 'OPTION_EGLIBC_BSD', cnf)
+        eglibc_cfg('cxx-tests',      distro_features, 'OPTION_EGLIBC_CXX_TESTS', cnf)
+        eglibc_cfg('catgets',      distro_features, 'OPTION_EGLIBC_CATGETS', cnf)
+        eglibc_cfg('charsets',      distro_features, 'OPTION_EGLIBC_CHARSETS', cnf)
+        eglibc_cfg('crypt',      distro_features, 'OPTION_EGLIBC_CRYPT', cnf)
+        eglibc_cfg('crypt-ufc',      distro_features, 'OPTION_EGLIBC_CRYPT_UFC', cnf)
+        eglibc_cfg('db-aliases',      distro_features, 'OPTION_EGLIBC_DB_ALIASES', cnf)
+        eglibc_cfg('envz',      distro_features, 'OPTION_EGLIBC_ENVZ', cnf)
+        eglibc_cfg('fcvt',      distro_features, 'OPTION_EGLIBC_FCVT', cnf)
+        eglibc_cfg('fmtmsg',      distro_features, 'OPTION_EGLIBC_FMTMSG', cnf)
+        eglibc_cfg('fstab',      distro_features, 'OPTION_EGLIBC_FSTAB', cnf)
+        eglibc_cfg('ftraverse',      distro_features, 'OPTION_EGLIBC_FTRAVERSE', cnf)
+        eglibc_cfg('getlogin',      distro_features, 'OPTION_EGLIBC_GETLOGIN', cnf)
+        eglibc_cfg('idn',      distro_features, 'OPTION_EGLIBC_IDN', cnf)
+        eglibc_cfg('inet',      distro_features, 'OPTION_EGLIBC_INET', cnf)
+        eglibc_cfg('inet-anl',      distro_features, 'OPTION_EGLIBC_INET_ANL', cnf)
+        eglibc_cfg('libm',      distro_features, 'OPTION_EGLIBC_LIBM', cnf)
+        eglibc_cfg('libm-big',      distro_features, 'OPTION_EGLIBC_LIBM_BIG', cnf)
+        eglibc_cfg('locales',      distro_features, 'OPTION_EGLIBC_LOCALES', cnf)
+        eglibc_cfg('locale-code',      distro_features, 'OPTION_EGLIBC_LOCALE_CODE', cnf)
+        eglibc_cfg('memusage',      distro_features, 'OPTION_EGLIBC_MEMUSAGE', cnf)
+        eglibc_cfg('nis',      distro_features, 'OPTION_EGLIBC_NIS', cnf)
+        eglibc_cfg('nsswitch',      distro_features, 'OPTION_EGLIBC_NSSWITCH', cnf)
+        eglibc_cfg('rcmd',      distro_features, 'OPTION_EGLIBC_RCMD', cnf)
+        eglibc_cfg('rtld-debug',      distro_features, 'OPTION_EGLIBC_RTLD_DEBUG', cnf)
+        eglibc_cfg('spawn',      distro_features, 'OPTION_EGLIBC_SPAWN', cnf)
+        eglibc_cfg('streams',      distro_features, 'OPTION_EGLIBC_STREAMS', cnf)
+        eglibc_cfg('sunrpc',      distro_features, 'OPTION_EGLIBC_SUNRPC', cnf)
+        eglibc_cfg('utmp',      distro_features, 'OPTION_EGLIBC_UTMP', cnf)
+        eglibc_cfg('utmpx',      distro_features, 'OPTION_EGLIBC_UTMPX', cnf)
+        eglibc_cfg('wordexp',      distro_features, 'OPTION_EGLIBC_WORDEXP', cnf)
+        eglibc_cfg('posix-clang-wchar',      distro_features, 'OPTION_POSIX_C_LANG_WIDE_CHAR', cnf)
+        eglibc_cfg('posix-regexp',      distro_features, 'OPTION_POSIX_REGEXP', cnf)
+        eglibc_cfg('posix-regexp-glibc',      distro_features, 'OPTION_POSIX_REGEXP_GLIBC', cnf)
+        eglibc_cfg('posix-wchar-io',      distro_features, 'OPTION_POSIX_WIDE_CHAR_DEVICE_IO', cnf)
+        return "\n".join(cnf)
meta/recipes-core/eglibc/eglibc.inc +14 -0
index 8314cb1..d5016bf 100644
@@ -28,6 +28,7 @@ DEPENDS = "virtual/${TARGET_PREFIX}gcc-intermediate linux-libc-headers"
 PROVIDES = "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc"
 PROVIDES += "virtual/libintl virtual/libiconv"
 inherit autotools
+require eglibc-options.inc
 
 LEAD_SONAME = "libc.so"
 
@@ -37,3 +38,16 @@ INHIBIT_DEFAULT_DEPS = "1"
 ARM_INSTRUCTION_SET = "arm"
 
 PACKAGES = "glibc catchsegv sln nscd ldd localedef glibc-utils glibc-dev glibc-doc glibc-locale libsegfault glibc-extra-nss glibc-thread-db glibc-pcprofile"
+
+
+DISTRO_FEATURES_EGLIBC = "locale-code nsswitch rtld-debug posix-clang-wchar "
+#DISTRO_FEATURES_EGLIBC = "ipv6 backtrace big-macros bsd cxx-tests catgets charsets \
+#                          crypt crypt-ufc db-aliases envz fcvt fmtmsg fstab ftraverse \
+#                          getlogin idn inet inet-anl libm libm-big locales locale-code \
+#                          memusage nis nsswitch rcmd rtld-debug spawn streams sunrpc utmp \
+#                          utmpx wordexp posix-clang-wchar posix-regexp posix-regexp-glibc posix-wchar-io \
+#                          "
+OE_FEATURES := "${@features_to_eglibc_settings(d)}"
+do_configure_prepend() {
+	echo '${OE_FEATURES}' > ${B}/option-groups.config
+}
Signature · 1 line
1.7.1
author
#2 lore raw

Hi Mark,

Quoted 11 lines

I have read your mail about minimal image posted on Feb 19 on this mail list. We try to reduce image size by what your said:

1. eglic configurability
2. using mklibs

Right now after migrate eglic configurability to my local yocto branch, and I only enable 4 options ("locale-code nsswitch rtld-debug posix-clang-wchar ", pls. check in attachment) of eglibc just to make compile pass.

When after create minimal image, the rootfs (tar.bz2) is still about 3.4M, same size as without adding configurability to eglibc.

Could you give me some directions what should we do in next step? We also hope some information about how to use mklibs to reduce packages and image size?

After open MKLIBS_OPTIMIZED_IMAGES ?= "core-image-minimal" in local.conf, the minimal image decrease from 3.4M to 3.1M, after extraction is 8.1M( vs. 8.4M before using mklibs). It looks like not so efficient as we expected.

Should I try to reduce busybox size at same time?Such as remove some not so usually used commands by configurations?

Any suggestion or guild will be appreciate!

Thanks and Regards,
Kai

Quoted 6 lines

_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky

#3 lore raw
Quoted 2 lines · Kang Kai

Hi Mark,

Apologies for the late response. I've been out of the office...

Quoted 4 lines
Quoted 4 lines

I have read your mail about minimal image posted on Feb 19 on this mail list. We try to reduce image size by what your said:

1. eglic configurability

eglibc configuration should affect the size of things greatly...

Quoted 6 lines
Quoted 6 lines

2. using mklibs

Right now after migrate eglic configurability to my local yocto branch, and I only enable 4 options ("locale-code nsswitch rtld-debug posix-clang-wchar ", pls. check in attachment) of eglibc just to make compile pass.

locale-code, nsswitch and any of the "wchar" options add a significant amount of space to the eglibc environment. (I don't know what rtld-debug does, so I don't know how to quantify it's effects on the rootfs size.)

If disabling any of these items causes a failure when building eglibc itself, we need to fix these issues and/or report them upstream.

Quoted 3 lines
Quoted 3 lines

When after create minimal image, the rootfs (tar.bz2) is still about 3.4M, same size as without adding configurability to eglibc.

You need to look at the files on the image, not the overall size of the image. Figure out where the larger items are any why they are there. This should help explain what is making the "optimized" minimal so big.

Quoted 5 lines
Quoted 2 lines

Could you give me some directions what should we do in next step? We also hope some information about how to use mklibs to reduce packages and image size?

After open MKLIBS_OPTIMIZED_IMAGES ?= "core-image-minimal" in local.conf, the minimal image decrease from 3.4M to 3.1M, after extraction is 8.1M( vs. 8.4M before using mklibs). It looks like not so efficient as we expected.

mklibs relinks the libc binary to remove objects that were not used. While the eglibc configuration simply disables various features in order to save space. The two are complementary.. but the more features you disable, the less mklibs will save.

Quoted 2 lines

Should I try to reduce busybox size at same time?Such as remove some not so usually used commands by configurations?

I suspect that the size and configuration of busybox is also affecting which items you need to have enabled within the eglibc configuration -- and which items mklibs is determining are needed.

Quoted 1 line

Any suggestion or guild will be appreciate!

I would suggest that you evaluate busybox and see if there are any components you can disable there as well -- while leaving the system somewhat functional.

The biggest problem with any of these "smallest system" exercises is that you need to have a target of functionality so that you can make the proper decisions. If the target is current configuration -- then likely we're about at a minimum already.. however if the target is to boot into a shell, we can disable a lot of busybox and simply enable the dash capabilities -- or even one of the lesser non-POSIX shells.

--Mark

Quoted 9 lines

Thanks and Regards,
Kai

Quoted 6 lines

_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky

author
#4 lore raw

Hi Mark,

Quoted 17 lines · Kang Kai
Quoted 2 lines

Hi Mark,

Apologies for the late response. I've been out of the office...

Quoted 4 lines
Quoted 4 lines

I have read your mail about minimal image posted on Feb 19 on this mail list. We try to reduce image size by what your said:

1. eglic configurability

eglibc configuration should affect the size of things greatly...

Quoted 6 lines
Quoted 6 lines

2. using mklibs

Right now after migrate eglic configurability to my local yocto branch, and I only enable 4 options ("locale-code nsswitch rtld-debug posix-clang-wchar ", pls. check in attachment) of eglibc just to make compile pass.

Quoted 6 lines

locale-code, nsswitch and any of the "wchar" options add a significant amount of space to the eglibc environment. (I don't know what rtld-debug does, so I don't know how to quantify it's effects on the rootfs size.)

If disabling any of these items causes a failure when building eglibc itself, we need to fix these issues and/or report them upstream.

I'll take that as the direction is right, disable all configurable options to reduce the image size. :) And I will try to figure out why disable these 4 options will cause eglibc build failure.

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

When after create minimal image, the rootfs (tar.bz2) is still about 3.4M, same size as without adding configurability to eglibc.

You need to look at the files on the image, not the overall size of the image. Figure out where the larger items are any why they are there. This should help explain what is making the "optimized" minimal so big.

ok, I'll do it.

Quoted 20 lines
Quoted 5 lines
Quoted 2 lines

Could you give me some directions what should we do in next step? We also hope some information about how to use mklibs to reduce packages and image size?

After open MKLIBS_OPTIMIZED_IMAGES ?= "core-image-minimal" in local.conf, the minimal image decrease from 3.4M to 3.1M, after extraction is 8.1M( vs. 8.4M before using mklibs). It looks like not so efficient as we expected.

mklibs relinks the libc binary to remove objects that were not used. While the eglibc configuration simply disables various features in order to save space. The two are complementary.. but the more features you disable, the less mklibs will save.

Quoted 2 lines

Should I try to reduce busybox size at same time?Such as remove some not so usually used commands by configurations?

I suspect that the size and configuration of busybox is also affecting which items you need to have enabled within the eglibc configuration -- and which items mklibs is determining are needed.

Quoted 1 line

Any suggestion or guild will be appreciate!

I would suggest that you evaluate busybox and see if there are any components you can disable there as well -- while leaving the system somewhat functional.

Quoted 6 lines

The biggest problem with any of these "smallest system" exercises is that you need to have a target of functionality so that you can make the proper decisions. If the target is current configuration -- then likely we're about at a minimum already.. however if the target is to boot into a shell, we can disable a lot of busybox and simply enable the dash capabilities -- or even one of the lesser non-POSIX shells.

I will ask Saul and Richard for more detailed requirements. Thank you very much!

Regards,
Kai