[OE-core] [PATCH v3] package.py: New EXTRA_STRIPFLAGS variable
Ulf Magnusson
ulfalizer at gmail.com
Wed Oct 26 13:16:30 UTC 2016
Hello,
On Wed, Oct 26, 2016 at 8:51 AM, Michael Blättler
<michael.blaettler at siemens.com> wrote:
> The EXTRA_STRIPFLAGS variable can be used to pass additional parameters to the strip command.
> This can be used to remove additional sections or to keep symbols.
> The removal of additional sections can be useful to enable reproducible builds.
> Sections which contain paths or md5sums of the debug binaries (like gnu_debuglink)
> can be eliminated with this flag.
>
> Signed-off-by: Pascal Bach <pascal.bach at siemens.com>
> Signed-off-by: Michael Blättler <michael.blaettler at siemens.com>
> ---
> meta/classes/package.bbclass | 5 +++--
> meta/lib/oe/package.py | 12 +++++-------
> 2 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
> index a6f0a7a..7e1c5c3 100644
> --- a/meta/classes/package.bbclass
> +++ b/meta/classes/package.bbclass
> @@ -1055,14 +1055,15 @@ python split_and_strip_files () {
> # Now lets go back over things and strip them
> #
> if (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'):
> + extraflags = d.getVar('EXTRA_STRIPFLAGS', True) or ''
> strip = d.getVar("STRIP", True)
> sfiles = []
> for file in elffiles:
> elf_file = int(elffiles[file])
> #bb.note("Strip %s" % file)
> - sfiles.append((file, elf_file, strip))
> + sfiles.append((file, elf_file, strip, extraflags))
> for f in kernmods:
> - sfiles.append((f, 16, strip))
> + sfiles.append((f, 16, strip, extraflags))
>
> oe.utils.multiprocess_exec(sfiles, oe.package.runstrip)
>
> diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
> index 02642f2..ab5f616 100644
> --- a/meta/lib/oe/package.py
> +++ b/meta/lib/oe/package.py
> @@ -10,7 +10,7 @@ def runstrip(arg):
>
> import stat, subprocess
>
> - (file, elftype, strip) = arg
> + (file, elftype, strip, extraflags) = arg
>
> newmode = None
> if not os.access(file, os.W_OK) or os.access(file, os.R_OK):
> @@ -18,17 +18,15 @@ def runstrip(arg):
> newmode = origmode | stat.S_IWRITE | stat.S_IREAD
> os.chmod(file, newmode)
>
> - extraflags = ""
> -
> - # kernel module
> + # kernel module
> if elftype & 16:
> - extraflags = "--strip-debug --remove-section=.comment --remove-section=.note --preserve-dates"
> + extraflags += " --strip-debug --remove-section=.comment --remove-section=.note --preserve-dates"
> # .so and shared library
> elif ".so" in file and elftype & 8:
> - extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded"
> + extraflags += " --remove-section=.comment --remove-section=.note --strip-unneeded"
> # shared or executable:
> elif elftype & 8 or elftype & 4:
> - extraflags = "--remove-section=.comment --remove-section=.note"
> + extraflags += " --remove-section=.comment --remove-section=.note"
Another approach would be to use STRIPFLAGS and
STRIPFLAGS_EXTRA_{MODULE,SO,EXE} variables with default values in
metadata. Not sure if that's overengineering things for little benefit
though.
>
> stripcmd = "'%s' %s '%s'" % (strip, extraflags, file)
> bb.debug(1, "runstrip: %s" % stripcmd)
> --
> 2.1.4
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
Looks fine to me codewise now, though I haven't tested it.
Cheers,
Ulf
More information about the Openembedded-core
mailing list