poky-tiny: use size optimization, section removal and lto
PATCH 1/1 poky-tiny: use size optimization, section removal and lto
Three changes:
1. Compile for size by default
2. Use GCC sections flags so that unused sections can be garbage collected at link time.
3. Enable LTO compiler option.
--- meta-poky/conf/distro/poky-tiny.conf | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
meta-poky/conf/distro/poky-tiny.conf +32 -0
@@ -122,3 +122,35 @@ PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny" # Disable python usage in opkg-utils since it won't build with tiny config PACKAGECONFIG_remove_pn-opkg-utils = "python" + +# set default for all targets +CFLAGS_append_class-target += "-ffunction-sections -fdata-sections" +LDFLAGS_append_class-target += "-Wl,--gc-sections -flto" + +# glibc won't compile with flto and sections +CFLAGS_remove_pn-glibc += "-ffunction-sections -fdata-sections" +LDFLAGS_remove_pn-glibc += "-Wl,--gc-sections" +LDFLAGS_remove_pn-glibc += "-flto" + +# libdevmapper won't compile with flto and sections +CFLAGS_remove_pn-libdevmapper += "-ffunction-sections -fdata-sections" +LDFLAGS_remove_pn-libdevmapper += "-Wl,--gc-sections" +LDFLAGS_remove_pn-libdevmapper += "-flto" + +# glibc-initial won't compile with flto and sections +LDFLAGS_remove_pn-glibc-initial += "-flto" + +# lcm2 won't compile with flto +LDFLAGS_remove_pn-lvm2 += "-flto" + +# cairo won't compile with flto and sections +CFLAGS_remove_pn-cairo += "-ffunction-sections -fdata-sections" +LDFLAGS_remove_pn-cairo += "-Wl,--gc-sections" +LDFLAGS_remove_pn-cairo += "-flto" + +# size optimize by default +SELECTED_OPTIMIZATION = "-Os" + +# xcrypt won't compile with -Os +SELECTED_OPTIMIZATION_pn-libxcrypt = " -O2" +
Signature · 1 line
2.17.1
Sinan
Quoted 7 lines · Sinan Kaya
Three changes:
1. Compile for size by default
2. Use GCC sections flags so that unused sections can be garbage collected at link time.
3. Enable LTO compiler option.
These are nice changes, thanks for doing it.
Quoted 10 lines
Signed-off-by Sinan Kaya <[email protected]>--- meta-poky/conf/distro/poky-tiny.conf | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)meta-poky/conf/distro/poky-tiny.conf +0
-0
meta-poky/conf/distro/poky-tiny.conf PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny" · line 128
Quoted 7 lines
meta-poky/conf/distro/poky-tiny.conf +4
-0@@ -122,3 +122,35 @@ PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny" # Disable python usage in opkg-utils since it won't build with tiny config PACKAGECONFIG_remove_pn-opkg-utils = "python" + +# set default for all targets +CFLAGS_append_class-target += "-ffunction-sections -fdata-sections" +LDFLAGS_append_class-target += "-Wl,--gc-sections -flto"
This should perhaps be added to FULL_OPTIMIZATION, although for lto I was thinking that we should have a seprate include file like lto.inc and call out the exceptions there. So it can be used in non poky-tiny builds too. something like
Quoted 15 lines
meta-poky/conf/distro/poky-tiny.conf +15
-0+ +# glibc won't compile with flto and sections +CFLAGS_remove_pn-glibc += "-ffunction-sections -fdata-sections" +LDFLAGS_remove_pn-glibc += "-Wl,--gc-sections" +LDFLAGS_remove_pn-glibc += "-flto" + +# libdevmapper won't compile with flto and sections +CFLAGS_remove_pn-libdevmapper += "-ffunction-sections -fdata-sections" +LDFLAGS_remove_pn-libdevmapper += "-Wl,--gc-sections" +LDFLAGS_remove_pn-libdevmapper += "-flto" + +# glibc-initial won't compile with flto and sections +LDFLAGS_remove_pn-glibc-initial += "-flto" + +# lcm2 won't compile with flto
meta-poky/conf/distro/poky-tiny.conf PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny" · line 153
Quoted 10 lines
meta-poky/conf/distro/poky-tiny.conf +10
-0+LDFLAGS_remove_pn-lvm2 += "-flto" + +# cairo won't compile with flto and sections +CFLAGS_remove_pn-cairo += "-ffunction-sections -fdata-sections" +LDFLAGS_remove_pn-cairo += "-Wl,--gc-sections" +LDFLAGS_remove_pn-cairo += "-flto" + +# size optimize by default +SELECTED_OPTIMIZATION = "-Os" +
I think we should be setting FULL_OPTIMIZATION instead.
Quoted 8 lines
meta-poky/conf/distro/poky-tiny.conf +3
-0+# xcrypt won't compile with -Os +SELECTED_OPTIMIZATION_pn-libxcrypt = " -O2" +
Quoted 21 lines · Khem Raj
Quoted 11 lines
meta-poky/conf/distro/poky-tiny.conf +0
-0@@ -122,3 +122,35 @@ PNBLACKLIST[core-image-weston] = "not buildablewith poky-tiny"
# Disable python usage in opkg-utils since it won't build with tiny config
PACKAGECONFIG_remove_pn-opkg-utils = "python"meta-poky/conf/distro/poky-tiny.conf PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny" · line 128
Quoted 4 lines
meta-poky/conf/distro/poky-tiny.conf +4
-0+ +# set default for all targets +CFLAGS_append_class-target += "-ffunction-sections -fdata-sections" +LDFLAGS_append_class-target += "-Wl,--gc-sections -flto"This should perhaps be added to
FULL_OPTIMIZATION, although for lto I was thinking that we should have a seprate include file like lto.inc and call out the exceptions there. So it can be used in non poky-tiny builds too. something like
Quoted 2 lines
I see that you are taking care of LTO already. There is also another patch for -Os.
Would you be willing to follow up for "-ffunction-sections -fdata-sections" too?
I just wanted to upstream what we are using internally.
Quoted 23 lines · Sinan Kaya
Quoted 21 lines · Khem Raj
Quoted 11 lines
meta-poky/conf/distro/poky-tiny.conf +0
-0@@ -122,3 +122,35 @@ PNBLACKLIST[core-image-weston] = "not buildablewith poky-tiny"
# Disable python usage in opkg-utils since it won't build with
tiny config
PACKAGECONFIG_remove_pn-opkg-utils = "python"meta-poky/conf/distro/poky-tiny.conf PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny" · line 128
Quoted 4 lines
meta-poky/conf/distro/poky-tiny.conf +4
-0+ +# set default for all targets +CFLAGS_append_class-target += "-ffunction-sections -fdata-sections" +LDFLAGS_append_class-target += "-Wl,--gc-sections -flto"This should perhaps be added to
FULL_OPTIMIZATION, although for lto I was thinking that we should have a seprate include file like lto.inc and call out the exceptions there. So it can be used in non poky-tiny builds too. something like
Quoted 8 lines
Quoted 2 lines
I see that you are taking care of LTO already. There is also another patch for -Os.
Would you be willing to follow up for "-ffunction-sections -fdata-sections" too?
that perhaps is fine and we should add that as in this patch. Except that they should be part of GLOBAL_OPTIMIZATIONS
so please send a v2
Quoted 5 lines
I just wanted to upstream what we are using internally.
Quoted 6 lines · Khem Raj
Quoted 2 lines
Would you be willing to follow up for "-ffunction-sections -fdata-sections" too?
that perhaps is fine and we should add that as in this patch. Except that they should be part of
GLOBAL_OPTIMIZATIONS
so please send a v2
I posted v2. I couldn't quite understand what you mean by GLOBAL_OPTIMIZATIONS though.