1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 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 memoization)
28 #:use-module ((guix licenses) #:select (gpl3+))
29 #:use-module (guix build-system trivial)
30 #:use-module (guix build-system gnu)
31 #:use-module ((gnu packages) #:select (search-patch))
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages cross-base)
34 #:use-module (gnu packages bash)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages gawk)
37 #:use-module (gnu packages gcc)
38 #:use-module (gnu packages guile)
39 #:use-module (gnu packages bdw-gc)
40 #:use-module (gnu packages libunistring)
41 #:use-module (gnu packages linux)
42 #:use-module (gnu packages hurd)
43 #:use-module (gnu packages mes)
44 #:use-module (gnu packages multiprecision)
45 #:use-module (ice-9 match)
46 #:use-module (srfi srfi-1)
47 #:export (%bootstrap-binaries-tarball
48 %linux-libre-headers-bootstrap-tarball
49 %binutils-bootstrap-tarball
50 %glibc-bootstrap-tarball
51 %gcc-bootstrap-tarball
52 %guile-bootstrap-tarball
53 %mescc-tools-bootstrap-tarball
54 %mes-bootstrap-tarball
57 %guile-static-stripped))
61 ;;; This module provides tools to build tarballs of the "bootstrap binaries"
62 ;;; used in (gnu packages bootstrap). These statically-linked binaries are
63 ;;; taken for granted and used as the root of the whole bootstrap procedure.
67 (define glibc-for-bootstrap
69 "Return a libc deriving from BASE whose `system' and `popen' functions looks
70 for `sh' in $PATH, and without nscd, and with static NSS modules."
73 (source (origin (inherit (package-source base))
74 (patches (cons (search-patch "glibc-bootstrap-system.patch")
75 (origin-patches (package-source base))))))
77 (substitute-keyword-arguments (package-arguments base)
78 ((#:configure-flags flags)
79 ;; Arrange so that getaddrinfo & co. do not contact the nscd,
80 ;; and can use statically-linked NSS modules.
81 `(cons* "--disable-nscd" "--disable-build-nscd"
85 ;; Remove the 'debug' output to allow bit-reproducible builds (when the
86 ;; 'debug' output is used, ELF files end up with a .gnu_debuglink, which
87 ;; includes a CRC of the corresponding debugging symbols; those symbols
88 ;; contain store file names, so the CRC changes at every rebuild.)
89 (outputs (delete "debug" (package-outputs base))))))
91 (define gcc-for-bootstrap
93 "Return a variant of GCC that uses the bootstrap variant of GLIBC."
96 (outputs '("out")) ;all in one so libgcc_s is easily found
98 ;; Set CPLUS_INCLUDE_PATH so GCC is able to find the libc
100 (cons (search-path-specification
101 (variable "CPLUS_INCLUDE_PATH")
102 (files '("include")))
103 (package-native-search-paths gcc)))
105 `( ;; Distinguish the name so we can refer to it below.
106 ("bootstrap-libc" ,(glibc-for-bootstrap glibc))
107 ("libc:static" ,(glibc-for-bootstrap glibc) "static")
108 ,@(package-inputs gcc)))
110 (substitute-keyword-arguments (package-arguments gcc)
112 `(modify-phases ,phases
113 (add-before 'configure 'treat-glibc-as-system-header
114 (lambda* (#:key inputs #:allow-other-keys)
115 (let ((libc (assoc-ref inputs "bootstrap-libc")))
116 ;; GCCs build processes requires that the libc
117 ;; we're building against is on the system header
119 (for-each (lambda (var)
120 (setenv var (string-append libc "/include")))
121 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"))
124 (define (package-with-relocatable-glibc p)
125 "Return a variant of P that uses the libc as defined by
126 `glibc-for-bootstrap'."
128 (define (cross-bootstrap-libc target)
130 ;; `cross-libc' already returns a cross libc, so clear
131 ;; %CURRENT-TARGET-SYSTEM.
132 (parameterize ((%current-target-system #f))
133 (cross-libc target))))
135 ;; Standard inputs with the above libc and corresponding GCC.
138 (if (%current-target-system) ; is this package cross built?
140 ,(cross-bootstrap-libc (%current-target-system))))
143 (define (native-inputs)
144 (if (%current-target-system)
145 (let* ((target (%current-target-system))
148 #:xbinutils (cross-binutils target)
149 #:libc (cross-bootstrap-libc target))))
150 `(("cross-gcc" ,(package
153 ;; Ensure the cross libc headers appears on the
154 ;; C++ system header search path.
155 (cons (search-path-specification
156 (variable "CROSS_CPLUS_INCLUDE_PATH")
157 (files '("include")))
158 (package-search-paths gcc)))))
159 ("cross-binutils" ,(cross-binutils target))
161 `(("libc" ,(glibc-for-bootstrap glibc))
162 ("libc:static" ,(glibc-for-bootstrap glibc) "static")
163 ("gcc" ,(gcc-for-bootstrap glibc))
164 ,@(fold alist-delete (%final-inputs) '("libc" "gcc")))))
166 (package-with-explicit-inputs p inputs
167 (current-source-location)
168 #:native-inputs native-inputs))
170 (define static-bash-for-bootstrap
172 (inherit static-bash)
174 (inherit (package-source static-bash))
176 (cons (search-patch "bash-reproducible-linux-pgrp-pipe.patch")
177 (origin-patches (package-source static-bash))))))))
179 (define %static-inputs
180 ;; Packages that are to be used as %BOOTSTRAP-INPUTS.
181 (let ((coreutils (package (inherit coreutils)
185 "--disable-silent-rules"
186 "--enable-no-install-program=stdbuf,libstdbuf.so"
187 "CFLAGS=-Os -g0" ; smaller, please
188 "LDFLAGS=-static -pthread"
190 ;; Work around a cross-compilation bug whereby libcoreutils.a
191 ;; would provide '__mktime_internal', which conflicts with the
193 ,@(if (%current-target-system)
194 `("gl_cv_func_working_mktime=yes")
197 #:tests? #f ; signal-related Gnulib tests fail
198 ,@(package-arguments coreutils)))
200 ;; Remove optional dependencies such as GMP. Keep Perl
201 ;; except if it's missing (which is the case when
203 (inputs (match (assoc "perl" (package-inputs coreutils))
207 ;; Remove the 'debug' output (see above for the reason.)
209 (bzip2 (package (inherit bzip2)
211 (substitute-keyword-arguments (package-arguments bzip2)
213 `(modify-phases ,phases
214 (add-before 'build 'dash-static
216 (substitute* "Makefile"
217 (("^LDFLAGS[[:blank:]]*=.*$")
218 "LDFLAGS = -static"))
220 (xz (package (inherit xz)
223 `(#:strip-flags '("--strip-all")
224 #:phases (modify-phases %standard-phases
225 (add-before 'configure 'static-executable
227 ;; Ask Libtool for a static executable.
228 (substitute* "src/xz/Makefile.in"
230 "xz_LDADD = -all-static"))
232 (gawk (package (inherit gawk)
233 (source (origin (inherit (package-source gawk))
234 (patches (cons (search-patch "gawk-shell.patch")
236 (package-source gawk))))))
238 `(;; Starting from gawk 4.1.0, some of the tests for the
239 ;; plug-in mechanism just fail on static builds:
241 ;; ./fts.awk:1: error: can't open shared library `filefuncs' for reading (No such file or directory)
244 ,@(substitute-keyword-arguments (package-arguments gawk)
246 `(modify-phases ,phases
247 (add-before 'configure 'no-export-dynamic
249 ;; Since we use `-static', remove
250 ;; `-export-dynamic'.
251 (substitute* "configure"
252 (("-Wl,-export-dynamic") ""))
254 (inputs (if (%current-target-system)
255 `(("bash" ,static-bash-for-bootstrap))
257 (tar (package (inherit tar)
259 `(;; Work around a cross-compilation bug whereby libgnu.a would provide
260 ;; '__mktime_internal', which conflicts with the one in libc.a.
261 ,@(if (%current-target-system)
262 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
264 ,@(substitute-keyword-arguments (package-arguments tar)
266 `(modify-phases ,phases
267 (replace 'set-shell-file-name
269 ;; Do not use "/bin/sh" to run programs; see
270 ;; <http://lists.gnu.org/archive/html/guix-devel/2016-09/msg02272.html>.
271 (substitute* "src/system.c"
273 (("execv ") "execvp "))
275 ;; We don't want to retain a reference to /gnu/store in the bootstrap
276 ;; versions of egrep/fgrep, so we remove the custom phase added since
277 ;; grep@2.25. The effect is 'egrep' and 'fgrep' look for 'grep' in
281 (inputs '()) ;remove PCRE, which is optional
283 (substitute-keyword-arguments (package-arguments grep)
285 `(modify-phases ,phases
286 (delete 'fix-egrep-and-fgrep)))))))
287 (finalize (compose static-package
288 package-with-relocatable-glibc)))
289 `(,@(map (match-lambda
291 (list name (finalize package))))
297 ("coreutils" ,coreutils)
301 ("bash" ,static-bash-for-bootstrap))))
303 (define %static-binaries
305 (name "static-binaries")
307 (build-system trivial-build-system)
309 (inputs %static-inputs)
311 `(#:modules ((guix build utils))
314 (use-modules (ice-9 ftw)
321 (define (directory-contents dir)
322 (map (cut string-append dir "/" <>)
323 (scandir dir (negate (cut member <> '("." ".."))))))
325 (define (copy-directory source destination)
326 (for-each (lambda (file)
327 (format #t "copying ~s...~%" file)
329 (string-append destination "/"
331 (directory-contents source)))
333 (let* ((out (assoc-ref %outputs "out"))
334 (bin (string-append out "/bin")))
337 ;; Copy Coreutils binaries.
338 (let* ((coreutils (assoc-ref %build-inputs "coreutils"))
339 (source (string-append coreutils "/bin")))
340 (copy-directory source bin))
342 ;; For the other inputs, copy just one binary, which has the
343 ;; same name as the input.
344 (for-each (match-lambda
346 (let ((source (string-append dir "/bin/" name)))
347 (format #t "copying ~s...~%" source)
349 (string-append bin "/" name)))))
350 (alist-delete "coreutils" %build-inputs))
352 ;; But of course, there are exceptions to this rule.
353 (let ((grep (assoc-ref %build-inputs "grep")))
354 (install-file (string-append grep "/bin/fgrep") bin)
355 (install-file (string-append grep "/bin/egrep") bin))
357 ;; Clear references to the store path.
358 (for-each remove-store-references
359 (directory-contents bin))
361 (with-directory-excursion bin
362 ;; Programs such as Perl's build system want these aliases.
363 (symlink "bash" "sh")
364 (symlink "gawk" "awk"))
367 (synopsis "Statically-linked bootstrap binaries")
369 "Binaries used to bootstrap the distribution.")
373 (define %linux-libre-headers-stripped
374 ;; The subset of Linux-Libre-Headers that we need.
375 (package (inherit linux-libre-headers)
376 (name (string-append (package-name linux-libre-headers) "-stripped"))
377 (build-system trivial-build-system)
380 `(#:modules ((guix build utils)
381 (guix build make-bootstrap))
384 (use-modules (guix build utils)
385 (guix build make-bootstrap))
387 (let* ((in (assoc-ref %build-inputs "linux-libre-headers"))
388 (out (assoc-ref %outputs "out")))
389 (copy-linux-headers out in)
391 (inputs `(("linux-libre-headers" ,linux-libre-headers)))))
393 (define %binutils-static
394 ;; Statically-linked Binutils.
395 (package (inherit binutils)
396 (name "binutils-static")
398 `(#:configure-flags (cons "--disable-gold"
399 ,(match (memq #:configure-flags
400 (package-arguments binutils))
401 ((#:configure-flags flags _ ...)
403 #:strip-flags '("--strip-all")
404 #:phases (modify-phases %standard-phases
405 (add-before 'configure 'all-static
407 ;; The `-all-static' libtool flag can only be passed
408 ;; after `configure', since configure tests don't use
409 ;; libtool, and only for executables built with libtool.
410 (substitute* '("binutils/Makefile.in"
413 (("^LDFLAGS =(.*)$" line)
415 "\nAM_LDFLAGS = -static -all-static\n")))
418 (define %binutils-static-stripped
419 ;; The subset of Binutils that we need.
420 (package (inherit %binutils-static)
421 (name (string-append (package-name %binutils-static) "-stripped"))
422 (build-system trivial-build-system)
425 `(#:modules ((guix build utils))
428 (use-modules (guix build utils))
430 (setvbuf (current-output-port) _IOLBF)
431 (let* ((in (assoc-ref %build-inputs "binutils"))
432 (out (assoc-ref %outputs "out"))
433 (bin (string-append out "/bin")))
435 (for-each (lambda (file)
436 (let ((target (string-append bin "/" file)))
437 (format #t "copying `~a'...~%" file)
438 (copy-file (string-append in "/bin/" file)
440 (remove-store-references target)))
441 '("ar" "as" "ld" "nm" "objcopy" "objdump"
442 "ranlib" "readelf" "size" "strings" "strip"))
444 (inputs `(("binutils" ,%binutils-static)))))
446 (define (%glibc-stripped)
447 ;; GNU libc's essential shared libraries, dynamic linker, and headers,
448 ;; with all references to store directories stripped. As a result,
449 ;; libc.so is unusable and need to be patched for proper relocation.
450 (let ((glibc (glibc-for-bootstrap glibc)))
451 (package (inherit glibc)
452 (name "glibc-stripped")
453 (build-system trivial-build-system)
455 `(#:modules ((guix build utils)
456 (guix build make-bootstrap))
459 (use-modules (guix build make-bootstrap))
460 (make-stripped-libc (assoc-ref %outputs "out")
461 (assoc-ref %build-inputs "libc")
462 (assoc-ref %build-inputs "kernel-headers")))))
463 (inputs `(("kernel-headers"
464 ,(if (or (and (%current-target-system)
465 (hurd-triplet? (%current-target-system)))
466 (string-suffix? "-hurd" (%current-system)))
468 linux-libre-headers))
469 ("libc" ,(let ((target (%current-target-system)))
472 (parameterize ((%current-target-system #f))
473 (cross-libc target)))
476 (propagated-inputs '())
479 (outputs '("out")))))
482 ;; A statically-linked GCC, with stripped-down functionality.
483 (package-with-relocatable-glibc
484 (package (inherit gcc)
486 (outputs '("out")) ; all in one
488 `(#:modules ((guix build utils)
489 (guix build gnu-build-system)
493 ,@(substitute-keyword-arguments (package-arguments gcc)
495 ((#:implicit-inputs? _) #t)
496 ((#:configure-flags flags)
498 ;; We don't need a full bootstrap here.
499 "--disable-bootstrap"
501 ;; Make sure '-static' is passed where it matters.
502 "--with-stage1-ldflags=-static"
504 ;; GCC 4.8+ requires a C++ compiler and library.
505 "--enable-languages=c,c++"
507 ;; Make sure gcc-nm doesn't require liblto_plugin.so.
512 "--disable-libmudflap"
513 "--disable-libatomic"
514 "--disable-libsanitizer"
517 "--disable-libcilkrts"
520 "--disable-libquadmath")
521 (remove (cut string-match "--(.*plugin|enable-languages)" <>)
524 `(modify-phases ,phases
525 (add-after 'pre-configure 'remove-lgcc_s
527 ;; Remove the '-lgcc_s' added to GNU_USER_TARGET_LIB_SPEC in
528 ;; the 'pre-configure phase of our main gcc package, because
529 ;; that shared library is not present in this static gcc. See
530 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-01/msg00008.html>.
531 (substitute* (cons "gcc/config/rs6000/sysv4.h"
532 (find-files "gcc/config"
534 ((" -lgcc_s}}") "}}"))
537 `(("zlib:static" ,zlib "static")
538 ,@(package-inputs gcc)))
540 (if (%current-target-system)
541 `(;; When doing a Canadian cross, we need GMP/MPFR/MPC both
542 ;; as target inputs and as native inputs; the latter is
543 ;; needed when building build-time tools ('genconstants',
544 ;; etc.) Failing to do that leads to misdetections of
545 ;; declarations by 'gcc/configure', and eventually to
546 ;; duplicate declarations as reported in
547 ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59217>.
549 ("mpfr-native" ,mpfr)
551 ,@(package-native-inputs gcc))
552 (package-native-inputs gcc))))))
554 (define %gcc-stripped
555 ;; The subset of GCC files needed for bootstrap.
556 (package (inherit gcc)
557 (name "gcc-stripped")
558 (build-system trivial-build-system)
560 (outputs '("out")) ;only one output
562 `(#:modules ((guix build utils))
565 (use-modules (srfi srfi-1)
569 (setvbuf (current-output-port) _IOLBF)
570 (let* ((out (assoc-ref %outputs "out"))
571 (bindir (string-append out "/bin"))
572 (libdir (string-append out "/lib"))
573 (includedir (string-append out "/include"))
574 (libexecdir (string-append out "/libexec"))
575 (gcc (assoc-ref %build-inputs "gcc")))
576 (copy-recursively (string-append gcc "/bin") bindir)
577 (for-each remove-store-references
578 (find-files bindir ".*"))
580 (copy-recursively (string-append gcc "/lib") libdir)
581 (for-each remove-store-references
582 (remove (cut string-suffix? ".h" <>)
583 (find-files libdir ".*")))
585 (copy-recursively (string-append gcc "/libexec")
587 (for-each remove-store-references
588 (find-files libexecdir ".*"))
590 ;; Starting from GCC 4.8, helper programs built natively
591 ;; (‘genchecksum’, ‘gcc-nm’, etc.) rely on C++ headers.
592 (copy-recursively (string-append gcc "/include/c++")
593 (string-append includedir "/c++"))
595 ;; For native builds, check whether the binaries actually work.
596 ,@(if (%current-target-system)
598 '((for-each (lambda (prog)
599 (invoke (string-append gcc "/bin/" prog)
601 '("gcc" "g++" "cpp"))))
604 (inputs `(("gcc" ,%gcc-static)))))
606 ;; Two packages: first build static, bare minimum content.
607 (define %mescc-tools-static
608 ;; A statically linked MesCC Tools.
610 (inherit mescc-tools-0.5.2)
611 (name "mescc-tools-static")
613 `(#:system "i686-linux"
614 ,@(substitute-keyword-arguments (package-arguments mescc-tools)
615 ((#:make-flags flags)
616 `(cons "CC=gcc -static" ,flags)))))))
618 ;; ... next remove store references.
619 (define %mescc-tools-static-stripped
620 ;; A statically linked Mescc Tools with store references removed, for
623 (inherit %mescc-tools-static)
624 (name (string-append (package-name %mescc-tools-static) "-stripped"))
625 (build-system trivial-build-system)
627 `(#:modules ((guix build utils))
630 (use-modules (guix build utils))
631 (let* ((in (assoc-ref %build-inputs "mescc-tools"))
632 (out (assoc-ref %outputs "out"))
633 (bin (string-append out "/bin")))
635 (for-each (lambda (file)
636 (let ((target (string-append bin "/" file)))
637 (format #t "copying `~a'...~%" file)
638 (copy-file (string-append in "/bin/" file)
640 (remove-store-references target)))
641 '( "M1" "blood-elf" "hex2"))
643 (inputs `(("mescc-tools" ,%mescc-tools-static)))))
645 ;; Two packages: first build static, bare minimum content.
646 (define-public %mes-minimal
647 ;; A minimal Mes without documentation.
648 (let ((triplet "i686-unknown-linux-gnu"))
653 `(("guile" ,guile-2.2)))
655 `(#:system "i686-linux"
657 #:configure-flags '("--mes")
659 (modify-phases %standard-phases
660 (delete 'patch-shebangs)
661 (add-after 'install 'strip-install
663 (let* ((out (assoc-ref %outputs "out"))
664 (share (string-append out "/share")))
665 (delete-file-recursively (string-append out "/lib/guile"))
666 (delete-file-recursively (string-append share "/guile"))
667 (delete-file-recursively (string-append share "/mes/scaffold"))
669 (for-each delete-file
671 (string-append share "/mes/lib")
672 "\\.(h|c)")))))))))))
674 ;; next remove store references.
675 (define %mes-minimal-stripped
676 ;; A minimal Mes with store references removed, for bootstrap.
678 (inherit %mes-minimal)
679 (name (string-append (package-name %mes-minimal) "-stripped"))
680 (build-system trivial-build-system)
682 `(#:modules ((guix build utils))
685 (use-modules (guix build utils))
686 (let ((in (assoc-ref %build-inputs "mes"))
687 (out (assoc-ref %outputs "out")))
689 (copy-recursively in out)
690 (for-each (lambda (dir)
691 (for-each remove-store-references
692 (find-files (string-append out "/" dir)
694 '("bin" "share/mes"))
696 (inputs `(("mes" ,%mes-minimal)))))
698 (define %guile-static
699 ;; A statically-linked Guile that is relocatable--i.e., it can search
700 ;; .scm and .go files relative to its installation directory, rather
701 ;; than in hard-coded configure-time paths.
702 (let* ((patches (cons* (search-patch "guile-relocatable.patch")
703 (search-patch "guile-2.2-default-utf8.patch")
704 (search-patch "guile-linux-syscalls.patch")
705 (origin-patches (package-source guile-2.2))))
706 (source (origin (inherit (package-source guile-2.2))
708 (guile (package (inherit guile-2.2)
709 (name (string-append (package-name guile-2.2) "-static"))
711 (synopsis "Statically-linked and relocatable Guile")
713 ;; Remove the 'debug' output (see above for the reason.)
714 (outputs (delete "debug" (package-outputs guile-2.2)))
717 `(("libunistring:static" ,libunistring "static")
718 ,@(package-inputs guile-2.2)))
722 ,@(alist-delete "bdw-gc"
723 (package-propagated-inputs guile-2.2))))
725 (substitute-keyword-arguments (package-arguments guile-2.2)
726 ((#:configure-flags flags '())
727 ;; When `configure' checks for ltdl availability, it
728 ;; doesn't try to link using libtool, and thus fails
729 ;; because of a missing -ldl. Work around that.
731 ((#:phases phases '%standard-phases)
732 `(modify-phases ,phases
734 ;; Do not record the absolute file name of 'sh' in
735 ;; (ice-9 popen). This makes 'open-pipe' unusable in
736 ;; a build chroot ('open-pipe*' is fine) but avoids
737 ;; keeping a reference to Bash.
738 (delete 'pre-configure)
740 (add-before 'configure 'static-guile
742 (substitute* "libguile/Makefile.in"
743 ;; Create a statically-linked `guile'
745 (("^guile_LDFLAGS =")
746 "guile_LDFLAGS = -all-static")
748 ;; Add `-ldl' *after* libguile-2.2.la.
749 (("^guile_LDADD =(.*)$" _ ldadd)
750 (string-append "guile_LDADD = "
751 (string-trim-right ldadd)
754 ;; There are uses of `dynamic-link' in
755 ;; {foreign,coverage}.test that don't fly here.
757 ((#:parallel-build? _ #f)
758 ;; Work around the fact that the Guile build system is
759 ;; not deterministic when parallel-build is enabled.
761 (package-with-relocatable-glibc (static-package guile))))
763 (define %guile-static-stripped
764 ;; A stripped static Guile binary, for use during bootstrap.
765 (package (inherit %guile-static)
766 (name "guile-static-stripped")
767 (build-system trivial-build-system)
769 ;; The end result should depend on nothing but itself.
770 `(#:allowed-references ("out")
771 #:modules ((guix build utils))
774 (use-modules (guix build utils))
776 (let* ((in (assoc-ref %build-inputs "guile"))
777 (out (assoc-ref %outputs "out"))
778 (guile1 (string-append in "/bin/guile"))
779 (guile2 (string-append out "/bin/guile")))
780 (mkdir-p (string-append out "/share/guile/2.2"))
781 (copy-recursively (string-append in "/share/guile/2.2")
782 (string-append out "/share/guile/2.2"))
784 (mkdir-p (string-append out "/lib/guile/2.2/ccache"))
785 (copy-recursively (string-append in "/lib/guile/2.2/ccache")
786 (string-append out "/lib/guile/2.2/ccache"))
788 (mkdir (string-append out "/bin"))
789 (copy-file guile1 guile2)
791 ;; Verify that the relocated Guile works.
792 ,@(if (%current-target-system)
794 '((invoke guile2 "--version")))
796 ;; Strip store references.
797 (remove-store-references guile2)
799 ;; Verify that the stripped Guile works. If it aborts, it could be
800 ;; that it tries to open iconv descriptors and fails because libc's
801 ;; iconv data isn't available (see `guile-default-utf8.patch'.)
802 ,@(if (%current-target-system)
804 '((invoke guile2 "--version")))
807 (inputs `(("guile" ,%guile-static)))
809 (synopsis "Minimal statically-linked and relocatable Guile")))
811 (define (tarball-package pkg)
812 "Return a package containing a tarball of PKG."
813 (package (inherit pkg)
814 (name (string-append (package-name pkg) "-tarball"))
815 (build-system trivial-build-system)
816 (native-inputs `(("tar" ,tar)
818 (inputs `(("input" ,pkg)))
820 (let ((name (package-name pkg))
821 (version (package-version pkg)))
822 `(#:modules ((guix build utils))
825 (use-modules (guix build utils))
826 (let ((out (assoc-ref %outputs "out"))
827 (input (assoc-ref %build-inputs "input"))
828 (tar (assoc-ref %build-inputs "tar"))
829 (xz (assoc-ref %build-inputs "xz")))
831 (set-path-environment-variable "PATH" '("bin") (list tar xz))
832 (with-directory-excursion input
834 (string-append out "/"
837 ,(or (%current-target-system)
841 ;; avoid non-determinism in the archive
842 "--sort=name" "--mtime=@0"
843 "--owner=root:0" "--group=root:0")))))))))
845 (define %bootstrap-binaries-tarball
846 ;; A tarball with the statically-linked bootstrap binaries.
847 (tarball-package %static-binaries))
849 (define %linux-libre-headers-bootstrap-tarball
850 ;; A tarball with the statically-linked Linux-Libre-Headers programs.
851 (tarball-package %linux-libre-headers-stripped))
853 (define %binutils-bootstrap-tarball
854 ;; A tarball with the statically-linked Binutils programs.
855 (tarball-package %binutils-static-stripped))
857 (define (%glibc-bootstrap-tarball)
858 ;; A tarball with GNU libc's shared libraries, dynamic linker, and headers.
859 (tarball-package (%glibc-stripped)))
861 (define %gcc-bootstrap-tarball
862 ;; A tarball with a dynamic-linked GCC and its headers.
863 (tarball-package %gcc-stripped))
865 (define %guile-bootstrap-tarball
866 ;; A tarball with the statically-linked, relocatable Guile.
867 (tarball-package %guile-static-stripped))
869 (define %mescc-tools-bootstrap-tarball
870 ;; A tarball with statically-linked MesCC binary seed.
871 (tarball-package %mescc-tools-static-stripped))
873 (define %mes-bootstrap-tarball
874 ;; A tarball with Mes binary seed.
875 (tarball-package %mes-minimal-stripped))
877 (define %bootstrap-tarballs
878 ;; A single derivation containing all the bootstrap tarballs, for
881 (name "bootstrap-tarballs")
884 (build-system trivial-build-system)
886 `(#:modules ((guix build utils))
888 (let ((out (assoc-ref %outputs "out")))
889 (use-modules (guix build utils)
893 (setvbuf (current-output-port) _IOLBF)
896 (for-each (match-lambda
898 (for-each (lambda (file)
899 (format #t "~a -> ~a~%" file out)
900 (symlink file (basename file)))
901 (find-files directory "\\.tar\\."))))
904 (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
905 ,@(match (or (%current-target-system) (%current-system))
906 ((or "i686-linux" "x86_64-linux")
907 `(("bootstrap-mescc-tools" ,%mescc-tools-bootstrap-tarball)
908 ("bootstrap-mes" ,%mes-bootstrap-tarball)
909 ("bootstrap-linux-libre-headers"
910 ,%linux-libre-headers-bootstrap-tarball)))
911 (_ `(("gcc-tarball" ,%gcc-bootstrap-tarball)
912 ("binutils-tarball" ,%binutils-bootstrap-tarball)
913 ("glibc-tarball" ,(%glibc-bootstrap-tarball)))))
914 ("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
915 (synopsis "Tarballs containing all the bootstrap binaries")
916 (description synopsis)
920 ;;; make-bootstrap.scm ends here