* [PATCH] poky-tiny: use size optimization, section removal and lto
@ 2020-11-06 17:03 Sinan Kaya
2020-11-06 18:13 ` [poky] " Khem Raj
0 siblings, 1 reply; 5+ messages in thread
From: Sinan Kaya @ 2020-11-06 17:03 UTC (permalink / raw
To: poky; +Cc: 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.
Signed-off-by: Sinan Kaya <okaya@kernel.org>
---
meta-poky/conf/distro/poky-tiny.conf | 32 ++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/meta-poky/conf/distro/poky-tiny.conf b/meta-poky/conf/distro/poky-tiny.conf
index c6d4b88f83d..eb463403fd1 100644
--- a/meta-poky/conf/distro/poky-tiny.conf
+++ b/meta-poky/conf/distro/poky-tiny.conf
@@ -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"
+
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [poky] [PATCH] poky-tiny: use size optimization, section removal and lto
2020-11-06 17:03 [PATCH] poky-tiny: use size optimization, section removal and lto Sinan Kaya
@ 2020-11-06 18:13 ` Khem Raj
2020-11-09 0:01 ` Sinan Kaya
0 siblings, 1 reply; 5+ messages in thread
From: Khem Raj @ 2020-11-06 18:13 UTC (permalink / raw
To: poky
Sinan
On 11/6/20 9:03 AM, Sinan Kaya wrote:
> 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.
> Signed-off-by: Sinan Kaya <okaya@kernel.org>
> ---
> meta-poky/conf/distro/poky-tiny.conf | 32 ++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/meta-poky/conf/distro/poky-tiny.conf b/meta-poky/conf/distro/poky-tiny.conf
> index c6d4b88f83d..eb463403fd1 100644
> --- a/meta-poky/conf/distro/poky-tiny.conf
> +++ b/meta-poky/conf/distro/poky-tiny.conf
> @@ -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
https://git.openembedded.org/openembedded-core-contrib/commit/?h=yoe/mut&id=b96dea04d451312e9e14d839215e3fef784c2c5d
> +
> +# 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"
> +
I think we should be setting FULL_OPTIMIZATION instead.
> +# xcrypt won't compile with -Os
> +SELECTED_OPTIMIZATION_pn-libxcrypt = " -O2"
> +
>
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [poky] [PATCH] poky-tiny: use size optimization, section removal and lto
2020-11-06 18:13 ` [poky] " Khem Raj
@ 2020-11-09 0:01 ` Sinan Kaya
2020-11-09 1:37 ` Khem Raj
0 siblings, 1 reply; 5+ messages in thread
From: Sinan Kaya @ 2020-11-09 0:01 UTC (permalink / raw
To: poky
On 11/6/2020 1:13 PM, Khem Raj wrote:
>>
>> diff --git a/meta-poky/conf/distro/poky-tiny.conf
>> b/meta-poky/conf/distro/poky-tiny.conf
>> index c6d4b88f83d..eb463403fd1 100644
>> --- a/meta-poky/conf/distro/poky-tiny.conf
>> +++ b/meta-poky/conf/distro/poky-tiny.conf
>> @@ -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
>
> https://git.openembedded.org/openembedded-core-contrib/commit/?h=yoe/mut&id=b96dea04d451312e9e14d839215e3fef784c2c5d
>
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [poky] [PATCH] poky-tiny: use size optimization, section removal and lto
2020-11-09 0:01 ` Sinan Kaya
@ 2020-11-09 1:37 ` Khem Raj
2020-11-09 22:26 ` Sinan Kaya
0 siblings, 1 reply; 5+ messages in thread
From: Khem Raj @ 2020-11-09 1:37 UTC (permalink / raw
To: Sinan Kaya; +Cc: poky
On Sun, Nov 8, 2020 at 4:01 PM Sinan Kaya <okaya@kernel.org> wrote:
>
> On 11/6/2020 1:13 PM, Khem Raj wrote:
> >>
> >> diff --git a/meta-poky/conf/distro/poky-tiny.conf
> >> b/meta-poky/conf/distro/poky-tiny.conf
> >> index c6d4b88f83d..eb463403fd1 100644
> >> --- a/meta-poky/conf/distro/poky-tiny.conf
> >> +++ b/meta-poky/conf/distro/poky-tiny.conf
> >> @@ -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
> >
> > https://git.openembedded.org/openembedded-core-contrib/commit/?h=yoe/mut&id=b96dea04d451312e9e14d839215e3fef784c2c5d
> >
>
> 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
>
> I just wanted to upstream what we are using internally.
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [poky] [PATCH] poky-tiny: use size optimization, section removal and lto
2020-11-09 1:37 ` Khem Raj
@ 2020-11-09 22:26 ` Sinan Kaya
0 siblings, 0 replies; 5+ messages in thread
From: Sinan Kaya @ 2020-11-09 22:26 UTC (permalink / raw
To: Khem Raj; +Cc: poky
On 11/8/2020 8:37 PM, Khem Raj wrote:
>> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-11-09 22:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-06 17:03 [PATCH] poky-tiny: use size optimization, section removal and lto Sinan Kaya
2020-11-06 18:13 ` [poky] " Khem Raj
2020-11-09 0:01 ` Sinan Kaya
2020-11-09 1:37 ` Khem Raj
2020-11-09 22:26 ` Sinan Kaya
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.