;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
#:use-module (gnu packages guile)
#:use-module (gnu packages bdw-gc)
#:use-module (gnu packages linux)
+ #:use-module (gnu packages hurd)
#:use-module (gnu packages multiprecision)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
%glibc-bootstrap-tarball
%gcc-bootstrap-tarball
%guile-bootstrap-tarball
- %bootstrap-tarballs))
+ %bootstrap-tarballs
+
+ %guile-static-stripped))
;;; Commentary:
;;;
(cross-binutils target)
(cross-bootstrap-libc)))
("cross-binutils" ,(cross-binutils target))
- ,@%final-inputs))
+ ,@(%final-inputs)))
`(("libc" ,(glibc-for-bootstrap))
- ("gcc" ,(package (inherit gcc-4.8)
+ ("gcc" ,(package (inherit gcc)
+ (outputs '("out")) ; all in one so libgcc_s is easily found
(inputs
`(("libc",(glibc-for-bootstrap))
- ,@(package-inputs gcc-4.8)))))
- ,@(fold alist-delete %final-inputs '("libc" "gcc")))))
+ ,@(package-inputs gcc)))))
+ ,@(fold alist-delete (%final-inputs) '("libc" "gcc")))))
(package-with-explicit-inputs p inputs
(current-source-location)
#:native-inputs native-inputs))
-(define %bash-static
- (static-package bash-light))
-
(define %static-inputs
;; Packages that are to be used as %BOOTSTRAP-INPUTS.
(let ((coreutils (package (inherit coreutils)
;; Since we use `-static', remove
;; `-export-dynamic'.
(substitute* "configure"
- (("-export-dynamic") "")))
+ (("-Wl,-export-dynamic") "")))
,phases)))))
(inputs (if (%current-target-system)
- `(("bash" ,%bash-static))
+ `(("bash" ,static-bash))
'()))))
+ (tar (package (inherit tar)
+ (arguments
+ '(#:phases (modify-phases %standard-phases
+ (add-before 'build 'set-shell-file-name
+ (lambda _
+ ;; Do not use "/bin/sh" to run programs; see
+ ;; <http://lists.gnu.org/archive/html/guix-devel/2016-09/msg02272.html>.
+ (substitute* "src/system.c"
+ (("/bin/sh") "sh")
+ (("execv ") "execvp "))
+ #t)))))))
(finalize (compose static-package
package-with-relocatable-glibc)))
`(,@(map (match-lambda
("sed" ,sed)
("grep" ,grep)
("gawk" ,gawk)))
- ("bash" ,%bash-static))))
+ ("bash" ,static-bash))))
(define %static-binaries
(package
;; But of course, there are exceptions to this rule.
(let ((grep (assoc-ref %build-inputs "grep")))
- (copy-file (string-append grep "/bin/fgrep")
- (string-append bin "/fgrep"))
- (copy-file (string-append grep "/bin/egrep")
- (string-append bin "/egrep")))
+ (install-file (string-append grep "/bin/fgrep") bin)
+ (install-file (string-append grep "/bin/egrep") bin))
;; Clear references to the store path.
(for-each remove-store-references
(synopsis "Statically-linked bootstrap binaries")
(description
"Binaries used to bootstrap the distribution.")
- (license #f)
+ (license gpl3+)
(home-page #f)))
(define %binutils-static
#t))))
(inputs `(("binutils" ,%binutils-static)))))
-(define %glibc-stripped
+(define (%glibc-stripped)
;; GNU libc's essential shared libraries, dynamic linker, and headers,
;; with all references to store directories stripped. As a result,
;; libc.so is unusable and need to be patched for proper relocation.
(name "glibc-stripped")
(build-system trivial-build-system)
(arguments
- `(#:modules ((guix build utils))
+ `(#:modules ((guix build utils)
+ (guix build make-bootstrap))
#:builder
(begin
- (use-modules (guix build utils))
-
- (setvbuf (current-output-port) _IOLBF)
- (let* ((out (assoc-ref %outputs "out"))
- (libdir (string-append out "/lib"))
- (incdir (string-append out "/include"))
- (libc (assoc-ref %build-inputs "libc"))
- (linux (assoc-ref %build-inputs "linux-headers")))
- (mkdir-p libdir)
- (for-each (lambda (file)
- (let ((target (string-append libdir "/"
- (basename file))))
- (copy-file file target)
- (remove-store-references target)))
- (find-files (string-append libc "/lib")
- "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
-
- (copy-recursively (string-append libc "/include") incdir)
-
- ;; Copy some of the Linux-Libre headers that glibc headers
- ;; refer to.
- (mkdir (string-append incdir "/linux"))
- (for-each (lambda (file)
- (copy-file (string-append linux "/include/linux/" file)
- (string-append incdir "/linux/"
- (basename file))))
- '("limits.h" "errno.h" "socket.h" "kernel.h"
- "sysctl.h" "param.h" "ioctl.h" "types.h"
- "posix_types.h" "stddef.h"))
-
- (copy-recursively (string-append linux "/include/asm")
- (string-append incdir "/asm"))
- (copy-recursively (string-append linux "/include/asm-generic")
- (string-append incdir "/asm-generic"))
-
- ;; Remove the '.install' and '..install.cmd' files; the latter
- ;; contains store paths, which prevents bit reproducibility.
- (for-each delete-file (find-files incdir "\\.install"))
-
- #t))))
- (inputs `(("libc" ,(let ((target (%current-target-system)))
+ (use-modules (guix build make-bootstrap))
+ (make-stripped-libc (assoc-ref %outputs "out")
+ (assoc-ref %build-inputs "libc")
+ (assoc-ref %build-inputs "kernel-headers")))))
+ (inputs `(("kernel-headers"
+ ,(if (or (and (%current-target-system)
+ (hurd-triplet? (%current-target-system)))
+ (string-suffix? "-hurd" (%current-system)))
+ gnumach-headers
+ linux-libre-headers))
+ ("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)))
+ glibc)))))
;; Only one output.
(outputs '("out")))))
(define %gcc-static
;; A statically-linked GCC, with stripped-down functionality.
(package-with-relocatable-glibc
- (package (inherit gcc-4.8)
+ (package (inherit gcc)
(name "gcc-static")
+ (outputs '("out")) ; all in one
(arguments
`(#:modules ((guix build utils)
(guix build gnu-build-system)
(srfi srfi-1)
(srfi srfi-26)
(ice-9 regex))
- ,@(substitute-keyword-arguments (package-arguments gcc-4.8)
+ ,@(substitute-keyword-arguments (package-arguments gcc)
((#:guile _) #f)
((#:implicit-inputs? _) #t)
((#:configure-flags flags)
`(append (list
+ ;; We don't need a full bootstrap here.
+ "--disable-bootstrap"
+
+ ;; Make sure '-static' is passed where it matters.
+ "--with-stage1-ldflags=-static"
+
+ ;; GCC 4.8+ requires a C++ compiler and library.
+ "--enable-languages=c,c++"
+
+ ;; Make sure gcc-nm doesn't require liblto_plugin.so.
+ "--disable-lto"
+
"--disable-shared"
"--disable-plugin"
- "--enable-languages=c"
"--disable-libmudflap"
"--disable-libatomic"
"--disable-libsanitizer"
"--disable-libitm"
"--disable-libgomp"
+ "--disable-libcilkrts"
+ "--disable-libvtv"
"--disable-libssp"
- "--disable-libquadmath"
- "--disable-decimal-float")
+ "--disable-libquadmath")
(remove (cut string-match "--(.*plugin|enable-languages)" <>)
,flags)))
- ((#:make-flags flags)
- (if (%current-target-system)
- `(cons "LDFLAGS=-static" ,flags)
- `(cons "BOOT_LDFLAGS=-static" ,flags))))))
+ ((#:phases phases)
+ `(alist-cons-after
+ 'pre-configure 'remove-lgcc_s
+ (lambda _
+ ;; Remove the '-lgcc_s' added to GNU_USER_TARGET_LIB_SPEC in
+ ;; the 'pre-configure phase of our main gcc package, because
+ ;; that shared library is not present in this static gcc. See
+ ;; <https://lists.gnu.org/archive/html/guix-devel/2015-01/msg00008.html>.
+ (substitute* (find-files "gcc/config"
+ "^gnu-user.*\\.h$")
+ ((" -lgcc_s}}") "}}")))
+ ,phases)))))
(native-inputs
(if (%current-target-system)
`(;; When doing a Canadian cross, we need GMP/MPFR/MPC both
("gmp-native" ,gmp)
("mpfr-native" ,mpfr)
("mpc-native" ,mpc)
- ,@(package-native-inputs gcc-4.8))
- (package-native-inputs gcc-4.8))))))
+ ,@(package-native-inputs gcc))
+ (package-native-inputs gcc))))))
(define %gcc-stripped
;; The subset of GCC files needed for bootstrap.
- (package (inherit gcc-4.8)
+ (package (inherit gcc)
(name "gcc-stripped")
(build-system trivial-build-system)
(source #f)
+ (outputs '("out")) ;only one output
(arguments
`(#:modules ((guix build utils))
#:builder
;; (‘genchecksum’, ‘gcc-nm’, etc.) rely on C++ headers.
(copy-recursively (string-append gcc "/include/c++")
(string-append includedir "/c++"))
- #t))))
+
+ ;; For native builds, check whether the binaries actually work.
+ ,(if (%current-target-system)
+ '#t
+ '(every (lambda (prog)
+ (zero? (system* (string-append gcc "/bin/" prog)
+ "--version")))
+ '("gcc" "g++" "cpp")))))))
(inputs `(("gcc" ,%gcc-static)))))
(define %guile-static
(patches patches)))
(guile (package (inherit guile-2.0)
(name (string-append (package-name guile-2.0) "-static"))
+ (replacement #f)
(source source)
(synopsis "Statically-linked and relocatable Guile")
(define (tarball-package pkg)
"Return a package containing a tarball of PKG."
(package (inherit pkg)
- (location (source-properties->location (current-source-location)))
(name (string-append (package-name pkg) "-tarball"))
(build-system trivial-build-system)
(native-inputs `(("tar" ,tar)
,(or (%current-target-system)
(%current-system))
".tar.xz")
- "."))))))))))
+ "."
+ ;; avoid non-determinism in the archive
+ "--sort=name" "--mtime=@0"
+ "--owner=root:0" "--group=root:0"))))))))))
(define %bootstrap-binaries-tarball
;; A tarball with the statically-linked bootstrap binaries.
;; A tarball with the statically-linked Binutils programs.
(tarball-package %binutils-static-stripped))
-(define %glibc-bootstrap-tarball
+(define (%glibc-bootstrap-tarball)
;; A tarball with GNU libc's shared libraries, dynamic linker, and headers.
- (tarball-package %glibc-stripped))
+ (tarball-package (%glibc-stripped)))
(define %gcc-bootstrap-tarball
;; A tarball with a dynamic-linked GCC and its headers.
(inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
("gcc-tarball" ,%gcc-bootstrap-tarball)
("binutils-tarball" ,%binutils-bootstrap-tarball)
- ("glibc-tarball" ,%glibc-bootstrap-tarball)
+ ("glibc-tarball" ,(%glibc-bootstrap-tarball))
("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
- (synopsis #f)
- (description #f)
+ (synopsis "Tarballs containing all the bootstrap binaries")
+ (description synopsis)
(home-page #f)
(license gpl3+)))