public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH 03/22] package: Process package stripping in parallel
Date: Mon, 4 Feb 2013 11:23:54 -0600	[thread overview]
Message-ID: <510FEEAA.9060706@windriver.com> (raw)
In-Reply-To: <bda5674ec4d39456cc53b1cf22f349f4880d3202.1359935562.git.richard.purdie@linuxfoundation.org>

On 2/3/13 5:55 PM, Richard Purdie wrote:
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>   meta/classes/package.bbclass |   58 ++++++++++--------------------------------
>   meta/lib/oe/package.py       |   45 ++++++++++++++++++++++++++++++++
>   2 files changed, 58 insertions(+), 45 deletions(-)
>
> diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
> index 527ef31..9c8cdbc 100644
> --- a/meta/classes/package.bbclass
> +++ b/meta/classes/package.bbclass
> @@ -309,49 +309,6 @@ def copydebugsources(debugsrcdir, d):
>               if os.path.exists(p) and not os.listdir(p):
>                   os.rmdir(p)
>
> -def runstrip(file, elftype, d):
> -    # Function to strip a single file, called from split_and_strip_files below
> -    # A working 'file' (one which works on the target architecture)
> -    #
> -    # The elftype is a bit pattern (explained in split_and_strip_files) to tell
> -    # us what type of file we're processing...
> -    # 4 - executable
> -    # 8 - shared library
> -
> -    import commands, stat, subprocess
> -
> -    strip = d.getVar("STRIP", True)
> -
> -    newmode = None
> -    if not os.access(file, os.W_OK) or os.access(file, os.R_OK):
> -        origmode = os.stat(file)[stat.ST_MODE]
> -        newmode = origmode | stat.S_IWRITE | stat.S_IREAD
> -        os.chmod(file, newmode)
> -
> -    extraflags = ""
> -
> -    # .so and shared library
> -    if elftype & 16:
> -        extraflags = "--strip-debug --remove-section=.comment --remove-section=.note --preserve-dates"
> -    elif ".so" in file and elftype & 8:
> -        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"
> -
> -    stripcmd = "'%s' %s '%s'" % (strip, extraflags, file)
> -    bb.debug(1, "runstrip: %s" % stripcmd)
> -
> -    ret = subprocess.call(stripcmd, shell=True)
> -
> -    if newmode:
> -        os.chmod(file, origmode)
> -
> -    if ret:
> -        bb.error("runstrip: '%s' strip command failed" % stripcmd)
> -
> -    return 0
> -
>   #
>   # Package data handling routines
>   #
> @@ -902,13 +859,24 @@ python split_and_strip_files () {
>       # Now lets go back over things and strip them
>       #
>       if (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'):
> +        strip = d.getVar("STRIP", True)
> +        sfiles = []
>           for file in file_list:
>               if file_list[file].startswith("ELF: "):
>                   elf_file = int(file_list[file][5:])
>                   #bb.note("Strip %s" % file)
> -                runstrip(file, elf_file, d)
> +                sfiles.append((file, elf_file, strip))
>           for f in kernmods:
> -            runstrip(f, 16, d)
> +            sfiles.append((f, 16, strip))
> +
> +
> +        import multiprocessing
> +        nproc = multiprocessing.cpu_count()
> +        pool = multiprocessing.Pool(nproc)
> +        processed = pool.imap(oe.package.runstrip, sfiles)
> +        pool.close()
> +        pool.join()
> +
>       #
>       # End of strip
>       #
> diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
> index 6b1c1f4..9a0ddb8 100644
> --- a/meta/lib/oe/package.py
> +++ b/meta/lib/oe/package.py
> @@ -1,3 +1,48 @@
> +def runstrip(arg):
> +    # Function to strip a single file, called from split_and_strip_files below

Minor note, the comment above is now confusing as it's unclear where the 
split_and_strip_files is.  It might be reasonable at this point to simply remove 
that -- or change the comment to indicate it's from the package.bbclass.

--Mark

> +    # A working 'file' (one which works on the target architecture)
> +    #
> +    # The elftype is a bit pattern (explained in split_and_strip_files) to tell
> +    # us what type of file we're processing...
> +    # 4 - executable
> +    # 8 - shared library
> +    # 16 - kernel module
> +
> +    import commands, stat, subprocess
> +
> +    (file, elftype, strip) = arg
> +
> +    newmode = None
> +    if not os.access(file, os.W_OK) or os.access(file, os.R_OK):
> +        origmode = os.stat(file)[stat.ST_MODE]
> +        newmode = origmode | stat.S_IWRITE | stat.S_IREAD
> +        os.chmod(file, newmode)
> +
> +    extraflags = ""
> +
> +    # kernel module
> +    if elftype & 16:
> +        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"
> +    # shared or executable:
> +    elif elftype & 8 or elftype & 4:
> +        extraflags = "--remove-section=.comment --remove-section=.note"
> +
> +    stripcmd = "'%s' %s '%s'" % (strip, extraflags, file)
> +    bb.debug(1, "runstrip: %s" % stripcmd)
> +
> +    ret = subprocess.call(stripcmd, shell=True)
> +
> +    if newmode:
> +        os.chmod(file, origmode)
> +
> +    if ret:
> +        bb.error("runstrip: '%s' strip command failed" % stripcmd)
> +
> +    return
> +
>
>   def file_translate(file):
>       ft = file.replace("@", "@at@")
>




  reply	other threads:[~2013-02-04 17:39 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-03 23:55 [PATCH 00/22] Packaging performance improvements, round 2 Richard Purdie
2013-02-03 23:55 ` [PATCH 01/22] package.bbclass: Multithread per file dependency generation code Richard Purdie
2013-02-03 23:55 ` [PATCH 02/22] package: Don't export PATH Richard Purdie
2013-02-03 23:55 ` [PATCH 03/22] package: Process package stripping in parallel Richard Purdie
2013-02-04 17:23   ` Mark Hatle [this message]
2013-02-03 23:55 ` [PATCH 04/22] insane.bbclass: Add pkgvarcheck to check for suboptimal usages of variables Richard Purdie
2013-02-03 23:55 ` [PATCH 05/22] insane.bbclass: Add documentation headers for logical code blocks Richard Purdie
2013-02-03 23:55 ` [PATCH 06/22] staging/insane.bbclass: Move legacy do_stage check iinto insane.bbclass Richard Purdie
2013-02-03 23:55 ` [PATCH 07/22] staging.bbclass: Drop unused/legacy function Richard Purdie
2013-02-03 23:55 ` [PATCH 08/22] update-rc.d: Drop OVERRIDES code Richard Purdie
2013-02-03 23:55 ` [PATCH 09/22] qemu: Set RDEPENDS on the specific package that needs it Richard Purdie
2013-02-03 23:55 ` [PATCH 10/22] gdb-cross-canadian: " Richard Purdie
2013-02-03 23:55 ` [PATCH 11/22] initramfs-live-boot: " Richard Purdie
2013-02-03 23:55 ` [PATCH 12/22] package.bbclass: Fix up bb.mkdirhier/bb.copyfile usage Richard Purdie
2013-02-03 23:55 ` [PATCH 13/22] package.bbclass: Rewrite split_and_strip_files Richard Purdie
2013-02-09 11:41   ` Enrico Scholz
2013-02-10 13:50     ` Enrico Scholz
2013-02-03 23:55 ` [PATCH 14/22] kernel.bbclass: Improve populate_packages_prepend Richard Purdie
2013-02-03 23:55 ` [PATCH 15/22] package.bbclass: Make use of cleandirs and dirs function flags Richard Purdie
2013-02-03 23:55 ` [PATCH 16/22] package.bbclass: Various minor performance tweaks Richard Purdie
2013-02-03 23:55 ` [PATCH 17/22] package.bbclass: Simplify empty directory removal Richard Purdie
2013-02-03 23:55 ` [PATCH 18/22] package.bbclass: Add PACKAGESPLITFUNCS variable Richard Purdie
2013-02-03 23:55 ` [PATCH 19/22] sstate/path.py: Add copyhardlinktree() function and use for performance optimisation Richard Purdie
2013-02-03 23:55 ` [PATCH 20/22] package.bbclass: Better document the different phases of operation Richard Purdie
2013-02-03 23:55 ` [PATCH 21/22] package.bbclass: Pre-expand some variables to save time Richard Purdie
2013-02-03 23:55 ` [PATCH 22/22] classes: Drop none package specific packaging variable accesses Richard Purdie
2013-02-04 11:41 ` [PATCH 00/22] Packaging performance improvements, round 2 Richard Purdie

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=510FEEAA.9060706@windriver.com \
    --to=mark.hatle@windriver.com \
    --cc=openembedded-core@lists.openembedded.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox