All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul Barker" <pbarker@konsulko.com>
To: Sinan Kaya <okaya@kernel.org>
Cc: poky@lists.yoctoproject.org
Subject: Re: [poky] [PATCH v3] poky-tiny: enable section removal
Date: Tue, 10 Nov 2020 10:11:12 +0000	[thread overview]
Message-ID: <CAM9ZRVvcLwFs6zgw_5+BdjYVjevm=46CBTOko4774wRM86Zo1A@mail.gmail.com> (raw)
In-Reply-To: <20201109223824.12351-1-okaya@kernel.org>

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

  reply	other threads:[~2020-11-10 10:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 22:38 [PATCH v3] poky-tiny: enable section removal Sinan Kaya
2020-11-10 10:11 ` Paul Barker [this message]
2020-11-10 17:55   ` [poky] " Sinan Kaya
2020-11-10 21:35 ` Richard Purdie
2020-11-10 22:51   ` Sinan Kaya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM9ZRVvcLwFs6zgw_5+BdjYVjevm=46CBTOko4774wRM86Zo1A@mail.gmail.com' \
    --to=pbarker@konsulko.com \
    --cc=okaya@kernel.org \
    --cc=poky@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.