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'.
This commit is contained in:
parent
48623f5be8
commit
6dff905e51
|
@ -542,7 +542,8 @@ store.")
|
||||||
;; users should automatically pull Linux headers as well.
|
;; users should automatically pull Linux headers as well.
|
||||||
(propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
|
(propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
|
||||||
|
|
||||||
(outputs '("out" "debug"))
|
(outputs '("out" "debug"
|
||||||
|
"static")) ;9 MiB of .a files
|
||||||
|
|
||||||
(arguments
|
(arguments
|
||||||
`(#:out-of-source? #t
|
`(#:out-of-source? #t
|
||||||
|
@ -553,6 +554,11 @@ store.")
|
||||||
;; RUNPATH checks.
|
;; RUNPATH checks.
|
||||||
#:validate-runpath? #f
|
#:validate-runpath? #f
|
||||||
|
|
||||||
|
#:modules ((ice-9 ftw)
|
||||||
|
(srfi srfi-26)
|
||||||
|
(guix build utils)
|
||||||
|
(guix build gnu-build-system))
|
||||||
|
|
||||||
#:configure-flags
|
#:configure-flags
|
||||||
(list "--enable-add-ons"
|
(list "--enable-add-ons"
|
||||||
"--sysconfdir=/etc"
|
"--sysconfdir=/etc"
|
||||||
|
@ -657,7 +663,46 @@ store.")
|
||||||
;; "bilingual" eval/exec magic at the top of the file.
|
;; "bilingual" eval/exec magic at the top of the file.
|
||||||
"")
|
"")
|
||||||
(("exec @PERL@")
|
(("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)))
|
(inputs `(("static-bash" ,static-bash)))
|
||||||
|
|
||||||
|
|
|
@ -583,12 +583,24 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
|
||||||
(let* ((gcc (cross-gcc-wrapper gcc-boot0 binutils-boot0
|
(let* ((gcc (cross-gcc-wrapper gcc-boot0 binutils-boot0
|
||||||
glibc-final-with-bootstrap-bash
|
glibc-final-with-bootstrap-bash
|
||||||
(car (assoc-ref %boot1-inputs "bash"))))
|
(car (assoc-ref %boot1-inputs "bash"))))
|
||||||
(bash (package (inherit static-bash)
|
(bash (package
|
||||||
|
(inherit static-bash)
|
||||||
(arguments
|
(arguments
|
||||||
`(#:guile ,%bootstrap-guile
|
(substitute-keyword-arguments
|
||||||
,@(package-arguments static-bash)))))
|
(package-arguments static-bash)
|
||||||
|
((#:guile _ #f)
|
||||||
|
'%bootstrap-guile)
|
||||||
|
((#:configure-flags flags '())
|
||||||
|
;; Add a '-L' flag so that the pseudo-cross-ld of
|
||||||
|
;; BINUTILS-BOOT0 can find libc.a.
|
||||||
|
`(append ,flags
|
||||||
|
(list (string-append "LDFLAGS=-static -L"
|
||||||
|
(assoc-ref %build-inputs
|
||||||
|
"libc:static")
|
||||||
|
"/lib"))))))))
|
||||||
(inputs `(("gcc" ,gcc)
|
(inputs `(("gcc" ,gcc)
|
||||||
("libc" ,glibc-final-with-bootstrap-bash)
|
("libc" ,glibc-final-with-bootstrap-bash)
|
||||||
|
("libc:static" ,glibc-final-with-bootstrap-bash "static")
|
||||||
,@(fold alist-delete %boot1-inputs
|
,@(fold alist-delete %boot1-inputs
|
||||||
'("gcc" "libc")))))
|
'("gcc" "libc")))))
|
||||||
(package-with-bootstrap-guile
|
(package-with-bootstrap-guile
|
||||||
|
@ -663,6 +675,7 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
|
||||||
(define %boot2-inputs
|
(define %boot2-inputs
|
||||||
;; 3rd stage inputs.
|
;; 3rd stage inputs.
|
||||||
`(("libc" ,glibc-final)
|
`(("libc" ,glibc-final)
|
||||||
|
("libc:static" ,glibc-final "static")
|
||||||
("gcc" ,gcc-boot0-wrapped)
|
("gcc" ,gcc-boot0-wrapped)
|
||||||
,@(fold alist-delete %boot1-inputs '("libc" "gcc"))))
|
,@(fold alist-delete %boot1-inputs '("libc" "gcc"))))
|
||||||
|
|
||||||
|
@ -923,12 +936,13 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
|
||||||
("binutils" ,binutils-final)
|
("binutils" ,binutils-final)
|
||||||
("gcc" ,gcc-final)
|
("gcc" ,gcc-final)
|
||||||
("libc" ,glibc-final)
|
("libc" ,glibc-final)
|
||||||
|
("libc:static" ,glibc-final "static")
|
||||||
("locales" ,glibc-utf8-locales-final))))
|
("locales" ,glibc-utf8-locales-final))))
|
||||||
|
|
||||||
(define-public canonical-package
|
(define-public canonical-package
|
||||||
(let ((name->package (fold (lambda (input result)
|
(let ((name->package (fold (lambda (input result)
|
||||||
(match input
|
(match input
|
||||||
((_ package)
|
((_ package . outputs)
|
||||||
(vhash-cons (package-full-name package)
|
(vhash-cons (package-full-name package)
|
||||||
package result))))
|
package result))))
|
||||||
vlist-null
|
vlist-null
|
||||||
|
|
|
@ -248,6 +248,7 @@ target that libc."
|
||||||
,@inputs)))
|
,@inputs)))
|
||||||
(libc
|
(libc
|
||||||
`(("libc" ,libc)
|
`(("libc" ,libc)
|
||||||
|
("libc:static" ,libc "static")
|
||||||
("xkernel-headers" ;the target headers
|
("xkernel-headers" ;the target headers
|
||||||
,@(assoc-ref (package-propagated-inputs libc)
|
,@(assoc-ref (package-propagated-inputs libc)
|
||||||
"kernel-headers"))
|
"kernel-headers"))
|
||||||
|
|
Loading…
Reference in New Issue