Skip to content

--enable-library-stripping #1622

Closed
accursoft opened this Issue Dec 18, 2013 · 11 comments

5 participants

@accursoft

Installed libraries can be shrunk by about 10% with strip --strip-unneeded. It would be nice if cabal could do this automatically, the same way it strips executables.

@23Skidoo 23Skidoo added a commit to 23Skidoo/cabal that referenced this issue Dec 19, 2013
@23Skidoo 23Skidoo Implement '--enable-library-stripping'.
Fixes #1622.
9344e94
@23Skidoo 23Skidoo was assigned Dec 19, 2013
@23Skidoo 23Skidoo added a commit to 23Skidoo/cabal that referenced this issue Dec 19, 2013
@23Skidoo 23Skidoo Implement '--enable-library-stripping'.
Fixes #1622.
05565ee
@23Skidoo 23Skidoo closed this in #1623 Dec 19, 2013
@23Skidoo
Haskell member

I implemented this, but in my testing --strip-unneeded doesn't produce a noticeable effect. YMMV, of course.

@lukexi
lukexi commented Dec 23, 2013

Hi guys, it looks like Xcode's version of strip doesn't support --strip-unneeded so this breaks cabal on OS X.

lukexi@thopminkingscape:~$ strip --strip-unneeded
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: unrecognized option: --strip-unneeded
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip [-AnuSXx] [-] [-d filename] [-s filename] [-R filename] [-o output] file [...] 
@23Skidoo
Haskell member

@lukexi Thanks for the bug report. We should just disable library stripping on OS X then.

@hvr hvr added a commit to ghc/ghc that referenced this issue Apr 16, 2014
@hvr hvr Update Cabal submodule to tip of v1.20 branch
This corresponds to the RC of the soon-to-be Cabal 1.20 release

One noteworthy change is the removal of the `--with-ranlib` flag
requiring a small adaptation in the GHC build system.

Moreover two new licences were added, MPL and BSD2.

Due to haskell/cabal#1622 Cabal-1.20 now
allows to strip libraries as well, this doesn't work well with
`ghc-cabal copy` being fed a `":"` strip-command argument which was
simply ignored in the past. The current code tries to retain this
semantics as backward compat. However, this needs more investigation as
I'm not sure if/why the `test_bindist` step doesn't want the libraries
to be stripped on installation.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
8992d52
@nomeata nomeata added a commit to nomeata/ghc-complete that referenced this issue Apr 16, 2014
@nomeata nomeata Changes to ghc
Changes to ghc:
commit 8992d5269804b727fb77249511e89df678526907
Author: Herbert Valerio Riedel <hvr@gnu.org>
Date:   Tue Apr 15 11:09:45 2014 +0200

    Update Cabal submodule to tip of v1.20 branch

    This corresponds to the RC of the soon-to-be Cabal 1.20 release

    One noteworthy change is the removal of the `--with-ranlib` flag
    requiring a small adaptation in the GHC build system.

    Moreover two new licences were added, MPL and BSD2.

    Due to haskell/cabal#1622 Cabal-1.20 now
    allows to strip libraries as well, this doesn't work well with
    `ghc-cabal copy` being fed a `":"` strip-command argument which was
    simply ignored in the past. The current code tries to retain this
    semantics as backward compat. However, this needs more investigation as
    I'm not sure if/why the `test_bindist` step doesn't want the libraries
    to be stripped on installation.

    Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
77e2db6
@tibbe
Haskell member
tibbe commented Apr 17, 2014

Would it make sense to call strip without --strip-unneeded on OS X, or would that have no effect?

@23Skidoo
Haskell member

@tibbe I've no idea.

@mietek
mietek commented Oct 26, 2014

With regard to noticeable effects—I don't think Cabal is stripping enough things, even on Linux. Simply running strip --strip-unneeded on the contents of a Cabal sandbox built for idris-0.9.14.3 reduces it from 192M to 167M.

As a side note, stripping a GHC 7.8.3 binary distribution reduces it from 928M to 839M, or from 837M to 749M, depending on the flavour.

@23Skidoo
Haskell member

@mietek Which kinds of files are we missing?

@mietek
mietek commented Nov 7, 2014

@23Skidoo: By default, Halcyon removes all documentation (./share/doc), even for sandboxes—all those LICENSE files add up!—and strips all installed files. Sample results:

Ubuntu 14.04 LTS, GHC 7.8.3: (ghc-7.8.3-x86_64-unknown-linux-deb7.tar.xz)

Sandbox for tryhaskell:

I haven't done much testing on OS X yet, but preliminary results show that strip -u -r appears to be harmless and effective. However, the OS X strip doesn't appear to list all modified files.

OS X 10.9, GHC 7.8.3:

Sandbox for tryhaskell:

  • After installing: 281MB
  • After removing documentation: 280MB
  • After stripping: 225MB (List of stripped files not available)

cc @thoughtpolice

@23Skidoo
Haskell member
23Skidoo commented Nov 7, 2014

Hmm, maybe we're not stripping .so files? I'll look into this.

@mietek
mietek commented Nov 7, 2014

Some more numbers—sandbox for hl:

  • After installing: 606MB
  • After removing documentation: 604MB
  • After stripping: 533MB

However, perhaps I'm stripping too much. Currently disabled sandbox stripping in order to try and get hl to deploy successfully.

@mietek
mietek commented Nov 9, 2014

Turns out stripping was not the problem. Re-enabled.

@thomie thomie added a commit to thomie/cabal that referenced this issue Aug 19, 2015
@thomie thomie Strip libraries at install/copy time. Never strip libraries in build …
…directory.

Two changes:

  * strip static libraries (.a files) at install/copy time, instead of
    at build time. Note that Cabal strips shared libraries (.so files)
    and executables at install/copy time also.

    This is needed for GHC, because it uses Cabal (via ghc-cabal copy)
    to install the boot libraries, and relies on Cabal to take of
    library stripping. Currently .so files indeed get properly stripped,
    but .a files do not.

    (Stripping static libraries at build time was introduced in
    60409cb, with the explanation:
    "Call 'stripLib' from createLibArchive so that it's done only
    once.")

    This bug (if you want to call it that) partially explains the
    difference in size of a GHC installation before and after manual
    stripping, reported in ticket #1622. (The other parts are that the
    GHC build system currently doesn't strip executables on
    installation: https://ghc.haskell.org/trac/ghc/ticket/9087, and
    neither are the RTS library stripped, since they don't go through
    Cabal).

  * never strip copy of a library in the build directory. Only
    strip the copy that is installed. Note that Cabal never strips
    executables in the build directory either.

    This might speed up compilation of a package under development,
    since stripping won't be performed for every 'cabal build'. It is
    also consistent with the GNU coding standards for 'install-strip':

      "install-strip should not strip the executables in the build
      directory which are being copied for installation. It should only
      strip the copies that are installed."

    Source:
    http://www.gnu.org/prep/standards/html_node/Standard-Targets.html
f63e5a5
@thomie thomie added a commit to thomie/cabal that referenced this issue Aug 20, 2015
@thomie thomie Strip libraries at install/copy time. Never strip libraries in build …
…directory.

Two changes:

  * strip static libraries (.a files) at install/copy time, instead of
    at build time. Note that Cabal strips shared libraries (.so files)
    and executables at install/copy time also.

    This is needed for GHC, because it uses Cabal (via ghc-cabal copy)
    to install the boot libraries, and relies on Cabal to take of
    library stripping. Currently .so files indeed get properly stripped,
    but .a files do not.

    (Stripping static libraries at build time was introduced in
    60409cb, with the explanation:
    "Call 'stripLib' from createLibArchive so that it's done only
    once.")

    This bug (if you want to call it that) partially explains the
    difference in size of a GHC installation before and after manual
    stripping, reported in
    haskell#1622 (comment)
    (The other parts are that the GHC build system currently doesn't
    strip executables on installation:
    https://ghc.haskell.org/trac/ghc/ticket/9087, and neither are the
    RTS library stripped, since they don't go through Cabal).

  * never strip the copy of a library in the build directory. Only
    strip the copy that is installed. Note that Cabal never strips
    executables in the build directory either.

    This might speed up compilation of a package under development,
    since stripping won't be performed for every 'cabal build'. It is
    also consistent with the GNU coding standards for 'install-strip':

      "install-strip should not strip the executables in the build
      directory which are being copied for installation. It should only
      strip the copies that are installed."

    Source:
    http://www.gnu.org/prep/standards/html_node/Standard-Targets.html
68c9209
@thomie thomie added a commit to thomie/cabal that referenced this issue Aug 20, 2015
@thomie thomie Strip libraries at install/copy time. Never strip libraries in build …
…directory.

Two changes:

  * strip static libraries (.a files) at install/copy time, instead of
    at build time. Note that Cabal strips shared libraries (.so files)
    and executables at install/copy time also.

    This is needed for GHC, because it uses Cabal (via ghc-cabal copy)
    to install the boot libraries, and relies on Cabal to take of
    library stripping. Currently .so files indeed get properly stripped,
    but .a files do not.

    (Stripping static libraries at build time was introduced in
    60409cb, with the explanation:
    "Call 'stripLib' from createLibArchive so that it's done only
    once.")

    This bug (if you want to call it that) partially explains the
    difference in size of a GHC installation before and after manual
    stripping, reported in
    haskell#1622 (comment)
    (The other parts are that the GHC build system currently doesn't
    strip executables on installation:
    https://ghc.haskell.org/trac/ghc/ticket/9087, and neither are the
    RTS library stripped, since they don't go through Cabal).

  * never strip the copy of a library in the build directory. Only
    strip the copy that is installed. Note that Cabal never strips
    executables in the build directory either.

    This might speed up compilation of a package under development,
    since stripping won't be performed for every 'cabal build'. It is
    also consistent with the GNU coding standards for 'install-strip':

      "install-strip should not strip the executables in the build
      directory which are being copied for installation. It should only
      strip the copies that are installed."

    Source:
    http://www.gnu.org/prep/standards/html_node/Standard-Targets.html
9e4aa38
@thomie thomie added a commit to thomie/cabal that referenced this issue Aug 20, 2015
@thomie thomie Strip libraries at install/copy time. Never strip libraries in build …
…directory.

Two changes:

  * strip static libraries (.a files) at install/copy time, instead of
    at build time. Note that Cabal strips shared libraries (.so files)
    and executables at install/copy time also.

    This is needed for GHC, because it uses Cabal (via ghc-cabal copy)
    to install the boot libraries, and relies on Cabal to take of
    library stripping. Currently .so files indeed get properly stripped,
    but .a files do not.

    (Stripping static libraries at build time was introduced in
    60409cb, with the explanation:
    "Call 'stripLib' from createLibArchive so that it's done only
    once.")

    This bug (if you want to call it that) partially explains the
    difference in size of a GHC installation before and after manual
    stripping, reported in
    haskell#1622 (comment)
    (The other parts are that the GHC build system currently doesn't
    strip executables on installation:
    https://ghc.haskell.org/trac/ghc/ticket/9087, and neither are the
    RTS library stripped, since they don't go through Cabal).

  * never strip the copy of a library in the build directory. Only
    strip the copy that is installed. Note that Cabal never strips
    executables in the build directory either.

    This might speed up compilation of a package under development,
    since stripping won't be performed for every 'cabal build'. It is
    also consistent with the GNU coding standards for 'install-strip':

      "install-strip should not strip the executables in the build
      directory which are being copied for installation. It should only
      strip the copies that are installed."

    Source:
    http://www.gnu.org/prep/standards/html_node/Standard-Targets.html
acecedf
@thomie thomie added a commit to thomie/cabal that referenced this issue Aug 20, 2015
@thomie thomie Strip libraries at install/copy time. Never strip libraries in build …
…directory.

Two changes:

  * strip static libraries (.a files) at install/copy time, instead of
    at build time. Note that Cabal strips shared libraries (.so files)
    and executables at install/copy time also.

    This is needed for GHC, because it uses Cabal (via ghc-cabal copy)
    to install the boot libraries, and relies on Cabal to take of
    library stripping. Currently .so files indeed get properly stripped,
    but .a files do not.

    (Stripping static libraries at build time was introduced in
    60409cb, with the explanation:
    "Call 'stripLib' from createLibArchive so that it's done only
    once.")

    This bug (if you want to call it that) partially explains the
    difference in size of a GHC installation before and after manual
    stripping, reported in
    haskell#1622 (comment)
    (The other parts are that the GHC build system currently doesn't
    strip executables on installation:
    https://ghc.haskell.org/trac/ghc/ticket/9087, and neither are the
    RTS library stripped, since they don't go through Cabal).

  * never strip the copy of a library in the build directory. Only
    strip the copy that is installed. Note that Cabal never strips
    executables in the build directory either.

    This might speed up compilation of a package under development,
    since stripping won't be performed for every 'cabal build'. It is
    also consistent with the GNU coding standards for 'install-strip':

      "install-strip should not strip the executables in the build
      directory which are being copied for installation. It should only
      strip the copies that are installed."

    Source:
    http://www.gnu.org/prep/standards/html_node/Standard-Targets.html
8cde55b
@thomie thomie added a commit to thomie/cabal that referenced this issue Aug 20, 2015
@thomie thomie Strip libraries at install/copy time. Never strip libraries in build …
…directory.

Two changes:

  * strip static libraries (.a files) at install/copy time, instead of
    at build time. Note that Cabal strips shared libraries (.so files)
    and executables at install/copy time also.

    This is needed for GHC, because it uses Cabal (via ghc-cabal copy)
    to install the boot libraries, and relies on Cabal to take of
    library stripping. Currently .so files indeed get properly stripped,
    but .a files do not.

    (Stripping static libraries at build time was introduced in
    60409cb, with the explanation:
    "Call 'stripLib' from createLibArchive so that it's done only
    once.")

    This bug (if you want to call it that) partially explains the
    difference in size of a GHC installation before and after manual
    stripping, reported in
    haskell#1622 (comment)
    (The other parts are that the GHC build system currently doesn't
    strip executables on installation:
    https://ghc.haskell.org/trac/ghc/ticket/9087, and neither are the
    RTS library stripped, since they don't go through Cabal).

  * never strip the copy of a library in the build directory. Only
    strip the copy that is installed. Note that Cabal never strips
    executables in the build directory either.

    This might speed up compilation of a package under development,
    since stripping won't be performed for every 'cabal build'. It is
    also consistent with the GNU coding standards for 'install-strip':

      "install-strip should not strip the executables in the build
      directory which are being copied for installation. It should only
      strip the copies that are installed."

    Source:
    http://www.gnu.org/prep/standards/html_node/Standard-Targets.html
7ef72b3
@enolan enolan added a commit to enolan/cabal that referenced this issue Sep 27, 2015
@thomie thomie Strip libraries at install/copy time. Never strip libraries in build …
…directory.

Two changes:

  * strip static libraries (.a files) at install/copy time, instead of
    at build time. Note that Cabal strips shared libraries (.so files)
    and executables at install/copy time also.

    This is needed for GHC, because it uses Cabal (via ghc-cabal copy)
    to install the boot libraries, and relies on Cabal to take of
    library stripping. Currently .so files indeed get properly stripped,
    but .a files do not.

    (Stripping static libraries at build time was introduced in
    60409cb, with the explanation:
    "Call 'stripLib' from createLibArchive so that it's done only
    once.")

    This bug (if you want to call it that) partially explains the
    difference in size of a GHC installation before and after manual
    stripping, reported in
    haskell#1622 (comment)
    (The other parts are that the GHC build system currently doesn't
    strip executables on installation:
    https://ghc.haskell.org/trac/ghc/ticket/9087, and neither are the
    RTS library stripped, since they don't go through Cabal).

  * never strip the copy of a library in the build directory. Only
    strip the copy that is installed. Note that Cabal never strips
    executables in the build directory either.

    This might speed up compilation of a package under development,
    since stripping won't be performed for every 'cabal build'. It is
    also consistent with the GNU coding standards for 'install-strip':

      "install-strip should not strip the executables in the build
      directory which are being copied for installation. It should only
      strip the copies that are installed."

    Source:
    http://www.gnu.org/prep/standards/html_node/Standard-Targets.html
81017f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.