All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] poky-tiny: enable section removal
@ 2020-11-09 22:38 Sinan Kaya
  2020-11-10 10:11 ` [poky] " Paul Barker
  2020-11-10 21:35 ` Richard Purdie
  0 siblings, 2 replies; 5+ messages in thread
From: Sinan Kaya @ 2020-11-09 22:38 UTC (permalink / raw)
  To: poky; +Cc: Sinan Kaya

Use GCC sections flags so that unused sections can be garbage
collected at link time.

Signed-off-by: Sinan Kaya <okaya@kernel.org>
---
 meta-poky/conf/distro/poky-tiny.conf | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/meta-poky/conf/distro/poky-tiny.conf b/meta-poky/conf/distro/poky-tiny.conf
index c6d4b88f83d..1e37394875d 100644
--- a/meta-poky/conf/distro/poky-tiny.conf
+++ b/meta-poky/conf/distro/poky-tiny.conf
@@ -122,3 +122,21 @@ 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 = " -ffunction-sections -fdata-sections"
+LDFLAGS_append = " -Wl,--gc-sections"
+
+# gc-sections requires either an entry or an undefined symbol
+CFLAGS_remove_pn-glibc = "-ffunction-sections -fdata-sections"
+LDFLAGS_remove_pn-glibc = "-Wl,--gc-sections"
+
+# perl won't cross compile with sections
+CFLAGS_remove_pn-perl = "-ffunction-sections -fdata-sections"
+LDFLAGS_remove_pn-perl = "-Wl,--gc-sections"
+
+# Unknown float word ordering. You need to manually preset
+CFLAGS_remove_pn-cairo = "-ffunction-sections -fdata-sections"
+LDFLAGS_remove_pn-cairo = "-Wl,--gc-sections"
+
+
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [poky] [PATCH v3] poky-tiny: enable section removal
  2020-11-09 22:38 [PATCH v3] poky-tiny: enable section removal Sinan Kaya
@ 2020-11-10 10:11 ` Paul Barker
  2020-11-10 17:55   ` Sinan Kaya
  2020-11-10 21:35 ` Richard Purdie
  1 sibling, 1 reply; 5+ messages in thread
From: Paul Barker @ 2020-11-10 10:11 UTC (permalink / raw)
  To: Sinan Kaya; +Cc: poky

On Mon, 9 Nov 2020 at 22:38, Sinan Kaya <okaya@kernel.org> wrote:
>
> Use GCC sections flags so that unused sections can be garbage
> collected at link time.
>
> Signed-off-by: Sinan Kaya <okaya@kernel.org>
> ---
>  meta-poky/conf/distro/poky-tiny.conf | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/meta-poky/conf/distro/poky-tiny.conf b/meta-poky/conf/distro/poky-tiny.conf
> index c6d4b88f83d..1e37394875d 100644
> --- a/meta-poky/conf/distro/poky-tiny.conf
> +++ b/meta-poky/conf/distro/poky-tiny.conf
> @@ -122,3 +122,21 @@ 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 = " -ffunction-sections -fdata-sections"
> +LDFLAGS_append = " -Wl,--gc-sections"
> +
> +# gc-sections requires either an entry or an undefined symbol
> +CFLAGS_remove_pn-glibc = "-ffunction-sections -fdata-sections"
> +LDFLAGS_remove_pn-glibc = "-Wl,--gc-sections"
> +
> +# perl won't cross compile with sections
> +CFLAGS_remove_pn-perl = "-ffunction-sections -fdata-sections"
> +LDFLAGS_remove_pn-perl = "-Wl,--gc-sections"
> +
> +# Unknown float word ordering. You need to manually preset
> +CFLAGS_remove_pn-cairo = "-ffunction-sections -fdata-sections"
> +LDFLAGS_remove_pn-cairo = "-Wl,--gc-sections"
> +
> +

Using _remove in a common layer like this is discouraged as it's very
difficult to override anywhere else.

I'd recommend defining new variables with default values which enable
the flags you want then append them to CFLAGS and LDFLAGS
respectively. This allows the new variables to be overridden per
package very easily. Also consider that you may want to apply these
only for the target and not for native/nativesdk packages.

Here's a quick untested example:

CFLAGS_SECTION_REMOVAL = "-ffunction-sections -fdata-sections"
LDFLAGS_SECTION_REMOVAL = "-Wl,--gc-sections"

CFLAGS_SECTION_REMOVAL_pn-glibc = ""
LDFLAGS_SECTION_REMOVAL_pn-glibc = ""
CFLAGS_SECTION_REMOVAL_pn-perl = ""
LDFLAGS_SECTION_REMOVAL_pn-perl = ""
CFLAGS_SECTION_REMOVAL_pn-cairo = ""
LDFLAGS_SECTION_REMOVAL_pn-cairo = ""

CFLAGS_append_class-target = " ${CFLAGS_SECTION_REMOVAL}"
LDFLAGS_append_class-target = " ${LDFLAGS_SECTION_REMOVAL}"

You could also look at `meta/conf/distro/include/security_flags.inc`
in oe-core as an example.

And lastly it looks like you have a couple of extra newlines added at
the end of the file, these can be dropped.

Thanks,

-- 
Paul Barker
Konsulko Group

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [poky] [PATCH v3] poky-tiny: enable section removal
  2020-11-10 10:11 ` [poky] " Paul Barker
@ 2020-11-10 17:55   ` Sinan Kaya
  0 siblings, 0 replies; 5+ messages in thread
From: Sinan Kaya @ 2020-11-10 17:55 UTC (permalink / raw)
  To: Paul Barker; +Cc: poky

On 11/10/2020 5:11 AM, Paul Barker wrote:
> On Mon, 9 Nov 2020 at 22:38, Sinan Kaya <okaya@kernel.org> wrote:
>> Use GCC sections flags so that unused sections can be garbage
>> collected at link time.
>>
>> Signed-off-by: Sinan Kaya <okaya@kernel.org>
>> ---
>>  meta-poky/conf/distro/poky-tiny.conf | 18 ++++++++++++++++++
>>  1 file changed, 18 insertions(+)
>>
>> diff --git a/meta-poky/conf/distro/poky-tiny.conf b/meta-poky/conf/distro/poky-tiny.conf
>> index c6d4b88f83d..1e37394875d 100644
>> --- a/meta-poky/conf/distro/poky-tiny.conf
>> +++ b/meta-poky/conf/distro/poky-tiny.conf
>> @@ -122,3 +122,21 @@ 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 = " -ffunction-sections -fdata-sections"
>> +LDFLAGS_append = " -Wl,--gc-sections"
>> +
>> +# gc-sections requires either an entry or an undefined symbol
>> +CFLAGS_remove_pn-glibc = "-ffunction-sections -fdata-sections"
>> +LDFLAGS_remove_pn-glibc = "-Wl,--gc-sections"
>> +
>> +# perl won't cross compile with sections
>> +CFLAGS_remove_pn-perl = "-ffunction-sections -fdata-sections"
>> +LDFLAGS_remove_pn-perl = "-Wl,--gc-sections"
>> +
>> +# Unknown float word ordering. You need to manually preset
>> +CFLAGS_remove_pn-cairo = "-ffunction-sections -fdata-sections"
>> +LDFLAGS_remove_pn-cairo = "-Wl,--gc-sections"
>> +
>> +
> Using _remove in a common layer like this is discouraged as it's very
> difficult to override anywhere else.
> 
> I'd recommend defining new variables with default values which enable
> the flags you want then append them to CFLAGS and LDFLAGS
> respectively. This allows the new variables to be overridden per
> package very easily. Also consider that you may want to apply these
> only for the target and not for native/nativesdk packages.
> 
> Here's a quick untested example:
> 
> CFLAGS_SECTION_REMOVAL = "-ffunction-sections -fdata-sections"
> LDFLAGS_SECTION_REMOVAL = "-Wl,--gc-sections"
> 
> CFLAGS_SECTION_REMOVAL_pn-glibc = ""
> LDFLAGS_SECTION_REMOVAL_pn-glibc = ""
> CFLAGS_SECTION_REMOVAL_pn-perl = ""
> LDFLAGS_SECTION_REMOVAL_pn-perl = ""
> CFLAGS_SECTION_REMOVAL_pn-cairo = ""
> LDFLAGS_SECTION_REMOVAL_pn-cairo = ""
> 
> CFLAGS_append_class-target = " ${CFLAGS_SECTION_REMOVAL}"
> LDFLAGS_append_class-target = " ${LDFLAGS_SECTION_REMOVAL}"
> 
> You could also look at `meta/conf/distro/include/security_flags.inc`
> in oe-core as an example.

Makes sense.

> 
> And lastly it looks like you have a couple of extra newlines added at
> the end of the file, these can be dropped.

Sure, let me look. It must be left over there when I removed other
configs.

> 
> Thanks,
> 
> -- Paul Barker Konsulko Group
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [poky] [PATCH v3] poky-tiny: enable section removal
  2020-11-09 22:38 [PATCH v3] poky-tiny: enable section removal Sinan Kaya
  2020-11-10 10:11 ` [poky] " Paul Barker
@ 2020-11-10 21:35 ` Richard Purdie
  2020-11-10 22:51   ` Sinan Kaya
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Purdie @ 2020-11-10 21:35 UTC (permalink / raw)
  To: Sinan Kaya, poky; +Cc: Ross Burton

On Mon, 2020-11-09 at 22:38 +0000, Sinan Kaya wrote:
> Use GCC sections flags so that unused sections can be garbage
> collected at link time.
> 
> Signed-off-by: Sinan Kaya <okaya@kernel.org>
> ---
>  meta-poky/conf/distro/poky-tiny.conf | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/meta-poky/conf/distro/poky-tiny.conf b/meta-
> poky/conf/distro/poky-tiny.conf
> index c6d4b88f83d..1e37394875d 100644
> --- a/meta-poky/conf/distro/poky-tiny.conf
> +++ b/meta-poky/conf/distro/poky-tiny.conf
> @@ -122,3 +122,21 @@ 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 = " -ffunction-sections -fdata-sections"
> +LDFLAGS_append = " -Wl,--gc-sections"
> +
> +# gc-sections requires either an entry or an undefined symbol
> +CFLAGS_remove_pn-glibc = "-ffunction-sections -fdata-sections"
> +LDFLAGS_remove_pn-glibc = "-Wl,--gc-sections"
> +
> +# perl won't cross compile with sections
> +CFLAGS_remove_pn-perl = "-ffunction-sections -fdata-sections"
> +LDFLAGS_remove_pn-perl = "-Wl,--gc-sections"
> +
> +# Unknown float word ordering. You need to manually preset
> +CFLAGS_remove_pn-cairo = "-ffunction-sections -fdata-sections"
> +LDFLAGS_remove_pn-cairo = "-Wl,--gc-sections"
> +

Whilst earlier versions passed testing, this one didn't:

https://autobuilder.yoctoproject.org/typhoon/#/builders/15/builds/2949

Cheers,

Richard


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [poky] [PATCH v3] poky-tiny: enable section removal
  2020-11-10 21:35 ` Richard Purdie
@ 2020-11-10 22:51   ` Sinan Kaya
  0 siblings, 0 replies; 5+ messages in thread
From: Sinan Kaya @ 2020-11-10 22:51 UTC (permalink / raw)
  To: Richard Purdie, poky; +Cc: Ross Burton

On 11/10/2020 4:35 PM, Richard Purdie wrote:
>> +# perl won't cross compile with sections
>> +CFLAGS_remove_pn-perl = "-ffunction-sections -fdata-sections"
>> +LDFLAGS_remove_pn-perl = "-Wl,--gc-sections"
>> +

[snip]

>> +
> Whilst earlier versions passed testing, this one didn't:
> 
> https://autobuilder.yoctoproject.org/typhoon/#/builders/15/builds/2949

Thanks, I saw build error on dunfell. Maybe, the issue is fixed
upstream. I'll omit perl change on next revision.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-10 22:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 22:38 [PATCH v3] poky-tiny: enable section removal Sinan Kaya
2020-11-10 10:11 ` [poky] " Paul Barker
2020-11-10 17:55   ` Sinan Kaya
2020-11-10 21:35 ` Richard Purdie
2020-11-10 22:51   ` 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.