unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Using ‘--strip-all’ instead of ‘--strip-debug’?
@ 2018-03-08 14:16 Ludovic Courtès
  0 siblings, 0 replies; only message in thread
From: Ludovic Courtès @ 2018-03-08 14:16 UTC (permalink / raw)
  To: Guix Devel

[-- Attachment #1: Type: text/plain, Size: 3522 bytes --]

Hello Guix!

A while back Dave Love (IIRC) suggested stripping binaries with
‘--strip-all’ instead of ‘--strip-debug’.  I found traces of a previous
unfruitful experiment in that area as shown in this commit:

  commit 7da473b75721e06237b106c6d186f2729117b1ee
  Author: Ludovic Courtès <ludo@gnu.org>
  Date:   Mon Dec 29 21:44:48 2014 +0100

      gnu: Revert use of '--strip-all'.

      This reverts commits f05bdc9412135f34a1c417edc203c35cd005d0d5
      and 856ae5e6c71a1283a414d33e638051f95d3cce35.

      This broke all sorts of things.  See <http://hydra.gnu.org/eval/102058>,
      for example.

Unfortunately, the Hydra URL above is no longer available and I have no
idea what broke exactly.

The patch below reverts the revert.  I’ve built Coreutils, Git, and Node
on top of ‘core-updates’ with it.  Here are the sizes compared to master:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix size git | tail -1
total: 354.6 MiB
$ guix size git | tail -1
total: 364.5 MiB
$ ./pre-inst-env guix build -e '(@@ (gnu packages commencement) coreutils-final)'
/gnu/store/6mvaqb321wsxgb6v1rddczpd0n4b2x6g-coreutils-8.29-debug
/gnu/store/n7911c84mipr2qjp6vjqj1mbih5xysrk-coreutils-8.29
$ guix size /gnu/store/n7911c84mipr2qjp6vjqj1mbih5xysrk-coreutils-8.29 | tail -1
total: 77.7 MiB
$ guix build -e '(@@ (gnu packages commencement) coreutils-final)'
/gnu/store/l890vkp8mj07r9faglddwkpf7w33w71y-coreutils-8.28-debug
/gnu/store/6i33ik7haav0hd5a797l3llkq04ghx6g-coreutils-8.28
$ guix size /gnu/store/6i33ik7haav0hd5a797l3llkq04ghx6g-coreutils-8.28 | tail -1
total: 78.9 MiB
$ ./pre-inst-env guix size node | tail -1
total: 194.6 MiB
$ guix size node | tail -1
total: 201.9 MiB
--8<---------------cut here---------------end--------------->8---

So we’re talking about a 1.5–3.6% improvement on the whole closures,
which is quite disappointing.

If we look at Coreutils and Git alone (not the closure), we gain 7.3%
and 8.9% respectively (for reference, Coreutils in Debian is at 14.7 MiB
per <https://packages.debian.org/sid/coreutils>):

--8<---------------cut here---------------start------------->8---
$ guix size /gnu/store/n7911c84mipr2qjp6vjqj1mbih5xysrk-coreutils-8.29 | grep coreutils
/gnu/store/n7911c84mipr2qjp6vjqj1mbih5xysrk-coreutils-8.29          77.7    13.9  17.9%
$ guix size /gnu/store/6i33ik7haav0hd5a797l3llkq04ghx6g-coreutils-8.28 | grep coreutils
/gnu/store/6i33ik7haav0hd5a797l3llkq04ghx6g-coreutils-8.28          78.9    15.0  19.0%
$ ./pre-inst-env guix size git | grep git-2.16
/gnu/store/f4bwbv3clbyz5snjfbq7wzrxlvj0rwwh-git-2.16.2             354.6    31.4   8.9%
$ guix size git | grep git-2.16
/gnu/store/jwbc0rnn7qa4064bghqs7q8r0bm7v32p-git-2.16.2             364.5    34.5   9.5%
--8<---------------cut here---------------end--------------->8---

We get 9.8% for Node (it’s C++, so it has bigger symbol tables I guess):

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix size node | grep node
/gnu/store/iwdhzvdqjfqfd0m62f6z8a6sxqzb24cr-node-9.4.0             194.6    44.0  22.6%
$ guix size node | grep node
/gnu/store/rk8is4gw40w9dbzj6q3313z7ly34mj62-node-9.4.0             201.9    48.8  24.2%
--8<---------------cut here---------------end--------------->8---

The main downside is unexpected breakage as the 2014 commit above
suggests (would “--strip-debug --strip-unneeded” be safer?).

Thoughts?

Ludo’.


[-- Attachment #2: 0001-build-system-gnu-Strip-with-strip-all-instead-of-str.patch --]
[-- Type: text/x-patch, Size: 7074 bytes --]

From bc7fcb3dccd1a30f6294a082293389b2de0e6f53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Sat, 27 Dec 2014 19:20:18 +0100
Subject: [PATCH] build-system/gnu: Strip with '--strip-all' instead of
 '--strip-debug'.

This saves 19% on the 'bin' directory of Coreutils, and certainly
helpful for things like Git's 'libexec' directory.

This reinstates commits f05bdc9412135f34a1c417edc203c35cd005d0d5
and 856ae5e6c71a1283a414d33e638051f95d3cce35.

* guix/build-system/gnu.scm (gnu-build): Change default value for
 #:strip-flags to '("--strip-all").  Add #:archive-strip-flags
parameter and pass it down.
* guix/build/gnu-build-system.scm (strip): Ditto.  Add #:archive-strip-flags
parameter.  Use it when (ar-file? path).
* gnu/packages/linux.scm (linux-libre)[arguments]: Add #:strip-flags.
* gnu/packages/commencement.scm (gcc-boot0)[arguments]: Add
  #:strip-flags.
* gnu/packages/base.scm (glibc)[arguments]: Likewise.
---
 gnu/packages/base.scm           |  3 +++
 gnu/packages/commencement.scm   |  4 ++++
 gnu/packages/linux.scm          |  7 ++++++-
 guix/build-system/gnu.scm       |  6 ++++--
 guix/build/gnu-build-system.scm | 13 +++++++++++--
 5 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 2a5008059..1e06cfa61 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -627,6 +627,9 @@ store.")
             ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
             "libc_cv_ssp=no" "libc_cv_ssp_strong=no")
 
+      ;; Using '--strip-all' on crt*.o breaks them.
+      #:strip-flags '("--strip-debug")
+
       #:tests? #f                                 ; XXX
       #:phases (modify-phases %standard-phases
                  (add-before
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 3636b54b0..6a233f448 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -225,6 +225,10 @@
                    (ice-9 regex)
                    (srfi srfi-1)
                    (srfi srfi-26))
+
+        ;; Using '--strip-all' leads to a link failure while building libc.
+        #:strip-flags '("--strip-debug")
+
         ,@(substitute-keyword-arguments (package-arguments gcc)
             ((#:configure-flags flags)
              `(append (list ,(string-append "--target=" (boot-triplet))
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index a752fcf1b..0a238ee32 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013, 2014, 2015, 2016 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
 ;;; Copyright © 2014, 2015, 2016, 2017, 2018 Mark H Weaver <mhw@netris.org>
@@ -368,6 +368,11 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration."
                        (string-append "INSTALL_MOD_PATH=" out)
                        "INSTALL_MOD_STRIP=1"
                        "modules_install")))))
+
+       ;; Use '--strip-debug', not '--strip-all', because the latter leads to
+       ;; unloadable modules (due to the lack of a symbol table.)
+       #:strip-flags ''("--strip-debug" "--enable-deterministic-archives")
+
        #:tests? #f))
     (home-page "https://www.gnu.org/software/linux-libre/")
     (synopsis "100% free redistribution of a cleaned Linux kernel")
diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm
index c9140074b..bc02e498d 100644
--- a/guix/build-system/gnu.scm
+++ b/guix/build-system/gnu.scm
@@ -290,8 +290,9 @@ standard packages used as implicit inputs of the GNU build system."
                     (parallel-tests? #t)
                     (patch-shebangs? #t)
                     (strip-binaries? #t)
-                    (strip-flags ''("--strip-debug"
+                    (strip-flags ''("--strip-all"
                                     "--enable-deterministic-archives"))
+                    (archive-strip-flags ''("--strip-debug"))
                     (strip-directories ''("lib" "lib64" "libexec"
                                           "bin" "sbin"))
                     (validate-runpath? #t)
@@ -365,6 +366,7 @@ packages that must not be referenced."
                   #:validate-runpath? ,validate-runpath?
                   #:license-file-regexp ,license-file-regexp
                   #:strip-flags ,strip-flags
+                  #:archive-strip-flags ,archive-strip-flags
                   #:strip-directories ,strip-directories)))
 
   (define guile-for-build
@@ -439,7 +441,7 @@ is one of `host' or `target'."
                           (parallel-build? #t) (parallel-tests? #t)
                           (patch-shebangs? #t)
                           (strip-binaries? #t)
-                          (strip-flags ''("--strip-debug"
+                          (strip-flags ''("--strip-all"
                                           "--enable-deterministic-archives"))
                           (strip-directories ''("lib" "lib64" "libexec"
                                                 "bin" "sbin"))
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 7b43361f9..59c5dfa0e 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -345,8 +345,14 @@ makefiles."
                 (objcopy-command (if target
                                      (string-append target "-objcopy")
                                      "objcopy"))
-                (strip-flags '("--strip-debug"
+                (strip-flags '("--strip-all"
                                "--enable-deterministic-archives"))
+
+                ;; Using '--strip-all' on .a file would remove the archive
+                ;; index, leading to "Archive has no index" errors when
+                ;; linking against them.
+                (archive-strip-flags '("--strip-debug"))
+
                 (strip-directories '("lib" "lib64" "libexec"
                                      "bin" "sbin"))
                 #:allow-other-keys)
@@ -405,7 +411,10 @@ makefiles."
                      (begin (make-file-writable file) #t)
 
                      (zero? (apply system* strip-command
-                                   (append strip-flags (list file))))
+                                   (append (if (ar-file? file)
+                                               archive-strip-flags
+                                               strip-flags)
+                                           (list file))))
                      (or (not debug-output)
                          (add-debug-link file))))
               (find-files dir
-- 
2.16.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-03-08 14:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08 14:16 Using ‘--strip-all’ instead of ‘--strip-debug’? Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).