>From bc7fcb3dccd1a30f6294a082293389b2de0e6f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= 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 +;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès ;;; Copyright © 2013, 2014, 2015, 2016 Andreas Enge ;;; Copyright © 2012 Nikita Karetnikov ;;; Copyright © 2014, 2015, 2016, 2017, 2018 Mark H Weaver @@ -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