1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2018, 2019 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2018, 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
7 ;;; Copyright © 2019 Marius Bakke <mbakke@fastmail.com>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages make-bootstrap)
25 #:use-module (guix utils)
26 #:use-module (guix packages)
27 #:use-module ((guix licenses) #:select (gpl3+))
28 #:use-module (guix build-system trivial)
29 #:use-module (guix build-system gnu)
30 #:use-module ((gnu packages) #:select (search-patch))
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages cross-base)
33 #:use-module (gnu packages bash)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages gawk)
36 #:use-module (gnu packages gcc)
37 #:use-module (gnu packages guile)
38 #:use-module (gnu packages bdw-gc)
39 #:use-module (gnu packages libunistring)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages hurd)
42 #:use-module (gnu packages mes)
43 #:use-module (gnu packages multiprecision)
44 #:use-module (ice-9 match)
45 #:use-module (srfi srfi-1)
46 #:export (%bootstrap-binaries-tarball
47 %linux-libre-headers-bootstrap-tarball
48 %binutils-bootstrap-tarball
49 %glibc-bootstrap-tarball
50 %gcc-bootstrap-tarball
51 %guile-bootstrap-tarball
52 %mescc-tools-bootstrap-tarball
53 %mes-bootstrap-tarball
56 %guile-static-stripped))
60 ;;; This module provides tools to build tarballs of the "bootstrap binaries"
61 ;;; used in (gnu packages bootstrap). These statically-linked binaries are
62 ;;; taken for granted and used as the root of the whole bootstrap procedure.
66 (define* (glibc-for-bootstrap #:optional (base glibc))
67 "Return a libc deriving from BASE whose `system' and `popen' functions looks
68 for `sh' in $PATH, and without nscd, and with static NSS modules."
69 (package (inherit base)
70 (source (origin (inherit (package-source base))
71 (patches (cons (search-patch "glibc-bootstrap-system.patch")
72 (origin-patches (package-source base))))))
74 (substitute-keyword-arguments (package-arguments base)
75 ((#:configure-flags flags)
76 ;; Arrange so that getaddrinfo & co. do not contact the nscd,
77 ;; and can use statically-linked NSS modules.
78 `(cons* "--disable-nscd" "--disable-build-nscd"
82 ;; Remove the 'debug' output to allow bit-reproducible builds (when the
83 ;; 'debug' output is used, ELF files end up with a .gnu_debuglink, which
84 ;; includes a CRC of the corresponding debugging symbols; those symbols
85 ;; contain store file names, so the CRC changes at every rebuild.)
86 (outputs (delete "debug" (package-outputs base)))))
88 (define (package-with-relocatable-glibc p)
89 "Return a variant of P that uses the libc as defined by
90 `glibc-for-bootstrap'."
92 (define (cross-bootstrap-libc)
93 (let ((target (%current-target-system)))
95 ;; `cross-libc' already returns a cross libc, so clear
96 ;; %CURRENT-TARGET-SYSTEM.
97 (parameterize ((%current-target-system #f))
98 (cross-libc target)))))
100 ;; Standard inputs with the above libc and corresponding GCC.
103 (if (%current-target-system) ; is this package cross built?
104 `(("cross-libc" ,(cross-bootstrap-libc)))
107 (define (native-inputs)
108 (if (%current-target-system)
109 (let* ((target (%current-target-system))
112 #:xbinutils (cross-binutils target)
113 #:libc (cross-bootstrap-libc))))
114 `(("cross-gcc" ,(package
117 ;; Ensure the cross libc headers appears on the
118 ;; C++ system header search path.
119 (cons (search-path-specification
120 (variable "CROSS_CPLUS_INCLUDE_PATH")
121 (files '("include")))
122 (package-search-paths gcc)))))
123 ("cross-binutils" ,(cross-binutils target))
125 `(("libc" ,(glibc-for-bootstrap))
126 ("libc:static" ,(glibc-for-bootstrap) "static")
127 ("gcc" ,(package (inherit gcc)
128 (outputs '("out")) ;all in one so libgcc_s is easily found
130 ;; Set CPLUS_INCLUDE_PATH so GCC is able to find the libc
132 (cons (search-path-specification
133 (variable "CPLUS_INCLUDE_PATH")
134 (files '("include")))
135 (package-native-search-paths gcc)))
137 `(;; Distinguish the name so we can refer to it below.
138 ("bootstrap-libc" ,(glibc-for-bootstrap))
139 ("libc:static" ,(glibc-for-bootstrap) "static")
140 ,@(package-inputs gcc)))
142 (substitute-keyword-arguments (package-arguments gcc)
144 `(modify-phases ,phases
145 (add-before 'configure 'treat-glibc-as-system-header
146 (lambda* (#:key inputs #:allow-other-keys)
147 (let ((libc (assoc-ref inputs "bootstrap-libc")))
148 ;; GCCs build processes requires that the libc
149 ;; we're building against is on the system header
151 (for-each (lambda (var)
152 (setenv var (string-append libc "/include")))
153 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"))
155 ,@(fold alist-delete (%final-inputs) '("libc" "gcc")))))
157 (package-with-explicit-inputs p inputs
158 (current-source-location)
159 #:native-inputs native-inputs))
161 (define static-bash-for-bootstrap
163 (inherit static-bash)
165 (inherit (package-source static-bash))
167 (cons (search-patch "bash-reproducible-linux-pgrp-pipe.patch")
168 (origin-patches (package-source static-bash))))))))
170 (define %static-inputs
171 ;; Packages that are to be used as %BOOTSTRAP-INPUTS.
172 (let ((coreutils (package (inherit coreutils)
176 "--disable-silent-rules"
177 "--enable-no-install-program=stdbuf,libstdbuf.so"
178 "CFLAGS=-Os -g0" ; smaller, please
179 "LDFLAGS=-static -pthread"
181 ;; Work around a cross-compilation bug whereby libcoreutils.a
182 ;; would provide '__mktime_internal', which conflicts with the
184 ,@(if (%current-target-system)
185 `("gl_cv_func_working_mktime=yes")
188 #:tests? #f ; signal-related Gnulib tests fail
189 ,@(package-arguments coreutils)))
191 ;; Remove optional dependencies such as GMP. Keep Perl
192 ;; except if it's missing (which is the case when
194 (inputs (match (assoc "perl" (package-inputs coreutils))
198 ;; Remove the 'debug' output (see above for the reason.)
200 (bzip2 (package (inherit bzip2)
202 (substitute-keyword-arguments (package-arguments bzip2)
204 `(modify-phases ,phases
205 (add-before 'build 'dash-static
207 (substitute* "Makefile"
208 (("^LDFLAGS[[:blank:]]*=.*$")
209 "LDFLAGS = -static"))
211 (xz (package (inherit xz)
214 `(#:strip-flags '("--strip-all")
215 #:phases (modify-phases %standard-phases
216 (add-before 'configure 'static-executable
218 ;; Ask Libtool for a static executable.
219 (substitute* "src/xz/Makefile.in"
221 "xz_LDADD = -all-static"))
223 (gawk (package (inherit gawk)
224 (source (origin (inherit (package-source gawk))
225 (patches (cons (search-patch "gawk-shell.patch")
227 (package-source gawk))))))
229 `(;; Starting from gawk 4.1.0, some of the tests for the
230 ;; plug-in mechanism just fail on static builds:
232 ;; ./fts.awk:1: error: can't open shared library `filefuncs' for reading (No such file or directory)
235 ,@(substitute-keyword-arguments (package-arguments gawk)
237 `(modify-phases ,phases
238 (add-before 'configure 'no-export-dynamic
240 ;; Since we use `-static', remove
241 ;; `-export-dynamic'.
242 (substitute* "configure"
243 (("-Wl,-export-dynamic") ""))
245 (inputs (if (%current-target-system)
246 `(("bash" ,static-bash-for-bootstrap))
248 (tar (package (inherit tar)
250 `(;; Work around a cross-compilation bug whereby libgnu.a would provide
251 ;; '__mktime_internal', which conflicts with the one in libc.a.
252 ,@(if (%current-target-system)
253 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
255 ,@(substitute-keyword-arguments (package-arguments tar)
257 `(modify-phases ,phases
258 (replace 'set-shell-file-name
260 ;; Do not use "/bin/sh" to run programs; see
261 ;; <http://lists.gnu.org/archive/html/guix-devel/2016-09/msg02272.html>.
262 (substitute* "src/system.c"
264 (("execv ") "execvp "))
266 ;; We don't want to retain a reference to /gnu/store in the bootstrap
267 ;; versions of egrep/fgrep, so we remove the custom phase added since
268 ;; grep@2.25. The effect is 'egrep' and 'fgrep' look for 'grep' in
272 (inputs '()) ;remove PCRE, which is optional
274 (substitute-keyword-arguments (package-arguments grep)
276 `(modify-phases ,phases
277 (delete 'fix-egrep-and-fgrep)))))))
278 (finalize (compose static-package
279 package-with-relocatable-glibc)))
280 `(,@(map (match-lambda
282 (list name (finalize package))))
288 ("coreutils" ,coreutils)
292 ("bash" ,static-bash-for-bootstrap))))
294 (define %static-binaries
296 (name "static-binaries")
298 (build-system trivial-build-system)
300 (inputs %static-inputs)
302 `(#:modules ((guix build utils))
305 (use-modules (ice-9 ftw)
312 (define (directory-contents dir)
313 (map (cut string-append dir "/" <>)
314 (scandir dir (negate (cut member <> '("." ".."))))))
316 (define (copy-directory source destination)
317 (for-each (lambda (file)
318 (format #t "copying ~s...~%" file)
320 (string-append destination "/"
322 (directory-contents source)))
324 (let* ((out (assoc-ref %outputs "out"))
325 (bin (string-append out "/bin")))
328 ;; Copy Coreutils binaries.
329 (let* ((coreutils (assoc-ref %build-inputs "coreutils"))
330 (source (string-append coreutils "/bin")))
331 (copy-directory source bin))
333 ;; For the other inputs, copy just one binary, which has the
334 ;; same name as the input.
335 (for-each (match-lambda
337 (let ((source (string-append dir "/bin/" name)))
338 (format #t "copying ~s...~%" source)
340 (string-append bin "/" name)))))
341 (alist-delete "coreutils" %build-inputs))
343 ;; But of course, there are exceptions to this rule.
344 (let ((grep (assoc-ref %build-inputs "grep")))
345 (install-file (string-append grep "/bin/fgrep") bin)
346 (install-file (string-append grep "/bin/egrep") bin))
348 ;; Clear references to the store path.
349 (for-each remove-store-references
350 (directory-contents bin))
352 (with-directory-excursion bin
353 ;; Programs such as Perl's build system want these aliases.
354 (symlink "bash" "sh")
355 (symlink "gawk" "awk"))
358 (synopsis "Statically-linked bootstrap binaries")
360 "Binaries used to bootstrap the distribution.")
364 (define %linux-libre-headers-stripped
365 ;; The subset of Linux-Libre-Headers that we need.
366 (package (inherit linux-libre-headers)
367 (name (string-append (package-name linux-libre-headers) "-stripped"))
368 (build-system trivial-build-system)
371 `(#:modules ((guix build utils)
372 (guix build make-bootstrap))
375 (use-modules (guix build utils)
376 (guix build make-bootstrap))
378 (let* ((in (assoc-ref %build-inputs "linux-libre-headers"))
379 (out (assoc-ref %outputs "out")))
380 (copy-linux-headers out in)
382 (inputs `(("linux-libre-headers" ,linux-libre-headers)))))
384 (define %binutils-static
385 ;; Statically-linked Binutils.
386 (package (inherit binutils)
387 (name "binutils-static")
389 `(#:configure-flags (cons "--disable-gold"
390 ,(match (memq #:configure-flags
391 (package-arguments binutils))
392 ((#:configure-flags flags _ ...)
394 #:strip-flags '("--strip-all")
395 #:phases (modify-phases %standard-phases
396 (add-before 'configure 'all-static
398 ;; The `-all-static' libtool flag can only be passed
399 ;; after `configure', since configure tests don't use
400 ;; libtool, and only for executables built with libtool.
401 (substitute* '("binutils/Makefile.in"
404 (("^LDFLAGS =(.*)$" line)
406 "\nAM_LDFLAGS = -static -all-static\n")))
409 (define %binutils-static-stripped
410 ;; The subset of Binutils that we need.
411 (package (inherit %binutils-static)
412 (name (string-append (package-name %binutils-static) "-stripped"))
413 (build-system trivial-build-system)
416 `(#:modules ((guix build utils))
419 (use-modules (guix build utils))
421 (setvbuf (current-output-port) _IOLBF)
422 (let* ((in (assoc-ref %build-inputs "binutils"))
423 (out (assoc-ref %outputs "out"))
424 (bin (string-append out "/bin")))
426 (for-each (lambda (file)
427 (let ((target (string-append bin "/" file)))
428 (format #t "copying `~a'...~%" file)
429 (copy-file (string-append in "/bin/" file)
431 (remove-store-references target)))
432 '("ar" "as" "ld" "nm" "objcopy" "objdump"
433 "ranlib" "readelf" "size" "strings" "strip"))
435 (inputs `(("binutils" ,%binutils-static)))))
437 (define (%glibc-stripped)
438 ;; GNU libc's essential shared libraries, dynamic linker, and headers,
439 ;; with all references to store directories stripped. As a result,
440 ;; libc.so is unusable and need to be patched for proper relocation.
441 (let ((glibc (glibc-for-bootstrap)))
442 (package (inherit glibc)
443 (name "glibc-stripped")
444 (build-system trivial-build-system)
446 `(#:modules ((guix build utils)
447 (guix build make-bootstrap))
450 (use-modules (guix build make-bootstrap))
451 (make-stripped-libc (assoc-ref %outputs "out")
452 (assoc-ref %build-inputs "libc")
453 (assoc-ref %build-inputs "kernel-headers")))))
454 (inputs `(("kernel-headers"
455 ,(if (or (and (%current-target-system)
456 (hurd-triplet? (%current-target-system)))
457 (string-suffix? "-hurd" (%current-system)))
459 linux-libre-headers))
460 ("libc" ,(let ((target (%current-target-system)))
463 (parameterize ((%current-target-system #f))
464 (cross-libc target)))
467 (propagated-inputs '())
470 (outputs '("out")))))
473 ;; A statically-linked GCC, with stripped-down functionality.
474 (package-with-relocatable-glibc
475 (package (inherit gcc)
477 (outputs '("out")) ; all in one
479 `(#:modules ((guix build utils)
480 (guix build gnu-build-system)
484 ,@(substitute-keyword-arguments (package-arguments gcc)
486 ((#:implicit-inputs? _) #t)
487 ((#:configure-flags flags)
489 ;; We don't need a full bootstrap here.
490 "--disable-bootstrap"
492 ;; Make sure '-static' is passed where it matters.
493 "--with-stage1-ldflags=-static"
495 ;; GCC 4.8+ requires a C++ compiler and library.
496 "--enable-languages=c,c++"
498 ;; Make sure gcc-nm doesn't require liblto_plugin.so.
503 "--disable-libmudflap"
504 "--disable-libatomic"
505 "--disable-libsanitizer"
508 "--disable-libcilkrts"
511 "--disable-libquadmath")
512 (remove (cut string-match "--(.*plugin|enable-languages)" <>)
515 `(modify-phases ,phases
516 (add-after 'pre-configure 'remove-lgcc_s
518 ;; Remove the '-lgcc_s' added to GNU_USER_TARGET_LIB_SPEC in
519 ;; the 'pre-configure phase of our main gcc package, because
520 ;; that shared library is not present in this static gcc. See
521 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-01/msg00008.html>.
522 (substitute* (cons "gcc/config/rs6000/sysv4.h"
523 (find-files "gcc/config"
525 ((" -lgcc_s}}") "}}"))
528 `(("zlib:static" ,zlib "static")
529 ,@(package-inputs gcc)))
531 (if (%current-target-system)
532 `(;; When doing a Canadian cross, we need GMP/MPFR/MPC both
533 ;; as target inputs and as native inputs; the latter is
534 ;; needed when building build-time tools ('genconstants',
535 ;; etc.) Failing to do that leads to misdetections of
536 ;; declarations by 'gcc/configure', and eventually to
537 ;; duplicate declarations as reported in
538 ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59217>.
540 ("mpfr-native" ,mpfr)
542 ,@(package-native-inputs gcc))
543 (package-native-inputs gcc))))))
545 (define %gcc-stripped
546 ;; The subset of GCC files needed for bootstrap.
547 (package (inherit gcc)
548 (name "gcc-stripped")
549 (build-system trivial-build-system)
551 (outputs '("out")) ;only one output
553 `(#:modules ((guix build utils))
556 (use-modules (srfi srfi-1)
560 (setvbuf (current-output-port) _IOLBF)
561 (let* ((out (assoc-ref %outputs "out"))
562 (bindir (string-append out "/bin"))
563 (libdir (string-append out "/lib"))
564 (includedir (string-append out "/include"))
565 (libexecdir (string-append out "/libexec"))
566 (gcc (assoc-ref %build-inputs "gcc")))
567 (copy-recursively (string-append gcc "/bin") bindir)
568 (for-each remove-store-references
569 (find-files bindir ".*"))
571 (copy-recursively (string-append gcc "/lib") libdir)
572 (for-each remove-store-references
573 (remove (cut string-suffix? ".h" <>)
574 (find-files libdir ".*")))
576 (copy-recursively (string-append gcc "/libexec")
578 (for-each remove-store-references
579 (find-files libexecdir ".*"))
581 ;; Starting from GCC 4.8, helper programs built natively
582 ;; (‘genchecksum’, ‘gcc-nm’, etc.) rely on C++ headers.
583 (copy-recursively (string-append gcc "/include/c++")
584 (string-append includedir "/c++"))
586 ;; For native builds, check whether the binaries actually work.
587 ,@(if (%current-target-system)
589 '((for-each (lambda (prog)
590 (invoke (string-append gcc "/bin/" prog)
592 '("gcc" "g++" "cpp"))))
595 (inputs `(("gcc" ,%gcc-static)))))
597 ;; Two packages: first build static, bare minimum content.
598 (define %mescc-tools-static
599 ;; A statically linked MesCC Tools.
601 (inherit mescc-tools-0.5.2)
602 (name "mescc-tools-static")
604 `(#:system "i686-linux"
605 ,@(substitute-keyword-arguments (package-arguments mescc-tools)
606 ((#:make-flags flags)
607 `(cons "CC=gcc -static" ,flags)))))))
609 ;; ... next remove store references.
610 (define %mescc-tools-static-stripped
611 ;; A statically linked Mescc Tools with store references removed, for
614 (inherit %mescc-tools-static)
615 (name (string-append (package-name %mescc-tools-static) "-stripped"))
616 (build-system trivial-build-system)
618 `(#:modules ((guix build utils))
621 (use-modules (guix build utils))
622 (let* ((in (assoc-ref %build-inputs "mescc-tools"))
623 (out (assoc-ref %outputs "out"))
624 (bin (string-append out "/bin")))
626 (for-each (lambda (file)
627 (let ((target (string-append bin "/" file)))
628 (format #t "copying `~a'...~%" file)
629 (copy-file (string-append in "/bin/" file)
631 (remove-store-references target)))
632 '( "M1" "blood-elf" "hex2"))
634 (inputs `(("mescc-tools" ,%mescc-tools-static)))))
636 ;; Two packages: first build static, bare minimum content.
637 (define-public %mes-minimal
638 ;; A minimal Mes without documentation.
639 (let ((triplet "i686-unknown-linux-gnu"))
644 `(("guile" ,guile-2.2)))
646 `(#:system "i686-linux"
648 #:configure-flags '("--mes")
650 (modify-phases %standard-phases
651 (delete 'patch-shebangs)
652 (add-after 'install 'strip-install
654 (let* ((out (assoc-ref %outputs "out"))
655 (share (string-append out "/share")))
656 (delete-file-recursively (string-append out "/lib/guile"))
657 (delete-file-recursively (string-append share "/guile"))
658 (delete-file-recursively (string-append share "/mes/scaffold"))
660 (for-each delete-file
662 (string-append share "/mes/lib")
663 "\\.(h|c)")))))))))))
665 ;; next remove store references.
666 (define %mes-minimal-stripped
667 ;; A minimal Mes with store references removed, for bootstrap.
669 (inherit %mes-minimal)
670 (name (string-append (package-name %mes-minimal) "-stripped"))
671 (build-system trivial-build-system)
673 `(#:modules ((guix build utils))
676 (use-modules (guix build utils))
677 (let ((in (assoc-ref %build-inputs "mes"))
678 (out (assoc-ref %outputs "out")))
680 (copy-recursively in out)
681 (for-each (lambda (dir)
682 (for-each remove-store-references
683 (find-files (string-append out "/" dir)
685 '("bin" "share/mes"))
687 (inputs `(("mes" ,%mes-minimal)))))
689 (define %guile-static
690 ;; A statically-linked Guile that is relocatable--i.e., it can search
691 ;; .scm and .go files relative to its installation directory, rather
692 ;; than in hard-coded configure-time paths.
693 (let* ((patches (cons* (search-patch "guile-relocatable.patch")
694 (search-patch "guile-2.2-default-utf8.patch")
695 (search-patch "guile-linux-syscalls.patch")
696 (origin-patches (package-source guile-2.2))))
697 (source (origin (inherit (package-source guile-2.2))
699 (guile (package (inherit guile-2.2)
700 (name (string-append (package-name guile-2.2) "-static"))
702 (synopsis "Statically-linked and relocatable Guile")
704 ;; Remove the 'debug' output (see above for the reason.)
705 (outputs (delete "debug" (package-outputs guile-2.2)))
708 `(("libunistring:static" ,libunistring "static")
709 ,@(package-inputs guile-2.2)))
713 ,@(alist-delete "bdw-gc"
714 (package-propagated-inputs guile-2.2))))
716 (substitute-keyword-arguments (package-arguments guile-2.2)
717 ((#:configure-flags flags '())
718 ;; When `configure' checks for ltdl availability, it
719 ;; doesn't try to link using libtool, and thus fails
720 ;; because of a missing -ldl. Work around that.
722 ((#:phases phases '%standard-phases)
723 `(modify-phases ,phases
725 ;; Do not record the absolute file name of 'sh' in
726 ;; (ice-9 popen). This makes 'open-pipe' unusable in
727 ;; a build chroot ('open-pipe*' is fine) but avoids
728 ;; keeping a reference to Bash.
729 (delete 'pre-configure)
731 (add-before 'configure 'static-guile
733 (substitute* "libguile/Makefile.in"
734 ;; Create a statically-linked `guile'
736 (("^guile_LDFLAGS =")
737 "guile_LDFLAGS = -all-static")
739 ;; Add `-ldl' *after* libguile-2.2.la.
740 (("^guile_LDADD =(.*)$" _ ldadd)
741 (string-append "guile_LDADD = "
742 (string-trim-right ldadd)
745 ;; There are uses of `dynamic-link' in
746 ;; {foreign,coverage}.test that don't fly here.
748 ((#:parallel-build? _ #f)
749 ;; Work around the fact that the Guile build system is
750 ;; not deterministic when parallel-build is enabled.
752 (package-with-relocatable-glibc (static-package guile))))
754 (define %guile-static-stripped
755 ;; A stripped static Guile binary, for use during bootstrap.
756 (package (inherit %guile-static)
757 (name "guile-static-stripped")
758 (build-system trivial-build-system)
760 ;; The end result should depend on nothing but itself.
761 `(#:allowed-references ("out")
762 #:modules ((guix build utils))
765 (use-modules (guix build utils))
767 (let* ((in (assoc-ref %build-inputs "guile"))
768 (out (assoc-ref %outputs "out"))
769 (guile1 (string-append in "/bin/guile"))
770 (guile2 (string-append out "/bin/guile")))
771 (mkdir-p (string-append out "/share/guile/2.2"))
772 (copy-recursively (string-append in "/share/guile/2.2")
773 (string-append out "/share/guile/2.2"))
775 (mkdir-p (string-append out "/lib/guile/2.2/ccache"))
776 (copy-recursively (string-append in "/lib/guile/2.2/ccache")
777 (string-append out "/lib/guile/2.2/ccache"))
779 (mkdir (string-append out "/bin"))
780 (copy-file guile1 guile2)
782 ;; Verify that the relocated Guile works.
783 ,@(if (%current-target-system)
785 '((invoke guile2 "--version")))
787 ;; Strip store references.
788 (remove-store-references guile2)
790 ;; Verify that the stripped Guile works. If it aborts, it could be
791 ;; that it tries to open iconv descriptors and fails because libc's
792 ;; iconv data isn't available (see `guile-default-utf8.patch'.)
793 ,@(if (%current-target-system)
795 '((invoke guile2 "--version")))
798 (inputs `(("guile" ,%guile-static)))
800 (synopsis "Minimal statically-linked and relocatable Guile")))
802 (define (tarball-package pkg)
803 "Return a package containing a tarball of PKG."
804 (package (inherit pkg)
805 (name (string-append (package-name pkg) "-tarball"))
806 (build-system trivial-build-system)
807 (native-inputs `(("tar" ,tar)
809 (inputs `(("input" ,pkg)))
811 (let ((name (package-name pkg))
812 (version (package-version pkg)))
813 `(#:modules ((guix build utils))
816 (use-modules (guix build utils))
817 (let ((out (assoc-ref %outputs "out"))
818 (input (assoc-ref %build-inputs "input"))
819 (tar (assoc-ref %build-inputs "tar"))
820 (xz (assoc-ref %build-inputs "xz")))
822 (set-path-environment-variable "PATH" '("bin") (list tar xz))
823 (with-directory-excursion input
825 (string-append out "/"
828 ,(or (%current-target-system)
832 ;; avoid non-determinism in the archive
833 "--sort=name" "--mtime=@0"
834 "--owner=root:0" "--group=root:0")))))))))
836 (define %bootstrap-binaries-tarball
837 ;; A tarball with the statically-linked bootstrap binaries.
838 (tarball-package %static-binaries))
840 (define %linux-libre-headers-bootstrap-tarball
841 ;; A tarball with the statically-linked Linux-Libre-Headers programs.
842 (tarball-package %linux-libre-headers-stripped))
844 (define %binutils-bootstrap-tarball
845 ;; A tarball with the statically-linked Binutils programs.
846 (tarball-package %binutils-static-stripped))
848 (define (%glibc-bootstrap-tarball)
849 ;; A tarball with GNU libc's shared libraries, dynamic linker, and headers.
850 (tarball-package (%glibc-stripped)))
852 (define %gcc-bootstrap-tarball
853 ;; A tarball with a dynamic-linked GCC and its headers.
854 (tarball-package %gcc-stripped))
856 (define %guile-bootstrap-tarball
857 ;; A tarball with the statically-linked, relocatable Guile.
858 (tarball-package %guile-static-stripped))
860 (define %mescc-tools-bootstrap-tarball
861 ;; A tarball with statically-linked MesCC binary seed.
862 (tarball-package %mescc-tools-static-stripped))
864 (define %mes-bootstrap-tarball
865 ;; A tarball with Mes binary seed.
866 (tarball-package %mes-minimal-stripped))
868 (define %bootstrap-tarballs
869 ;; A single derivation containing all the bootstrap tarballs, for
872 (name "bootstrap-tarballs")
875 (build-system trivial-build-system)
877 `(#:modules ((guix build utils))
879 (let ((out (assoc-ref %outputs "out")))
880 (use-modules (guix build utils)
884 (setvbuf (current-output-port) _IOLBF)
887 (for-each (match-lambda
889 (for-each (lambda (file)
890 (format #t "~a -> ~a~%" file out)
891 (symlink file (basename file)))
892 (find-files directory "\\.tar\\."))))
895 (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
896 ,@(match (or (%current-target-system) (%current-system))
897 ((or "i686-linux" "x86_64-linux")
898 `(("bootstrap-mescc-tools" ,%mescc-tools-bootstrap-tarball)
899 ("bootstrap-mes" ,%mes-bootstrap-tarball)
900 ("bootstrap-linux-libre-headers"
901 ,%linux-libre-headers-bootstrap-tarball)))
902 (_ `(("gcc-tarball" ,%gcc-bootstrap-tarball)
903 ("binutils-tarball" ,%binutils-bootstrap-tarball)
904 ("glibc-tarball" ,(%glibc-bootstrap-tarball)))))
905 ("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
906 (synopsis "Tarballs containing all the bootstrap binaries")
907 (description synopsis)
911 ;;; make-bootstrap.scm ends here