aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/base.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-09-03 14:25:39 +0200
committerLudovic Courtès <ludo@gnu.org>2017-09-05 10:18:39 +0200
commit6dff905e51202bbdebbad8811b6509584d12a796 (patch)
tree860cd300b5f48616061817f73b157ea60ca1536f /gnu/packages/base.scm
parent48623f5be854e923b04ae83a1a882ff1cefdc742 (diff)
downloadguix-6dff905e51202bbdebbad8811b6509584d12a796.tar
guix-6dff905e51202bbdebbad8811b6509584d12a796.tar.gz
gnu: glibc: Add "static" output.
This shrinks glibc:out from 37 MiB to 29 MiB. * gnu/packages/base.scm (glibc/linux)[outputs]: Add "static". [arguments]: Add #:modules. Add 'move-static-libs' phase. * gnu/packages/commencement.scm (static-bash-for-glibc): Augment #:configure-flags to pass "-L LIBC:STATIC". Add the "static" output of GLIBC-FINAL to 'inputs'. (%boot2-inputs, %final-inputs): Likewise. (canonical-package): Adjust to deal with multiple-output packages. * gnu/packages/cross-base.scm (cross-gcc): Add the "static" output of LIBC to 'native-inputs'.
Diffstat (limited to 'gnu/packages/base.scm')
-rw-r--r--gnu/packages/base.scm49
1 files changed, 47 insertions, 2 deletions
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 532bb3e95b..ef81f2069f 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -542,7 +542,8 @@ store.")
;; users should automatically pull Linux headers as well.
(propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
- (outputs '("out" "debug"))
+ (outputs '("out" "debug"
+ "static")) ;9 MiB of .a files
(arguments
`(#:out-of-source? #t
@@ -553,6 +554,11 @@ store.")
;; RUNPATH checks.
#:validate-runpath? #f
+ #:modules ((ice-9 ftw)
+ (srfi srfi-26)
+ (guix build utils)
+ (guix build gnu-build-system))
+
#:configure-flags
(list "--enable-add-ons"
"--sysconfdir=/etc"
@@ -657,7 +663,46 @@ store.")
;; "bilingual" eval/exec magic at the top of the file.
"")
(("exec @PERL@")
- "exec perl"))))))))
+ "exec perl")))))
+
+ (add-after 'install 'move-static-libs
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; Move static libraries to the "static" output.
+ (define (static-library? file)
+ ;; Return true if FILE is a static library. The
+ ;; "_nonshared.a" files are referred to by libc.so,
+ ;; libpthread.so, etc., which are in fact linker
+ ;; scripts.
+ (and (string-suffix? ".a" file)
+ (not (string-contains file "_nonshared"))))
+
+ (define (linker-script? file)
+ ;; Guess whether FILE, a ".a" file, is actually a
+ ;; linker script.
+ (and (not (ar-file? file))
+ (not (elf-file? file))))
+
+ (let* ((out (assoc-ref outputs "out"))
+ (lib (string-append out "/lib"))
+ (files (scandir lib static-library?))
+ (static (assoc-ref outputs "static"))
+ (slib (string-append static "/lib")))
+ (mkdir-p slib)
+ (for-each (lambda (base)
+ (rename-file (string-append lib "/" base)
+ (string-append slib "/" base)))
+ files)
+
+ ;; Usually libm.a is a linker script so we need to
+ ;; change the file names in there to refer to STATIC
+ ;; instead of OUT.
+ (for-each (lambda (ld-script)
+ (substitute* ld-script
+ ((out) static)))
+ (filter linker-script?
+ (map (cut string-append slib "/" <>)
+ files)))
+ #t))))))
(inputs `(("static-bash" ,static-bash)))