gnu: linux-libre-headers: Do not retain reference to the bootstrap tools.
[jackhill/guix/guix.git] / gnu / packages / make-bootstrap.scm
index 2e3e9ec..9eb868a 100644 (file)
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -23,6 +23,7 @@
   #:use-module (guix build-system trivial)
   #:use-module (guix build-system gnu)
   #:use-module ((gnu packages) #:select (search-patch))
+  #:use-module ((gnu packages commencement) #:select (%final-inputs))
   #:use-module (gnu packages base)
   #:use-module (gnu packages cross-base)
   #:use-module (gnu packages bash)
@@ -103,6 +104,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
             ,@%final-inputs))
         `(("libc" ,(glibc-for-bootstrap))
           ("gcc" ,(package (inherit gcc-4.8)
+                    (outputs '("out")) ; all in one so libgcc_s is easily found
                     (inputs
                      `(("libc",(glibc-for-bootstrap))
                        ,@(package-inputs gcc-4.8)))))
@@ -372,10 +374,6 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
              (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)))
                            (if target
@@ -393,6 +391,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
   (package-with-relocatable-glibc
    (package (inherit gcc-4.8)
      (name "gcc-static")
+     (outputs '("out"))                           ; all in one
      (arguments
       `(#:modules ((guix build utils)
                    (guix build gnu-build-system)
@@ -404,9 +403,20 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
             ((#: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"
@@ -417,10 +427,18 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
                        "--disable-decimal-float")
                       (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
@@ -442,6 +460,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
     (name "gcc-stripped")
     (build-system trivial-build-system)
     (source #f)
+    (outputs '("out"))                            ;only one output
     (arguments
      `(#:modules ((guix build utils))
        #:builder
@@ -475,7 +494,14 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
            ;; (‘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