me
/
guix
Archived
1
0
Fork 0

gnu: make-bootstrap: Allow cross-compilation of the bootstrap tarballs.

* gnu/packages/make-bootstrap.scm (package-with-relocatable-glibc): Turn
  `inputs' into a thunk.  Add `native-inputs', and pass it to
  `package-with-explicit-inputs'.
  (%static-inputs): Add %BASH-STATIC as an input to gawk when cross
  building.
  (%glibc-stripped): When cross compiling,
  use (glibc-for-bootstrap (cross-libc)) as the basis.
  (%gcc-static): Base on GCC-4.7, not GCC-FINAL.
  (tarball-package): TAR and XZ are native inputs.  Choose the tarball
  file name based on (%current-target-system) too.
master
Ludovic Courtès 2013-06-25 23:39:14 +02:00
parent a3cff41dd1
commit a410a0105d
1 changed files with 108 additions and 77 deletions

View File

@ -24,6 +24,7 @@
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module ((gnu packages) #:select (search-patch)) #:use-module ((gnu packages) #:select (search-patch))
#:use-module (gnu packages base) #:use-module (gnu packages base)
#:use-module (gnu packages cross-base)
#:use-module (gnu packages bash) #:use-module (gnu packages bash)
#:use-module (gnu packages compression) #:use-module (gnu packages compression)
#:use-module (gnu packages gawk) #:use-module (gnu packages gawk)
@ -49,20 +50,20 @@
;;; ;;;
;;; Code: ;;; Code:
(define* (glibc-for-bootstrap #:optional (base glibc-final)) (define* (glibc-for-bootstrap #:optional (base glibc))
"Return a libc deriving from BASE whose `system' and `popen' functions looks "Return a libc deriving from BASE whose `system' and `popen' functions looks
for `sh' in $PATH, and without nscd, and with static NSS modules." for `sh' in $PATH, and without nscd, and with static NSS modules."
(package (inherit base) (package (inherit base)
(arguments (arguments
(substitute-keyword-arguments (package-arguments base) (substitute-keyword-arguments (package-arguments base)
((#:patches patches) ((#:patches patches)
`(cons (assoc-ref %build-inputs "patch/system") ,patches)) `(cons (assoc-ref %build-inputs "patch/system") ,patches))
((#:configure-flags flags) ((#:configure-flags flags)
;; Arrange so that getaddrinfo & co. do not contact the nscd, ;; Arrange so that getaddrinfo & co. do not contact the nscd,
;; and can use statically-linked NSS modules. ;; and can use statically-linked NSS modules.
`(cons* "--disable-nscd" "--disable-build-nscd" `(cons* "--disable-nscd" "--disable-build-nscd"
"--enable-static-nss" "--enable-static-nss"
,flags)))) ,flags))))
(inputs (inputs
`(("patch/system" ,(search-patch "glibc-bootstrap-system.patch")) `(("patch/system" ,(search-patch "glibc-bootstrap-system.patch"))
,@(package-inputs base))))) ,@(package-inputs base)))))
@ -71,17 +72,39 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
"Return a variant of P that uses the libc as defined by "Return a variant of P that uses the libc as defined by
`glibc-for-bootstrap'." `glibc-for-bootstrap'."
(define inputs (define (cross-bootstrap-libc)
`(("libc", (glibc-for-bootstrap)) (let ((target (%current-target-system)))
("gcc" ,(package-with-explicit-inputs (glibc-for-bootstrap
gcc-4.7 ;; `cross-libc' already returns a cross libc, so clear
`(("libc",(glibc-for-bootstrap)) ;; %CURRENT-TARGET-SYSTEM.
,@(alist-delete "libc" %final-inputs)) (parameterize ((%current-target-system #f))
(current-source-location))) (cross-libc target)))))
,@(fold alist-delete %final-inputs '("libc" "gcc"))))
;; Standard inputs with the above libc and corresponding GCC.
(define (inputs)
(if (%current-target-system) ; is this package cross built?
`(("cross-libc" ,(cross-bootstrap-libc)))
'()))
(define (native-inputs)
(if (%current-target-system)
(let ((target (%current-target-system)))
`(("cross-gcc" ,(cross-gcc target
(cross-binutils target)
(cross-bootstrap-libc)))
("cross-binutils" ,(cross-binutils target))
,@%final-inputs))
`(("libc" ,(glibc-for-bootstrap))
("gcc" ,(package (inherit gcc-4.7)
(inputs
`(("libc",(glibc-for-bootstrap))
,@(package-inputs gcc-4.7)))))
,@(fold alist-delete %final-inputs '("libc" "gcc")))))
(package-with-explicit-inputs p inputs (package-with-explicit-inputs p inputs
(current-source-location))) (current-source-location)
#:native-inputs native-inputs))
(define %bash-static (define %bash-static
(static-package bash-light)) (static-package bash-light))
@ -140,9 +163,12 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(substitute* "configure" (substitute* "configure"
(("-export-dynamic") ""))) (("-export-dynamic") "")))
,phases))))) ,phases)))))
(inputs `(("patch/sh" ,(search-patch "gawk-shell.patch")))))) (inputs `(("patch/sh" ,(search-patch "gawk-shell.patch"))
(finalize (compose static-package ,@(if (%current-target-system)
package-with-relocatable-glibc))) `(("bash" ,%bash-static))
'())))))
(finalize (compose static-package
package-with-relocatable-glibc)))
`(,@(map (match-lambda `(,@(map (match-lambda
((name package) ((name package)
(list name (finalize package)))) (list name (finalize package))))
@ -155,12 +181,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
("sed" ,sed) ("sed" ,sed)
("grep" ,grep) ("grep" ,grep)
("gawk" ,gawk))) ("gawk" ,gawk)))
("bash" ,%bash-static) ("bash" ,%bash-static))))
;; ("ld-wrapper" ,ld-wrapper)
;; ("binutils" ,binutils-final)
;; ("gcc" ,gcc-final)
;; ("libc" ,glibc-final)
)))
(define %static-binaries (define %static-binaries
(package (package
@ -330,7 +351,12 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(copy-recursively (string-append linux "/include/asm-generic") (copy-recursively (string-append linux "/include/asm-generic")
(string-append incdir "/asm-generic")) (string-append incdir "/asm-generic"))
#t)))) #t))))
(inputs `(("libc" ,glibc) (inputs `(("libc" ,(let ((target (%current-target-system)))
(if target
(glibc-for-bootstrap
(parameterize ((%current-target-system #f))
(cross-libc target)))
glibc)))
("linux-headers" ,linux-libre-headers))) ("linux-headers" ,linux-libre-headers)))
;; Only one output. ;; Only one output.
@ -339,7 +365,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(define %gcc-static (define %gcc-static
;; A statically-linked GCC, with stripped-down functionality. ;; A statically-linked GCC, with stripped-down functionality.
(package-with-relocatable-glibc (package-with-relocatable-glibc
(package (inherit gcc-final) (package (inherit gcc-4.7)
(name "gcc-static") (name "gcc-static")
(arguments (arguments
`(#:modules ((guix build utils) `(#:modules ((guix build utils)
@ -347,7 +373,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(srfi srfi-1) (srfi srfi-1)
(srfi srfi-26) (srfi srfi-26)
(ice-9 regex)) (ice-9 regex))
,@(substitute-keyword-arguments (package-arguments gcc-final) ,@(substitute-keyword-arguments (package-arguments gcc-4.7)
((#:guile _) #f) ((#:guile _) #f)
((#:implicit-inputs? _) #t) ((#:implicit-inputs? _) #t)
((#:configure-flags flags) ((#:configure-flags flags)
@ -365,10 +391,10 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
((#:make-flags flags) ((#:make-flags flags)
`(cons "BOOT_LDFLAGS=-static" ,flags))))) `(cons "BOOT_LDFLAGS=-static" ,flags)))))
(inputs `(("gmp-source" ,(package-source gmp)) (inputs `(("gmp-source" ,(package-source gmp))
("mpfr-source" ,(package-source mpfr)) ("mpfr-source" ,(package-source mpfr))
("mpc-source" ,(package-source mpc)) ("mpc-source" ,(package-source mpc))
("binutils" ,binutils-final) ("binutils" ,binutils)
,@(package-inputs gcc-4.7)))))) ,@(package-inputs gcc-4.7))))))
(define %gcc-stripped (define %gcc-stripped
;; The subset of GCC files needed for bootstrap. ;; The subset of GCC files needed for bootstrap.
@ -411,51 +437,54 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
;; .scm and .go files relative to its installation directory, rather ;; .scm and .go files relative to its installation directory, rather
;; than in hard-coded configure-time paths. ;; than in hard-coded configure-time paths.
(let* ((guile (package (inherit guile-2.0) (let* ((guile (package (inherit guile-2.0)
(name (string-append (package-name guile-2.0) "-static")) (name (string-append (package-name guile-2.0) "-static"))
(inputs (inputs
`(("patch/relocatable" `(("patch/relocatable"
,(search-patch "guile-relocatable.patch")) ,(search-patch "guile-relocatable.patch"))
("patch/utf8" ("patch/utf8"
,(search-patch "guile-default-utf8.patch")) ,(search-patch "guile-default-utf8.patch"))
("patch/syscalls" ("patch/syscalls"
,(search-patch "guile-linux-syscalls.patch")) ,(search-patch "guile-linux-syscalls.patch"))
,@(package-inputs guile-2.0))) ,@(package-inputs guile-2.0)))
(propagated-inputs (propagated-inputs
`(("bdw-gc" ,libgc) `(("bdw-gc" ,libgc)
,@(alist-delete "bdw-gc" ,@(alist-delete "bdw-gc"
(package-propagated-inputs guile-2.0)))) (package-propagated-inputs guile-2.0))))
(arguments (arguments
`(;; When `configure' checks for ltdl availability, it `(;; When `configure' checks for ltdl availability, it
;; doesn't try to link using libtool, and thus fails ;; doesn't try to link using libtool, and thus fails
;; because of a missing -ldl. Work around that. ;; because of a missing -ldl. Work around that.
#:configure-flags '("LDFLAGS=-ldl") #:configure-flags '("LDFLAGS=-ldl"
,@(if (%current-target-system)
'("CC_FOR_BUILD=gcc")
'()))
#:phases (alist-cons-before #:phases (alist-cons-before
'configure 'static-guile 'configure 'static-guile
(lambda _ (lambda _
(substitute* "libguile/Makefile.in" (substitute* "libguile/Makefile.in"
;; Create a statically-linked `guile' ;; Create a statically-linked `guile'
;; executable. ;; executable.
(("^guile_LDFLAGS =") (("^guile_LDFLAGS =")
"guile_LDFLAGS = -all-static") "guile_LDFLAGS = -all-static")
;; Add `-ldl' *after* libguile-2.0.la. ;; Add `-ldl' *after* libguile-2.0.la.
(("^guile_LDADD =(.*)$" _ ldadd) (("^guile_LDADD =(.*)$" _ ldadd)
(string-append "guile_LDADD = " (string-append "guile_LDADD = "
(string-trim-right ldadd) (string-trim-right ldadd)
" -ldl\n")))) " -ldl\n"))))
%standard-phases) %standard-phases)
;; Allow Guile to be relocated, as is needed during ;; Allow Guile to be relocated, as is needed during
;; bootstrap. ;; bootstrap.
#:patches #:patches
(list (assoc-ref %build-inputs "patch/relocatable") (list (assoc-ref %build-inputs "patch/relocatable")
(assoc-ref %build-inputs "patch/utf8") (assoc-ref %build-inputs "patch/utf8")
(assoc-ref %build-inputs "patch/syscalls")) (assoc-ref %build-inputs "patch/syscalls"))
;; There are uses of `dynamic-link' in ;; There are uses of `dynamic-link' in
;; {foreign,coverage}.test that don't fly here. ;; {foreign,coverage}.test that don't fly here.
#:tests? #f))))) #:tests? #f)))))
(package-with-relocatable-glibc (static-package guile)))) (package-with-relocatable-glibc (static-package guile))))
(define %guile-static-stripped (define %guile-static-stripped
@ -492,9 +521,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(location (source-properties->location (current-source-location))) (location (source-properties->location (current-source-location)))
(name (string-append (package-name pkg) "-tarball")) (name (string-append (package-name pkg) "-tarball"))
(build-system trivial-build-system) (build-system trivial-build-system)
(inputs `(("tar" ,tar) (native-inputs `(("tar" ,tar)
("xz" ,xz) ("xz" ,xz)))
("input" ,pkg))) (inputs `(("input" ,pkg)))
(arguments (arguments
(let ((name (package-name pkg)) (let ((name (package-name pkg))
(version (package-version pkg))) (version (package-version pkg)))
@ -512,7 +541,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(zero? (system* "tar" "cJvf" (zero? (system* "tar" "cJvf"
(string-append out "/" (string-append out "/"
,name "-" ,version ,name "-" ,version
"-" ,(%current-system) "-"
,(or (%current-target-system)
(%current-system))
".tar.xz") ".tar.xz")
".")))))))))) "."))))))))))