1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015, 2018, 2019 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2017, 2020 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2018, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
6 ;;; Copyright © 2019 Carl Dong <contact@carldong.me>
7 ;;; Copyright © 2019 Léo Le Bouter <lle-bout@zaclys.net>
8 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
9 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages bootstrap)
27 #:use-module (guix licenses)
28 #:use-module (gnu packages)
29 #:use-module (guix platform)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix build-system)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system trivial)
35 #:use-module ((guix store)
36 #:select (%store-monad interned-file text-file store-lift))
37 #:use-module ((guix derivations)
38 #:select (raw-derivation derivation-input derivation->output-path))
39 #:use-module (guix utils)
40 #:use-module ((guix build utils) #:select (elf-file?))
41 #:use-module ((guix gexp) #:select (lower-object))
42 #:use-module (guix monads)
43 #:use-module (guix memoization)
44 #:use-module (guix i18n)
45 #:use-module (srfi srfi-1)
46 #:use-module (srfi srfi-26)
47 #:use-module (srfi srfi-34)
48 #:use-module (srfi srfi-35)
49 #:use-module (ice-9 match)
50 #:export (bootstrap-origin
51 package-with-bootstrap-guile
55 bootstrap-guile-origin
58 %bootstrap-coreutils&co
59 %bootstrap-linux-libre-headers
64 %bootstrap-mescc-tools
67 %bootstrap-inputs-for-tests))
71 ;;; Pre-built packages that are used to bootstrap the
72 ;;; distribution--i.e., to build all the core packages from scratch.
79 ;;; The bootstrap executables: 'bash', 'mkdir', 'tar', 'xz'. They allow us to
80 ;;; extract the very first tarball.
83 (define %bootstrap-executables
84 ;; List of bootstrap executables and their recursive hashes (as per 'guix
85 ;; hash -r'), taking their executable bit into account.
88 ,(base32 "13aqhqb8nydlwq1ah9974q0iadx1pb95v13wzzyf7vgv6nasrwzr"))
90 ,(base32 "1pxhdp7ldwavmm71xbh9wc197cb2nr66acjn26yjx3732cixh9ws"))
92 ,(base32 "1j51gv08sfg277yxj73xd564wjq3f8xwd6s9rbcg8v9gms47m4cx"))
94 ,(base32 "1d779rwsrasphg5g3r37qppcqy3p7ay1jb1y83w7x4i3qsc7zjy2")))
97 ,(base32 "0hwlw5lcyjzadprf5fm0cv4zb6jw667g9amnmhq0lbixasy7j72j"))
99 ,(base32 "12lfwh5p8pp06250wgi9mdvjv1jdfpd5xpmvfc0616aj0xqh09hp"))
101 ,(base32 "00sbmwl8qh6alxv9mw4hvj1j4yipwmw5mrw6qad8bi2pr7ya5386"))
103 ,(base32 "0hi47y6zh5zz137i59l5ibw92x6g54zn7ris1b1ym9rvavsasg7b")))
106 ,(base32 "0s6f1s26g4dsrrkl39zblvwpxmbzi6n9mgqf6vxsqz42gik6bgyn"))
108 ,(base32 "1r5rcp35niyxfkrdf00y2ba8ifrq9bi76cr63lwjf2l655j1i5p7"))
110 ,(base32 "0dksx5im3fv8ximz7368bsax9f26nn47ds74298flm5lnvpv9xly"))
112 ,(base32 "1cqqavghjfr0iwxqf61lrssv27wfigysgq2rs4rm1gkmn04yn1k3")))
115 ,(base32 "0rjaxyzjdllfkf1abczvgaf3cdcc7mmahyvdbkjmjzhgz92pv23g"))
117 ,(base32 "133ybmfpkmsnysrzbngwvbysqnsmfi8is8zifs7i7n6n600h4s1w"))
119 ,(base32 "07830bx29ad5i0l1ykj0g0b1jayjdblf01sr3ww9wbnwdbzinqms"))
121 ,(base32 "0i9kxdi17bm5gxfi2xzm0y73p3ii0cqxli1sbljm6rh2fjgyn90k")))
124 ,(base32 "1as8649aqaibahhhrvkj10ci8shpi4hq5n7gnik8rhhy0dc1jarg"))
126 ,(base32 "1snqgpfrl00hfn82lm29jqylzjsfb9jd6ha74dp12phwb8fpbmb9"))
128 ,(base32 "0nq2c1zb3wv5bf7kd83sziaashydazrn7xgq6kijlk0zj2syzc2m"))
130 ,(base32 "033rhpk6zrpxpd6ffjyg5y2zwq9x9cnq0zljb7k8jlncbalsayq5")))
133 ,(base32 "1aw046dhda240k9pb9iaj5aqkm23gkvxa9j82n4k7fk87nbrixw6"))
135 ,(base32 "0c9j6qgyw84zxbry3ypifzll13gy8ax71w40kdk1h11jbgla3f5k"))
137 ,(base32 "06gmqdjq3rl8lr47b9fyx4ifnm5x56ymc8lyryp1ax1j2s4y5jb4"))
139 ,(base32 "09j1d69qr0hhhx4k4ih8wp00dfc9y4rp01hfg3vc15yxd0jxabh5")))
142 ,(base32 "1kiw7n6mkdy2x9in97646nb7aiayxr090ws1hbrlazah3fjqi6nj"))
144 ,(base32 "04dpvi231zcl40ig048vqqnyvmnkw1byrm1q1qqvs1f0g16yhrrk"))
146 ,(base32 "150c8948cz8r208g6qgn2dn4f4zs5kpgbpbg6bwag6yw42rapw2l"))
148 ,(base32 "0v5738idy9pqzcbrjdpxi5c6qs5m78zrpsydmrpx5cfcfzbkxzjh")))
151 ,(base32 "0almlf73k6hbm495kzf4bw1rzsg5qddn7z2rf5l3d1xcapac2hj3"))
153 ,(base32 "0rg1amdcqfkplcy1608jignl8jq0wqzfkp430mwik3f62959gya6"))
155 ,(base32 "17d3x27qhiwk7h6ns0xrvbrq0frxz89mjjh2cdwx2rraq5x6wffm"))
157 ,(base32 "0nxn75xf386vdq3igmgm8gnyk4h4x0cm8jv71vlb2jvwxh0cyw1q")))))
159 (define %bootstrap-executable-base-urls
160 ;; This is where the bootstrap executables come from.
161 '("https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/bootstrap/"
162 "https://alpha.gnu.org/gnu/guix/bootstrap/"
163 "http://flashner.co.il/guix/bootstrap/"
164 "http://lilypond.org/janneke/guix/"))
166 (define (bootstrap-executable-file-name system program)
167 "Return the FILE-NAME part of url where PROGRAM can be found for SYSTEM."
169 ("powerpc64le-linux" (string-append system "/20210106/" program))
170 ("i586-gnu" (string-append system "/20200326/" program))
171 ("powerpc-linux" (string-append system "/20200923/bin/" program))
172 ("riscv64-linux" (string-append system "/20210725/bin/" program))
173 (_ (string-append system "/" program
174 "?id=44f07d1dc6806e97c4e9ee3e6be883cc59dc666e"))))
176 (define bootstrap-executable
177 (mlambda (program system)
178 "Return an origin for PROGRAM, a statically-linked bootstrap executable
180 (let ((system (if (string=? system "x86_64-linux")
183 (match (assoc-ref (assoc-ref %bootstrap-executables system)
189 (format #f (G_ "could not find bootstrap binary '~a' \
194 (method url-fetch/executable)
195 (uri (map (cute string-append <>
196 (bootstrap-executable-file-name system program))
197 %bootstrap-executable-base-urls))
199 (hash (content-hash bv sha256))))))))
203 ;;; Helper procedures.
206 (define bootstrap-origin
208 "Return a variant of SOURCE, an <origin> instance, whose method uses
209 %BOOTSTRAP-GUILE to do its job."
211 (lambda* (url hash-algo hash
212 #:optional name #:key system)
213 (fetch url hash-algo hash name
214 #:guile %bootstrap-guile
217 (define %bootstrap-patch-inputs
218 ;; Packages used when an <origin> has a non-empty 'patches' field.
219 `(("tar" ,%bootstrap-coreutils&co)
220 ("xz" ,%bootstrap-coreutils&co)
221 ("bzip2" ,%bootstrap-coreutils&co)
222 ("gzip" ,%bootstrap-coreutils&co)
223 ("patch" ,%bootstrap-coreutils&co)))
225 (let ((orig-method (origin-method source)))
226 (if (or (not (null? (origin-patches source)))
227 (origin-snippet source))
228 (origin (inherit source)
229 (method (if (eq? orig-method url-fetch)
232 (patch-guile %bootstrap-guile)
233 (patch-inputs %bootstrap-patch-inputs)
235 ;; Patches can be origins as well, so process them.
236 (patches (map (match-lambda
238 (bootstrap-origin patch))
240 (origin-patches source))))
243 (define* (package-from-tarball name source program-to-test description
245 "Return a package that correspond to the extraction of SOURCE.
246 PROGRAM-TO-TEST is #f or a string: the program to run after extraction of
247 SOURCE to check whether everything is alright. If SNIPPET is provided, it is
248 evaluated after extracting SOURCE. SNIPPET should return true if successful,
249 or false to signal an error."
253 (build-system trivial-build-system)
255 `(#:guile ,%bootstrap-guile
256 #:modules ((guix build utils))
259 (use-modules (guix build utils))
261 (let ((out (assoc-ref %outputs "out"))
262 (tar (assoc-ref %build-inputs "tar"))
263 (xz (assoc-ref %build-inputs "xz"))
264 (tarball (assoc-ref %build-inputs "tarball")))
267 (copy-file tarball "binaries.tar.xz")
268 (invoke xz "-d" "binaries.tar.xz")
269 (let ((builddir (getcwd)))
270 (with-directory-excursion out
272 (string-append builddir "/binaries.tar"))
273 ,@(if snippet (list snippet) '())
274 (or (not ,program-to-test)
275 (invoke (string-append "bin/" ,program-to-test)
278 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
279 ("xz" ,(bootstrap-executable "xz" (%current-system)))
280 ("tarball" ,(bootstrap-origin (source (%current-system))))))
282 (synopsis description)
283 (description description)
287 (define package-with-bootstrap-guile
289 "Return a variant of P such that all its origins are fetched with
291 (define rewritten-input
293 ((name (? origin? o))
294 `(,name ,(bootstrap-origin o)))
295 ((name (? package? p) sub-drvs ...)
296 `(,name ,(package-with-bootstrap-guile p) ,@sub-drvs))
300 (source (match (package-source p)
301 ((? origin? o) (bootstrap-origin o))
303 (inputs (map rewritten-input
305 (native-inputs (map rewritten-input
306 (package-native-inputs p)))
307 (propagated-inputs (map rewritten-input
308 (package-propagated-inputs p)))
309 (replacement (and=> (package-replacement p)
310 package-with-bootstrap-guile)))))
312 (define* (glibc-dynamic-linker
313 #:optional (system (or (and=> (%current-target-system)
314 gnu-triplet->nix-system)
316 "Return the name of Glibc's dynamic linker for SYSTEM."
317 ;; See the 'SYSDEP_KNOWN_INTERPRETER_NAMES' cpp macro in libc.
318 (let ((platform (lookup-platform-by-system system)))
320 ((platform? platform)
321 (platform-glibc-dynamic-linker platform))
323 ;; TODO: Define those as platforms.
324 ((string=? system "i686-gnu") "/lib/ld.so.1")
325 ((string=? system "powerpc64-linux") "/lib/ld64.so.1")
326 ((string=? system "alpha-linux") "/lib/ld-linux.so.2")
328 ;; XXX: This one is used bare-bones, without a libc, so add a case
329 ;; here just so we can keep going.
330 ((string=? system "arm-elf") "no-ld.so")
331 ((string=? system "arm-eabi") "no-ld.so")
332 ((string=? system "xtensa-elf") "no-ld.so")
333 ((string=? system "avr") "no-ld.so")
334 ((string=? system "propeller-elf") "no-ld.so")
335 ((string=? system "i686-mingw") "no-ld.so")
336 ((string=? system "x86_64-mingw") "no-ld.so")
337 ((string=? system "vc4-elf") "no-ld.so")
339 (else (error "dynamic linker name not known for this system"
344 ;;; Bootstrap packages.
347 (define %bootstrap-base-urls
348 ;; This is where the initial binaries come from.
349 '("https://ftp.gnu.org/gnu/guix/bootstrap"
350 "https://alpha.gnu.org/gnu/guix/bootstrap"
351 "http://ftp.gnu.org/gnu/guix/bootstrap"
352 "http://alpha.gnu.org/gnu/guix/bootstrap"
353 "ftp://alpha.gnu.org/gnu/guix/bootstrap"
354 "http://www.fdn.fr/~lcourtes/software/guix/packages"
355 "http://flashner.co.il/guix/bootstrap"
356 "http://lilypond.org/janneke/guix/"))
358 (define (bootstrap-guile-url-path system)
359 "Return the URI for FILE."
360 (string-append "/" system
363 "/20170217/guile-2.0.14.tar.xz")
365 "/20200923/guile-2.0.14.tar.xz")
367 "/20150101/guile-2.0.11.tar.xz")
369 "/20200326/guile-static-stripped-2.0.14-i586-pc-gnu.tar.xz")
371 "/20210106/guile-static-stripped-2.0.14-powerpc64le-linux-gnu.tar.xz")
373 "/20210725/guile-3.0.2.tar.xz")
375 "/20131110/guile-2.0.9.tar.xz"))))
377 (define (bootstrap-guile-hash system)
378 "Return the SHA256 hash of the Guile bootstrap tarball for SYSTEM."
381 (base32 "1w2p5zyrglzzniqgvyn1b55vprfzhgk8vzbzkkbdgl5248si0yq3"))
383 (base32 "0im800m30abgh7msh331pcbjvb4n02smz5cfzf1srv0kpx3csmxp"))
385 (base32 "0fzp93lvi0hn54acc0fpvhc7bvl0yc853k62l958cihk03q80ilr"))
387 (base32 "1mi3brl7l58aww34rawhvja84xc7l1b4hmwdmc36fp9q9mfx0lg5"))
389 (base32 "1rnyfz5q38jyvxddj617443bnnzql4vw0mxzqpj8wz48wx4bhbq0"))
391 (base32 "1giy2aprjmn5fp9c4s9r125fljw4wv6ixy5739i5bffw4jgr0f9r"))
393 (base32 "0wgqpsmvg25rnqn49ap7kwd2qxccd8dr4lllzp7i3rjvgav27vac"))
395 (base32 "1by2p7s27fbyjzfkcw8h65h4kkqh7d23kv4sgg5jppjn2qx7swq4"))
397 (base32 "12pqmhsbbp7hh9r1bjdl14l3a4q06plpz6dcks9dysb4czay8p9f"))))
399 (define (bootstrap-guile-origin system)
400 "Return an <origin> object for the Guile tarball of SYSTEM."
403 (uri (map (cute string-append <> (bootstrap-guile-url-path system))
404 %bootstrap-base-urls))
405 (sha256 (bootstrap-guile-hash system))))
407 (define (download-bootstrap-guile system)
408 "Return a derivation that downloads the bootstrap Guile tarball for SYSTEM."
409 (let* ((path (bootstrap-guile-url-path system))
410 (base (basename path))
411 (urls (map (cut string-append <> path) %bootstrap-base-urls)))
412 (url-fetch urls 'sha256 (bootstrap-guile-hash system)
415 (define* (raw-build name inputs
416 #:key outputs system search-paths
418 (define (->store file)
419 (lower-object (bootstrap-executable file system)
422 (define (make-guile-wrapper bash guile-real)
423 ;; The following code, run by the bootstrap guile after it is unpacked,
424 ;; creates a wrapper for itself to set its load path. This replaces the
425 ;; previous non-portable method based on reading the /proc/self/exe
428 (use-modules (ice-9 match))
429 (match (command-line)
431 (let ((bin-dir (string-append out "/bin"))
432 (guile (string-append out "/bin/guile"))
433 (guile-real (string-append out "/bin/.guile-real"))
434 ;; We must avoid using a bare dollar sign in this code,
435 ;; because it would be interpreted by the shell.
436 (dollar (string (integer->char 36))))
437 (chmod bin-dir #o755)
438 (rename-file guile guile-real)
439 (call-with-output-file guile
443 export GUILE_SYSTEM_PATH=~a/share/guile/2.0
444 export GUILE_SYSTEM_COMPILED_PATH=~a/lib/guile/2.0/ccache
445 exec -a \"~a0\" ~a \"~a@\"\n"
446 bash out out dollar guile-real dollar)))
448 (chmod bin-dir #o555))))))
450 (mlet* %store-monad ((tar (->store "tar"))
452 (mkdir (->store "mkdir"))
453 (bash (->store "bash"))
454 (guile (download-bootstrap-guile system))
455 (wrapper -> (make-guile-wrapper bash guile))
457 (text-file "build-bootstrap-guile.sh"
459 echo \"unpacking bootstrap Guile to '$out'...\"
462 ~a -dc < $GUILE_TARBALL | ~a xv
464 # Use the bootstrap guile to create its own wrapper to set the load path.
465 GUILE_SYSTEM_PATH=$out/share/guile/2.0 \
466 GUILE_SYSTEM_COMPILED_PATH=$out/lib/guile/2.0/ccache \
467 $out/bin/guile -c ~s $out ~a
470 $out/bin/guile --version~%"
471 (derivation->output-path mkdir)
472 (derivation->output-path xz)
473 (derivation->output-path tar)
474 (object->string wrapper)
475 (derivation->output-path bash)))))
477 (derivation->output-path bash) `(,builder)
479 #:inputs (map derivation-input
480 (list bash mkdir tar xz guile))
481 #:sources (list builder)
482 #:env-vars `(("GUILE_TARBALL"
483 . ,(derivation->output-path guile))))))
485 (define* (raw-build-guile3 name inputs
486 #:key outputs system search-paths
488 (define (->store file)
489 (lower-object (bootstrap-executable file system)
492 (define (make-guile-wrapper bash guile-real)
493 ;; The following code, run by the bootstrap guile after it is unpacked,
494 ;; creates a wrapper for itself to set its load path. This replaces the
495 ;; previous non-portable method based on reading the /proc/self/exe
498 (use-modules (ice-9 match))
499 (match (command-line)
501 (let ((bin-dir (string-append out "/bin"))
502 (guile (string-append out "/bin/guile"))
503 (guile-real (string-append out "/bin/.guile-real"))
504 ;; We must avoid using a bare dollar sign in this code,
505 ;; because it would be interpreted by the shell.
506 (dollar (string (integer->char 36))))
507 (chmod bin-dir #o755)
508 (rename-file guile guile-real)
509 (call-with-output-file guile
513 export GUILE_SYSTEM_PATH=~a/share/guile/3.0
514 export GUILE_SYSTEM_COMPILED_PATH=~a/lib/guile/3.0/ccache
515 exec -a \"~a0\" ~a \"~a@\"\n"
516 bash out out dollar guile-real dollar)))
518 (chmod bin-dir #o555))))))
520 (mlet* %store-monad ((tar (->store "tar"))
522 (mkdir (->store "mkdir"))
523 (bash (->store "bash"))
524 (guile (download-bootstrap-guile system))
525 (wrapper -> (make-guile-wrapper bash guile))
527 (text-file "build-bootstrap-guile.sh"
529 echo \"unpacking bootstrap Guile to '$out'...\"
532 ~a -dc < $GUILE_TARBALL | ~a xv
534 # Use the bootstrap guile to create its own wrapper to set the load path.
535 GUILE_SYSTEM_PATH=$out/share/guile/3.0 \
536 GUILE_SYSTEM_COMPILED_PATH=$out/lib/guile/3.0/ccache \
537 $out/bin/guile -c ~s $out ~a
540 $out/bin/guile --version~%"
541 (derivation->output-path mkdir)
542 (derivation->output-path xz)
543 (derivation->output-path tar)
544 (object->string wrapper)
545 (derivation->output-path bash)))))
547 (derivation->output-path bash) `(,builder)
549 #:inputs (map derivation-input
550 (list bash mkdir tar xz guile))
551 #:sources (list builder)
552 #:env-vars `(("GUILE_TARBALL"
553 . ,(derivation->output-path guile))))))
555 (define* (make-raw-bag name
556 #:key source inputs native-inputs outputs
561 (build-inputs inputs)
562 (build (cond ((target-riscv64?)
566 (define %bootstrap-guile
567 ;; The Guile used to run the build scripts of the initial derivations.
568 ;; It is just unpacked from a tarball containing a pre-built binary.
569 ;; This is typically built using %GUILE-BOOTSTRAP-TARBALL below.
571 ;; XXX: Would need libc's `libnss_files2.so' for proper `getaddrinfo'
572 ;; support (for /etc/services).
573 (let ((raw (build-system
575 (description "Raw build system with direct store access")
576 (lower make-raw-bag))))
578 (name "guile-bootstrap")
582 (synopsis "Bootstrap Guile")
583 (description "Pre-built Guile for bootstrapping purposes.")
587 (define %bootstrap-coreutils&co
588 (package-from-tarball "bootstrap-binaries"
592 (uri (map (cut string-append <> "/" system
595 "/20150101/static-binaries.tar.xz")
597 "/20170217/static-binaries.tar.xz")
599 "/20210106/static-binaries-0-powerpc64le-linux-gnu.tar.xz")
601 "/20200326/static-binaries-0-i586-pc-gnu.tar.xz")
603 "/20200923/static-binaries.tar.xz")
605 "/20210725/static-binaries.tar.xz")
607 "/20131110/static-binaries.tar.xz")))
608 %bootstrap-base-urls))
613 "0c533p9dhczzcsa1117gmfq3pc8w362g4mx84ik36srpr7cx2bg4"))
616 "0s5b3jb315n13m1k8095l0a5hfrsz8g0fv1b6riyc5hnxqyphlak"))
619 "0gf0fn2kbpxkjixkmx5f4z6hv6qpmgixl69zgg74dbsfdfj8jdv5"))
622 "18dfiq6c6xhsdpbidigw6480wh0vdgsxqq3xindq4lpdgqlccpfh"))
625 "0afs2j9z2d1hjq42myz4iwjh0aqgzf59inifw87x6b6p1z9wv92v"))
628 "17kllqnf3fg79gzy9ansgi801c46yh9c23h4d923plvb0nfm1cfn"))
631 "0kspxy0yczan2vlih6aa9hailr2inz000fqa0gn5x9d1fxxa5y8m"))
634 "0x0xjlpmyh6rkr51p00gp6pscgl6zjida1rsg8vk3rinyi6rrbkg"))
637 "072y4wyfsj1bs80r6vbybbafy8ya4vfy7qj25dklwk97m6g71753"))))))
638 "fgrep" ; the program to test
639 "Bootstrap binaries of Coreutils, Awk, etc."
641 '(let ((path (list (string-append (getcwd) "/bin"))))
643 (patch-shebang "bin/egrep" path)
644 (patch-shebang "bin/fgrep" path)
645 ;; Starting with grep@2.25 'egrep' and 'fgrep' are shell files
646 ;; that call 'grep'. If the bootstrap 'egrep' and 'fgrep'
647 ;; are not binaries then patch them to execute 'grep' via its
648 ;; absolute file name instead of searching for it in $PATH.
649 (if (not (elf-file? "bin/egrep"))
650 (substitute* '("bin/egrep" "bin/fgrep")
651 (("^exec grep") (string-append (getcwd) "/bin/grep"))))
652 (chmod "bin" #o555))))
654 (define-public %bootstrap-linux-libre-headers
655 (package-from-tarball
656 "linux-libre-headers-bootstrap"
660 (uri (map (cute string-append <>
661 "/i686-linux/20190815/"
662 "linux-libre-headers-stripped-4.14.67-i686-linux.tar.xz")
663 %bootstrap-base-urls))
666 "0sm2z9x4wk45bh6qfs94p0w1d6hsy6dqx9sw38qsqbvxwa1qzk8s"))))
667 #f ; no program to test
668 "Bootstrap linux-libre-headers"))
670 (define %bootstrap-binutils
671 (package-from-tarball "binutils-bootstrap"
675 (uri (map (cut string-append <> "/" system
678 "/20150101/binutils-2.25.tar.xz")
680 "/20170217/binutils-2.27.tar.xz")
682 "/20210106/binutils-static-stripped-2.34-powerpc64le-linux-gnu.tar.xz")
684 "/20200326/binutils-static-stripped-2.34-i586-pc-gnu.tar.xz")
686 "/20200923/binutils-2.35.1.tar.xz")
688 "/20210725/binutils-2.34.tar.xz")
690 "/20131110/binutils-2.23.2.tar.xz")))
691 %bootstrap-base-urls))
696 "1j5yivz7zkjqfsfmxzrrrffwyayjqyfxgpi89df0w4qziqs2dg20"))
699 "14jgwf9gscd7l2pnz610b1zia06dvcm2qyzvni31b8zpgmcai2v9"))
702 "1v7dj6bzn6m36f20gw31l99xaabq4xrhrx3gwqkhhig0mdlmr69q"))
705 "111s7ilfiby033rczc71797xrmaa3qlv179wdvsaq132pd51xv3n"))
708 "1klxy945c61134mzhqzz2gbk8w0n8jq7arwkrvz78d22ff2q0cwz"))
711 "0n9qf4vbilfmh1lknhw000waakj4q6s50pnjazr5137skm976z5m"))
714 "11kykv1kmqc5wln57rs4klaqa13hm952smkc57qcsyss21kfjprs"))
717 "0asbg1c4avkrvh057mx0942xwddd136jni382zqsxzn79ls42yq8"))
720 "1x8kkhcxmfyzg1ddpz2pxs6fbdl6412r7x0nzbmi5n7mj8zw2gy7"))))))
721 "ld" ; the program to test
722 "Bootstrap binaries of the GNU Binutils"))
724 (define %bootstrap-glibc
727 (name "glibc-bootstrap")
730 (build-system trivial-build-system)
732 `(#:guile ,%bootstrap-guile
733 #:modules ((guix build utils))
736 (use-modules (guix build utils))
738 (let ((out (assoc-ref %outputs "out"))
739 (tar (assoc-ref %build-inputs "tar"))
740 (xz (assoc-ref %build-inputs "xz"))
741 (tarball (assoc-ref %build-inputs "tarball")))
744 (copy-file tarball "binaries.tar.xz")
745 (invoke xz "-d" "binaries.tar.xz")
746 (let ((builddir (getcwd)))
747 (with-directory-excursion out
749 (string-append builddir
753 ;; Patch libc.so so it refers to the right path.
754 (substitute* "lib/libc.so"
755 (("/[^ ]+/lib/(libc|ld)" _ prefix)
756 (string-append out "/lib/" prefix)))
760 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
761 ("xz" ,(bootstrap-executable "xz" (%current-system)))
762 ("tarball" ,(bootstrap-origin
765 (uri (map (cut string-append <> "/" (%current-system)
766 (match (%current-system)
768 "/20150101/glibc-2.20.tar.xz")
770 "/20170217/glibc-2.25.tar.xz")
772 "/20210106/glibc-stripped-2.31-powerpc64le-linux-gnu.tar.xz")
774 "/20200326/glibc-stripped-2.31-i586-pc-gnu.tar.xz")
776 "/20200923/glibc-2.32.tar.xz")
778 "/20210725/glibc-2.31.tar.xz")
780 "/20131110/glibc-2.18.tar.xz")))
781 %bootstrap-base-urls))
783 (match (%current-system)
786 "0jlqrgavvnplj1b083s20jj9iddr4lzfvwybw5xrcis9spbfzk7v"))
789 "1hgrccw1zqdc7lvgivwa54d9l3zsim5pqm0dykxg0z522h6gr05w"))
792 "18cmgvpllqfpn6khsmivqib7ys8ymnq0hdzi3qp24prik0ykz8gn"))
795 "07nx3x8598i2924rjnlrncg6rm61c9bmcczbbcpbx0fb742nvv5c"))
798 "1a1df6z8gkaq09md3jy94lixnh20599p58p0s856p10xwjaqr1iz"))
801 "0d9x80vm7ca1pd2whcmpm1h14zxpb58kqajlxlwffzm04xfsjnxm"))
804 "14ddm10lpbas8bankmn5bcrlqvz1v5dnn1qjzxb19r57vd2w5952"))
807 "0smmssyjrlk5cvx49586smmk81gkwff0i6r91n4rir4jm6ba25sb"))
810 "0k97a3whzx3apsi9n2cbsrr79ad6lh00klxph9hw4fqyp1abkdsg")))))))))
811 (synopsis "Bootstrap binaries and headers of the GNU C Library")
812 (description synopsis)
816 (define %bootstrap-gcc
817 ;; The initial GCC. Uses binaries from a tarball typically built by
818 ;; %GCC-BOOTSTRAP-TARBALL.
820 (name "gcc-bootstrap")
823 (build-system trivial-build-system)
825 `(#:guile ,%bootstrap-guile
826 #:modules ((guix build utils))
829 (use-modules (guix build utils)
832 (let ((out (assoc-ref %outputs "out"))
833 (tar (assoc-ref %build-inputs "tar"))
834 (xz (assoc-ref %build-inputs "xz"))
835 (bash (assoc-ref %build-inputs "bash"))
836 (libc (assoc-ref %build-inputs "libc"))
837 (tarball (assoc-ref %build-inputs "tarball")))
840 (copy-file tarball "binaries.tar.xz")
841 (invoke xz "-d" "binaries.tar.xz")
842 (let ((builddir (getcwd))
843 (bindir (string-append out "/bin")))
844 (with-directory-excursion out
846 (string-append builddir "/binaries.tar")))
848 (with-directory-excursion bindir
850 (rename-file "gcc" ".gcc-wrapped")
851 (call-with-output-file "gcc"
854 exec ~a/bin/.gcc-wrapped -B~a/lib \
855 -Wl,-rpath -Wl,~a/lib \
856 -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
859 ,(glibc-dynamic-linker))))
864 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
865 ("xz" ,(bootstrap-executable "xz" (%current-system)))
866 ("bash" ,(bootstrap-executable "bash" (%current-system)))
867 ("libc" ,%bootstrap-glibc)
868 ("tarball" ,(bootstrap-origin
871 (uri (map (cut string-append <> "/" (%current-system)
872 (match (%current-system)
874 "/20150101/gcc-4.8.4.tar.xz")
876 "/20170217/gcc-5.4.0.tar.xz")
878 "/20210106/gcc-stripped-5.5.0-powerpc64le-linux-gnu.tar.xz")
880 "/20200326/gcc-stripped-5.5.0-i586-pc-gnu.tar.xz")
882 "/20200923/gcc-5.5.0.tar.xz")
884 "/20210725/gcc-7.5.0.tar.xz")
886 "/20131110/gcc-4.8.2.tar.xz")))
887 %bootstrap-base-urls))
889 (match (%current-system)
892 "17ga4m6195n4fnbzdkmik834znkhs53nkypp6557pl1ps7dgqbls"))
895 "150c1arrf2k8vfy6dpxh59vcgs4p1bgiz2av5m19dynpks7rjnyw"))
898 "0ghz825yzp43fxw53kd6afm8nkz16f7dxi9xi40bfwc8x3nbbr8v"))
901 "1ar3vdzyqbfm0z36kmvazvfswxhcihlacl2dzdjgiq25cqnq9ih1"))
904 "151kjsai25vz2s667bgzpisx8f281fpl3n9pxz2yrp9jlnadz3m1"))
907 "1k4mbnb54wj2q37fgshf5dfixixqnhn002vhzvi9pnb57xb9v14d"))
910 "1j2zc58wzil71a34h7c70sd68dmqvcscrw3rmn2whq79vd70zvv5"))
913 "1p7df3yixhm87dw5sccc6yn1i9db1r9hnmsg87wq5xi4rfmirq7w"))
916 "1m5miqkyng45l745n0sfafdpjkqv9225xf44jqkygwsipj2cv9ks")))))))))
918 (list (search-path-specification
919 (variable "C_INCLUDE_PATH")
920 (files '("include")))
921 (search-path-specification
922 (variable "CPLUS_INCLUDE_PATH")
923 (files '("include/c++" "include")))
924 (search-path-specification
925 (variable "LIBRARY_PATH")
926 (files '("lib" "lib64")))))
927 (synopsis "Bootstrap binaries of the GNU Compiler Collection")
928 (description synopsis)
932 (define %bootstrap-mescc-tools
933 ;; The initial MesCC tools. Uses binaries from a tarball typically built by
934 ;; %MESCC-TOOLS-BOOTSTRAP-TARBALL.
936 (name "bootstrap-mescc-tools")
939 (build-system trivial-build-system)
941 `(#:guile ,%bootstrap-guile
942 #:modules ((guix build utils))
945 (use-modules (guix build utils)
947 (let ((out (assoc-ref %outputs "out"))
948 (tar (assoc-ref %build-inputs "tar"))
949 (xz (assoc-ref %build-inputs "xz"))
950 (tarball (assoc-ref %build-inputs "tarball")))
953 (copy-file tarball "binaries.tar.xz")
954 (invoke xz "-d" "binaries.tar.xz")
955 (let ((builddir (getcwd))
956 (bindir (string-append out "/bin")))
957 (with-directory-excursion out
959 (string-append builddir "/binaries.tar"))))))))
961 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
962 ("xz" ,(bootstrap-executable "xz" (%current-system)))
968 (cute string-append <>
969 "/i686-linux/20190815/"
970 "mescc-tools-static-stripped-0.5.2-i686-linux.tar.xz")
971 %bootstrap-base-urls))
974 "0c3kklgghzh4q2dbpl6asb74cimp7hp6jscdwqwmzxbapgcl6582")))))))
975 (synopsis "Bootstrap binaries of MesCC Tools")
976 (description synopsis)
978 (supported-systems '("i686-linux" "x86_64-linux"))
981 (define %bootstrap-mes
982 ;; The initial Mes. Uses binaries from a tarball typically built by
983 ;; %MES-BOOTSTRAP-TARBALL.
985 (name "bootstrap-mes")
988 (build-system trivial-build-system)
990 `(#:guile ,%bootstrap-guile
991 #:modules ((guix build utils))
994 (use-modules (guix build utils)
996 (let ((out (assoc-ref %outputs "out"))
997 (tar (assoc-ref %build-inputs "tar"))
998 (xz (assoc-ref %build-inputs "xz"))
999 (tarball (assoc-ref %build-inputs "tarball")))
1002 (copy-file tarball "binaries.tar.xz")
1003 (invoke xz "-d" "binaries.tar.xz")
1004 (let ((builddir (getcwd))
1005 (bindir (string-append out "/bin")))
1006 (with-directory-excursion out
1008 (string-append builddir "/binaries.tar"))))))))
1010 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
1011 ("xz" ,(bootstrap-executable "xz" (%current-system)))
1017 (cute string-append <>
1018 "/i686-linux/20190815/"
1019 "mes-minimal-stripped-0.19-i686-linux.tar.xz")
1020 %bootstrap-base-urls))
1023 "1q4xjpx6nbn44kxnilpgl12bhpmwy2bblzwszc2ci7xkf400jcpv")))))))
1024 (supported-systems '("i686-linux" "x86_64-linux"))
1025 (synopsis "Bootstrap binaries of Mes")
1026 (description synopsis)
1030 (define (%bootstrap-inputs)
1031 ;; The initial, pre-built inputs. From now on, we can start building our
1033 (match (%current-system)
1034 ((or "i686-linux" "x86_64-linux")
1035 `(("linux-libre-headers" ,%bootstrap-linux-libre-headers)
1036 ("bootstrap-mescc-tools" ,%bootstrap-mescc-tools)
1037 ("mes" ,%bootstrap-mes)))
1039 `(("libc" ,%bootstrap-glibc)
1040 ("gcc" ,%bootstrap-gcc)
1041 ("binutils" ,%bootstrap-binutils)
1042 ("coreutils&co" ,%bootstrap-coreutils&co)
1043 ;; In gnu-build-system.scm, we rely on the availability of Bash.
1044 ("bash" ,%bootstrap-coreutils&co)))))
1046 (define %bootstrap-inputs-for-tests
1047 ;; These are bootstrap inputs that are cheap to produce (no compilation
1048 ;; needed) and that are meant to be used for testing. (These are those we
1049 ;; used before the Mes-based reduced bootstrap.)
1050 `(("libc" ,%bootstrap-glibc)
1051 ("gcc" ,%bootstrap-gcc)
1052 ("binutils" ,%bootstrap-binutils)
1053 ("coreutils&co" ,%bootstrap-coreutils&co)
1054 ("bash" ,%bootstrap-coreutils&co)))
1056 ;;; bootstrap.scm ends here