Skip to contentSkip to conversation

poky-tiny: Use musl for default system C library

PATCH In review Khem Raj 2 participants 5 messages Dec 20, 2015 – Jan 22, 2016

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 poky-tiny: Use musl for default system C library

poky-tiny is reference for smallest footprint distro that can be generated using yocto project infrastructure. Therefore switch to using musl which gives the smallest footprint with a lot of extra stretching for adding new package if needed, core-image-minimal for qemux86 comes out to be 716K ( rootfs only ), boot tested on qemux86/poky-tiny

---
 meta-yocto/conf/distro/poky-tiny.conf | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)
meta-yocto/conf/distro/poky-tiny.conf +5 -20
index b0227de..de3a441 100644
@@ -25,12 +25,12 @@
 # [ ] Define linux-yocto-tiny configs for all supported BSPs
 # [ ] Drop ldconfig from the installation
 # [ ] Modify the runqemu scripts to work with ext2 parameter:
-#     runqemu qemux86 qemuparams="-nographic" bootparams="console=ttyS0,115200 root=0800" 
+#     runqemu qemux86 qemuparams="-nographic" bootparams="console=ttyS0,115200 root=0800"
 # [ ] Modify busybox to allow for DISTRO_FEATURES-like confiruration
 
 require conf/distro/poky.conf
 DISTRO = "poky-tiny"
-
+TCLIBC = "musl"
 # FIXME: consider adding a new "tiny" feature
 #DISTRO_FEATURES_append = " tiny"
 
@@ -57,27 +57,11 @@ ENABLE_WIDEC_class-native = "true"
 # eglibc->bash->gettext->libc-posix-clang-wchar dependency.
 USE_NLS="no"
 
-# Reconfigure eglibc for a smaller installation
-# Comment out any of the lines below to disable them in the build
-DISTRO_FEATURES_LIBC_TINY = "libc-libm libc-crypt"
-DISTRO_FEATURES_LIBC_TINY_append_x86-64 = " libc-libm-big"
-
-# Required for "who"
-DISTRO_FEATURES_LIBC_MINIMAL = "libc-utmp libc-utmpx libc-getlogin"
-DISTRO_FEATURES_LIBC_REGEX = "libc-posix-regexp"
-DISTRO_FEATURES_LIBC_NET = "libc-inet libc-nis"
-
-DISTRO_FEATURES_LIBC = "${DISTRO_FEATURES_LIBC_TINY} \
-                        ${DISTRO_FEATURES_LIBC_MINIMAL} \
-                        ${DISTRO_FEATURES_LIBC_REGEX} \
-                        ${DISTRO_FEATURES_LIBC_NET} \
-                       "
-
 # Comment out any of the lines below to disable them in the build
 # DISTRO_FEATURES options:
 # alsa bluetooth ext2 irda pcmcia usbgadget usbhost wifi nfs zeroconf pci
 DISTRO_FEATURES_TINY = "pci"
-DISTRO_FEATURES_NET = "ipv4"
+DISTRO_FEATURES_NET = "ipv4 ipv6"
 DISTRO_FEATURES_USB = "usbhost"
 #DISTRO_FEATURES_USBGADGET = "usbgadget"
 #DISTRO_FEATURES_WIFI = "wifi"
@@ -87,13 +71,14 @@ DISTRO_FEATURES = "${DISTRO_FEATURES_TINY} \
                    ${DISTRO_FEATURES_USB} \
                    ${DISTRO_FEATURES_USBGADGET} \
                    ${DISTRO_FEATURES_WIFI} \
-                   ${DISTRO_FEATURES_LIBC} \
                   "
 
 # Enable LFS - see bug YOCTO #5865
 DISTRO_FEATURES_append_libc-uclibc = " largefile"
+DISTRO_FEATURES_append_libc-musl = " largefile"
 
 DISTRO_FEATURES_class-native = "${DISTRO_FEATURES_DEFAULT} ${DISTRO_FEATURES_LIBC} ${POKY_DEFAULT_DISTRO_FEATURES}"
+DISTRO_FEATURES_class-nativesdk = "${DISTRO_FEATURES_DEFAULT} ${DISTRO_FEATURES_LIBC} ${POKY_DEFAULT_DISTRO_FEATURES}"
 
 # Use tmpdevfs and the busybox runtime services
 VIRTUAL-RUNTIME_dev_manager = ""
Signature · 1 line
2.6.4
#1 lore raw
Quoted 6 lines · Khem Raj

poky-tiny is reference for smallest footprint distro that can be generated using yocto project infrastructure. Therefore switch to using musl which gives the smallest footprint with a lot of extra stretching for adding new package if needed, core-image-minimal for qemux86 comes out to be 716K ( rootfs only ), boot tested on qemux86/poky-tiny

For anyone else reading, I just gave this a test locally, and for context the previous poky-tiny was using a tuned glibc and the rootfs came in at 1.5M.

Ross

#2 lore raw
Quoted 4 lines · Ross

For anyone else reading, I just gave this a test locally, and for context the previous poky-tiny was using a tuned glibc and the rootfs came in at 1.5M.

Finished my comparison builds:

musl:
-rw-r--r-- 1 ross ross 731681 Jan 7 23:46 core-image-minimal-qemux86-20160107234351.rootfs.cpio.gz glibc:
-rw-r--r-- 1 ross ross 1569610 Jan 8 00:01 core-image-minimal-qemux86-20160107235147.rootfs.cpio.gz uclibc:
-rw-r--r-- 1 ross ross 669759 Jan 8 09:14 core-image-minimal-qemux86-20160108090512.rootfs.cpio.gz

So it's a slightly increase over uclibc, but by default poky-tiny uses glibc so this is a massive win. In the greater scheme of things musl is trending to be worth the increase over uclibc too.

Ross

author
#3 lore raw
Quoted 9 lines · Ross

On 8 January 2016 at 09:09, Burton, Ross <[email protected] <mailto:[email protected]>> wrote:
For anyone else reading, I just gave this a test locally, and for context the previous poky-tiny was using a tuned glibc and the rootfs came in at 1.5M.

Finished my comparison builds:

Quoted 9 lines

musl:
-rw-r--r-- 1 ross ross 731681 Jan 7 23:46 core-image-minimal-qemux86-20160107234351.rootfs.cpio.gz glibc:
-rw-r--r-- 1 ross ross 1569610 Jan 8 00:01 core-image-minimal-qemux86-20160107235147.rootfs.cpio.gz uclibc:
-rw-r--r-- 1 ross ross 669759 Jan 8 09:14 core-image-minimal-qemux86-20160108090512.rootfs.cpio.gz

So it's a slightly increase over uclibc, but by default poky-tiny uses glibc so this is a massive win. In the greater scheme of things musl is trending to be worth the increase over uclibc too.

Thanks Ross for this info. I think it will be interesting to know the sizes of packages contributing to image from buildhistory if you have it lying around. musl has libpthread/libm etc. all bundled into single .so for simplicity reasons. I would like to get to bottom of the slight increase of musl over uclibc based system

Quoted 1 line

Ross

author
#4 lore raw
Quoted 19 lines · Khem Raj
Quoted 17 lines · On Jan 8, 2016, at 1:21 AM, Burton, Ross <[email protected]…

On 8 January 2016 at 09:09, Burton, Ross <[email protected] <mailto:[email protected]>> wrote:
For anyone else reading, I just gave this a test locally, and for context the previous poky-tiny was using a tuned glibc and the rootfs came in at 1.5M.

Finished my comparison builds:

musl:
-rw-r--r-- 1 ross ross 731681 Jan 7 23:46 core-image-minimal-qemux86-20160107234351.rootfs.cpio.gz glibc:
-rw-r--r-- 1 ross ross 1569610 Jan 8 00:01 core-image-minimal-qemux86-20160107235147.rootfs.cpio.gz uclibc:
-rw-r--r-- 1 ross ross 669759 Jan 8 09:14 core-image-minimal-qemux86-20160108090512.rootfs.cpio.gz

Quoted 6 lines
Quoted 2 lines

So it's a slightly increase over uclibc, but by default poky-tiny uses glibc so this is a massive win. In the greater scheme of things musl is trending to be worth the increase over uclibc too.

Thanks Ross for this info. I think it will be interesting to know the sizes of packages contributing to image from buildhistory if you have it lying around. musl has libpthread/libm etc. all bundled into single .so for simplicity reasons. I would like to get to bottom of the slight increase of musl over uclibc based system

musl/core-image-minimal ( 690K )

601 KiB busybox
598 KiB musl
23 KiB netbase
5 KiB update-rc.d
4 KiB update-alternatives-opkg
3 KiB busybox-udhcpc
3 KiB busybox-mdev
3 KiB base-files
2 KiB run-postinsts
2 KiB busybox-syslog

uclibc/core-image-minimal ( 614K)

603     KiB busybox
515     KiB uclibc
73      KiB libm1
23      KiB netbase
5       KiB update-rc.d
4       KiB update-alternatives-opkg
3       KiB busybox-udhcpc
3       KiB busybox-mdev
3       KiB base-files
2       KiB run-postinsts
2       KiB busybox-syslog

I don’t know why musl one is 690K where as the factored sizes are quite same for both images . May be because it is on different machine.

Quoted 3 lines
Quoted 3 lines

Ross