gnu: ruby-pandoc-ruby: Use pandoc instead of ghc-pandoc.
[jackhill/guix/guix.git] / gnu / packages / bootstrap.scm
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 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
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.
15 ;;;
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.
20 ;;;
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/>.
23
24 (define-module (gnu packages bootstrap)
25 #:use-module (guix licenses)
26 #:use-module (gnu packages)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix build-system)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system trivial)
32 #:use-module ((guix store)
33 #:select (run-with-store add-to-store add-text-to-store))
34 #:use-module ((guix derivations)
35 #:select (derivation derivation-input derivation->output-path))
36 #:use-module ((guix utils) #:select (gnu-triplet->nix-system))
37 #:use-module ((guix gexp) #:select (lower-object))
38 #:use-module (guix memoization)
39 #:use-module (guix i18n)
40 #:use-module (srfi srfi-1)
41 #:use-module (srfi srfi-26)
42 #:use-module (srfi srfi-34)
43 #:use-module (srfi srfi-35)
44 #:use-module (ice-9 match)
45 #:export (bootstrap-origin
46 package-with-bootstrap-guile
47 glibc-dynamic-linker
48
49 bootstrap-executable
50 bootstrap-guile-origin
51
52 %bootstrap-guile
53 %bootstrap-coreutils&co
54 %bootstrap-linux-libre-headers
55 %bootstrap-binutils
56 %bootstrap-gcc
57 %bootstrap-glibc
58 %bootstrap-inputs
59 %bootstrap-mescc-tools
60 %bootstrap-mes
61
62 %bootstrap-inputs-for-tests))
63
64 ;;; Commentary:
65 ;;;
66 ;;; Pre-built packages that are used to bootstrap the
67 ;;; distribution--i.e., to build all the core packages from scratch.
68 ;;;
69 ;;; Code:
70
71
72 \f
73 ;;;
74 ;;; The bootstrap executables: 'bash', 'mkdir', 'tar', 'xz'. They allow us to
75 ;;; extract the very first tarball.
76 ;;;
77
78 (define %bootstrap-executables
79 ;; List of bootstrap executables and their recursive hashes (as per 'guix
80 ;; hash -r'), taking their executable bit into account.
81 `(("aarch64-linux"
82 ("bash"
83 ,(base32 "13aqhqb8nydlwq1ah9974q0iadx1pb95v13wzzyf7vgv6nasrwzr"))
84 ("mkdir"
85 ,(base32 "1pxhdp7ldwavmm71xbh9wc197cb2nr66acjn26yjx3732cixh9ws"))
86 ("tar"
87 ,(base32 "1j51gv08sfg277yxj73xd564wjq3f8xwd6s9rbcg8v9gms47m4cx"))
88 ("xz"
89 ,(base32 "1d779rwsrasphg5g3r37qppcqy3p7ay1jb1y83w7x4i3qsc7zjy2")))
90 ("armhf-linux"
91 ("bash"
92 ,(base32 "0s6f1s26g4dsrrkl39zblvwpxmbzi6n9mgqf6vxsqz42gik6bgyn"))
93 ("mkdir"
94 ,(base32 "1r5rcp35niyxfkrdf00y2ba8ifrq9bi76cr63lwjf2l655j1i5p7"))
95 ("tar"
96 ,(base32 "0dksx5im3fv8ximz7368bsax9f26nn47ds74298flm5lnvpv9xly"))
97 ("xz"
98 ,(base32 "1cqqavghjfr0iwxqf61lrssv27wfigysgq2rs4rm1gkmn04yn1k3")))
99 ("i686-linux"
100 ("bash"
101 ,(base32 "0rjaxyzjdllfkf1abczvgaf3cdcc7mmahyvdbkjmjzhgz92pv23g"))
102 ("mkdir"
103 ,(base32 "133ybmfpkmsnysrzbngwvbysqnsmfi8is8zifs7i7n6n600h4s1w"))
104 ("tar"
105 ,(base32 "07830bx29ad5i0l1ykj0g0b1jayjdblf01sr3ww9wbnwdbzinqms"))
106 ("xz"
107 ,(base32 "0i9kxdi17bm5gxfi2xzm0y73p3ii0cqxli1sbljm6rh2fjgyn90k")))
108 ("i586-gnu"
109 ("bash"
110 ,(base32 "1as8649aqaibahhhrvkj10ci8shpi4hq5n7gnik8rhhy0dc1jarg"))
111 ("mkdir"
112 ,(base32 "1snqgpfrl00hfn82lm29jqylzjsfb9jd6ha74dp12phwb8fpbmb9"))
113 ("tar"
114 ,(base32 "0nq2c1zb3wv5bf7kd83sziaashydazrn7xgq6kijlk0zj2syzc2m"))
115 ("xz"
116 ,(base32 "033rhpk6zrpxpd6ffjyg5y2zwq9x9cnq0zljb7k8jlncbalsayq5")))
117 ("mips64el-linux"
118 ("bash"
119 ,(base32 "1aw046dhda240k9pb9iaj5aqkm23gkvxa9j82n4k7fk87nbrixw6"))
120 ("mkdir"
121 ,(base32 "0c9j6qgyw84zxbry3ypifzll13gy8ax71w40kdk1h11jbgla3f5k"))
122 ("tar"
123 ,(base32 "06gmqdjq3rl8lr47b9fyx4ifnm5x56ymc8lyryp1ax1j2s4y5jb4"))
124 ("xz"
125 ,(base32 "09j1d69qr0hhhx4k4ih8wp00dfc9y4rp01hfg3vc15yxd0jxabh5")))))
126
127 (define %bootstrap-executable-base-urls
128 ;; This is where the bootstrap executables come from.
129 '("https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/bootstrap/"
130 "http://lilypond.org/janneke/guix/"))
131
132 (define (bootstrap-executable-file-name system program)
133 "Return the FILE-NAME part of url where PROGRAM can be found for SYSTEM."
134 (match system
135 ("i586-gnu" (string-append system "/20200326/" program))
136 (_ (string-append system "/" program
137 "?id=44f07d1dc6806e97c4e9ee3e6be883cc59dc666e"))))
138
139 (define bootstrap-executable
140 (mlambda (program system)
141 "Return an origin for PROGRAM, a statically-linked bootstrap executable
142 built for SYSTEM."
143 (let ((system (if (string=? system "x86_64-linux")
144 "i686-linux"
145 system)))
146 (match (assoc-ref (assoc-ref %bootstrap-executables system)
147 program)
148 (#f
149 (raise (condition
150 (&message
151 (message
152 (format #f (G_ "could not find bootstrap binary '~a' \
153 for system '~a'")
154 program system))))))
155 ((bv)
156 (origin
157 (method url-fetch/executable)
158 (uri (map (cute string-append <>
159 (bootstrap-executable-file-name system program))
160 %bootstrap-executable-base-urls))
161 (file-name program)
162 (hash (content-hash bv sha256))))))))
163
164 \f
165 ;;;
166 ;;; Helper procedures.
167 ;;;
168
169 (define bootstrap-origin
170 (mlambdaq (source)
171 "Return a variant of SOURCE, an <origin> instance, whose method uses
172 %BOOTSTRAP-GUILE to do its job."
173 (define (boot fetch)
174 (lambda* (url hash-algo hash
175 #:optional name #:key system)
176 (fetch url hash-algo hash name
177 #:guile %bootstrap-guile
178 #:system system)))
179
180 (define %bootstrap-patch-inputs
181 ;; Packages used when an <origin> has a non-empty 'patches' field.
182 `(("tar" ,%bootstrap-coreutils&co)
183 ("xz" ,%bootstrap-coreutils&co)
184 ("bzip2" ,%bootstrap-coreutils&co)
185 ("gzip" ,%bootstrap-coreutils&co)
186 ("patch" ,%bootstrap-coreutils&co)))
187
188 (let ((orig-method (origin-method source)))
189 (if (or (not (null? (origin-patches source)))
190 (origin-snippet source))
191 (origin (inherit source)
192 (method (if (eq? orig-method url-fetch)
193 (boot url-fetch)
194 orig-method))
195 (patch-guile %bootstrap-guile)
196 (patch-inputs %bootstrap-patch-inputs)
197
198 ;; Patches can be origins as well, so process them.
199 (patches (map (match-lambda
200 ((? origin? patch)
201 (bootstrap-origin patch))
202 (patch patch))
203 (origin-patches source))))
204 source))))
205
206 (define* (package-from-tarball name source program-to-test description
207 #:key snippet)
208 "Return a package that correspond to the extraction of SOURCE.
209 PROGRAM-TO-TEST is #f or a string: the program to run after extraction of
210 SOURCE to check whether everything is alright. If SNIPPET is provided, it is
211 evaluated after extracting SOURCE. SNIPPET should return true if successful,
212 or false to signal an error."
213 (package
214 (name name)
215 (version "0")
216 (build-system trivial-build-system)
217 (arguments
218 `(#:guile ,%bootstrap-guile
219 #:modules ((guix build utils))
220 #:builder
221 (begin
222 (use-modules (guix build utils))
223
224 (let ((out (assoc-ref %outputs "out"))
225 (tar (assoc-ref %build-inputs "tar"))
226 (xz (assoc-ref %build-inputs "xz"))
227 (tarball (assoc-ref %build-inputs "tarball")))
228
229 (mkdir out)
230 (copy-file tarball "binaries.tar.xz")
231 (invoke xz "-d" "binaries.tar.xz")
232 (let ((builddir (getcwd)))
233 (with-directory-excursion out
234 (invoke tar "xvf"
235 (string-append builddir "/binaries.tar"))
236 ,@(if snippet (list snippet) '())
237 (or (not ,program-to-test)
238 (invoke (string-append "bin/" ,program-to-test)
239 "--version"))))))))
240 (inputs
241 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
242 ("xz" ,(bootstrap-executable "xz" (%current-system)))
243 ("tarball" ,(bootstrap-origin (source (%current-system))))))
244 (source #f)
245 (synopsis description)
246 (description description)
247 (home-page #f)
248 (license gpl3+)))
249
250 (define package-with-bootstrap-guile
251 (mlambdaq (p)
252 "Return a variant of P such that all its origins are fetched with
253 %BOOTSTRAP-GUILE."
254 (define rewritten-input
255 (match-lambda
256 ((name (? origin? o))
257 `(,name ,(bootstrap-origin o)))
258 ((name (? package? p) sub-drvs ...)
259 `(,name ,(package-with-bootstrap-guile p) ,@sub-drvs))
260 (x x)))
261
262 (package (inherit p)
263 (source (match (package-source p)
264 ((? origin? o) (bootstrap-origin o))
265 (s s)))
266 (inputs (map rewritten-input
267 (package-inputs p)))
268 (native-inputs (map rewritten-input
269 (package-native-inputs p)))
270 (propagated-inputs (map rewritten-input
271 (package-propagated-inputs p)))
272 (replacement (and=> (package-replacement p)
273 package-with-bootstrap-guile)))))
274
275 (define* (glibc-dynamic-linker
276 #:optional (system (or (and=> (%current-target-system)
277 gnu-triplet->nix-system)
278 (%current-system))))
279 "Return the name of Glibc's dynamic linker for SYSTEM."
280 ;; See the 'SYSDEP_KNOWN_INTERPRETER_NAMES' cpp macro in libc.
281 (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2")
282 ((string=? system "i686-linux") "/lib/ld-linux.so.2")
283 ((string=? system "armhf-linux") "/lib/ld-linux-armhf.so.3")
284 ((string=? system "mips64el-linux") "/lib/ld.so.1")
285 ((string=? system "i586-gnu") "/lib/ld.so.1")
286 ((string=? system "i686-gnu") "/lib/ld.so.1")
287 ((string=? system "aarch64-linux") "/lib/ld-linux-aarch64.so.1")
288 ((string=? system "powerpc-linux") "/lib/ld.so.1")
289 ((string=? system "powerpc64-linux") "/lib/ld64.so.1")
290 ((string=? system "powerpc64le-linux") "/lib/ld64.so.2")
291 ((string=? system "alpha-linux") "/lib/ld-linux.so.2")
292 ((string=? system "s390x-linux") "/lib/ld64.so.1")
293 ((string=? system "riscv64-linux") "/lib/ld-linux-riscv64-lp64d.so.1")
294
295 ;; XXX: This one is used bare-bones, without a libc, so add a case
296 ;; here just so we can keep going.
297 ((string=? system "arm-elf") "no-ld.so")
298 ((string=? system "arm-eabi") "no-ld.so")
299 ((string=? system "xtensa-elf") "no-ld.so")
300 ((string=? system "avr") "no-ld.so")
301 ((string=? system "propeller-elf") "no-ld.so")
302 ((string=? system "i686-mingw") "no-ld.so")
303 ((string=? system "x86_64-mingw") "no-ld.so")
304 ((string=? system "vc4-elf") "no-ld.so")
305
306 (else (error "dynamic linker name not known for this system"
307 system))))
308
309 \f
310 ;;;
311 ;;; Bootstrap packages.
312 ;;;
313
314 (define %bootstrap-base-urls
315 ;; This is where the initial binaries come from.
316 '("https://ftp.gnu.org/gnu/guix/bootstrap"
317 "https://alpha.gnu.org/gnu/guix/bootstrap"
318 "http://ftp.gnu.org/gnu/guix/bootstrap"
319 "http://alpha.gnu.org/gnu/guix/bootstrap"
320 "ftp://alpha.gnu.org/gnu/guix/bootstrap"
321 "http://www.fdn.fr/~lcourtes/software/guix/packages"
322 "http://flashner.co.il/guix/bootstrap"
323 "http://lilypond.org/janneke/guix/"))
324
325 (define (bootstrap-guile-url-path system)
326 "Return the URI for FILE."
327 (string-append "/" system
328 (match system
329 ("aarch64-linux"
330 "/20170217/guile-2.0.14.tar.xz")
331 ("armhf-linux"
332 "/20150101/guile-2.0.11.tar.xz")
333 ("i586-gnu"
334 "/20200326/guile-static-stripped-2.0.14-i586-pc-gnu.tar.xz")
335 (_
336 "/20131110/guile-2.0.9.tar.xz"))))
337
338 (define (bootstrap-guile-hash system)
339 "Return the SHA256 hash of the Guile bootstrap tarball for SYSTEM."
340 (match system
341 ("x86_64-linux"
342 (base32 "1w2p5zyrglzzniqgvyn1b55vprfzhgk8vzbzkkbdgl5248si0yq3"))
343 ("i686-linux"
344 (base32 "0im800m30abgh7msh331pcbjvb4n02smz5cfzf1srv0kpx3csmxp"))
345 ("mips64el-linux"
346 (base32 "0fzp93lvi0hn54acc0fpvhc7bvl0yc853k62l958cihk03q80ilr"))
347 ("armhf-linux"
348 (base32 "1mi3brl7l58aww34rawhvja84xc7l1b4hmwdmc36fp9q9mfx0lg5"))
349 ("aarch64-linux"
350 (base32 "1giy2aprjmn5fp9c4s9r125fljw4wv6ixy5739i5bffw4jgr0f9r"))
351 ("i586-gnu"
352 (base32 "0wgqpsmvg25rnqn49ap7kwd2qxccd8dr4lllzp7i3rjvgav27vac"))))
353
354 (define (bootstrap-guile-origin system)
355 "Return an <origin> object for the Guile tarball of SYSTEM."
356 (origin
357 (method url-fetch)
358 (uri (map (cute string-append <> (bootstrap-guile-url-path system))
359 %bootstrap-base-urls))
360 (sha256 (bootstrap-guile-hash system))))
361
362 (define (download-bootstrap-guile store system)
363 "Return a derivation that downloads the bootstrap Guile tarball for SYSTEM."
364 (let* ((path (bootstrap-guile-url-path system))
365 (base (basename path))
366 (urls (map (cut string-append <> path) %bootstrap-base-urls)))
367 (run-with-store store
368 (url-fetch urls 'sha256 (bootstrap-guile-hash system)
369 #:system system))))
370
371 (define* (raw-build store name inputs
372 #:key outputs system search-paths
373 #:allow-other-keys)
374 (define (->store file)
375 (run-with-store store
376 (lower-object (bootstrap-executable file system)
377 system)))
378
379 (let* ((tar (->store "tar"))
380 (xz (->store "xz"))
381 (mkdir (->store "mkdir"))
382 (bash (->store "bash"))
383 (guile (download-bootstrap-guile store system))
384 ;; The following code, run by the bootstrap guile after it is
385 ;; unpacked, creates a wrapper for itself to set its load path.
386 ;; This replaces the previous non-portable method based on
387 ;; reading the /proc/self/exe symlink.
388 (make-guile-wrapper
389 '(begin
390 (use-modules (ice-9 match))
391 (match (command-line)
392 ((_ out bash)
393 (let ((bin-dir (string-append out "/bin"))
394 (guile (string-append out "/bin/guile"))
395 (guile-real (string-append out "/bin/.guile-real"))
396 ;; We must avoid using a bare dollar sign in this code,
397 ;; because it would be interpreted by the shell.
398 (dollar (string (integer->char 36))))
399 (chmod bin-dir #o755)
400 (rename-file guile guile-real)
401 (call-with-output-file guile
402 (lambda (p)
403 (format p "\
404 #!~a
405 export GUILE_SYSTEM_PATH=~a/share/guile/2.0
406 export GUILE_SYSTEM_COMPILED_PATH=~a/lib/guile/2.0/ccache
407 exec -a \"~a0\" ~a \"~a@\"\n"
408 bash out out dollar guile-real dollar)))
409 (chmod guile #o555)
410 (chmod bin-dir #o555))))))
411 (builder
412 (add-text-to-store store
413 "build-bootstrap-guile.sh"
414 (format #f "
415 echo \"unpacking bootstrap Guile to '$out'...\"
416 ~a $out
417 cd $out
418 ~a -dc < $GUILE_TARBALL | ~a xv
419
420 # Use the bootstrap guile to create its own wrapper to set the load path.
421 GUILE_SYSTEM_PATH=$out/share/guile/2.0 \
422 GUILE_SYSTEM_COMPILED_PATH=$out/lib/guile/2.0/ccache \
423 $out/bin/guile -c ~s $out ~a
424
425 # Sanity check.
426 $out/bin/guile --version~%"
427 (derivation->output-path mkdir)
428 (derivation->output-path xz)
429 (derivation->output-path tar)
430 (format #f "~s" make-guile-wrapper)
431 (derivation->output-path bash)))))
432 (derivation store name
433 (derivation->output-path bash) `(,builder)
434 #:system system
435 #:inputs (map derivation-input
436 (list bash mkdir tar xz guile))
437 #:sources (list builder)
438 #:env-vars `(("GUILE_TARBALL"
439 . ,(derivation->output-path guile))))))
440
441 (define* (make-raw-bag name
442 #:key source inputs native-inputs outputs
443 system target)
444 (bag
445 (name name)
446 (system system)
447 (build-inputs inputs)
448 (build raw-build)))
449
450 (define %bootstrap-guile
451 ;; The Guile used to run the build scripts of the initial derivations.
452 ;; It is just unpacked from a tarball containing a pre-built binary.
453 ;; This is typically built using %GUILE-BOOTSTRAP-TARBALL below.
454 ;;
455 ;; XXX: Would need libc's `libnss_files2.so' for proper `getaddrinfo'
456 ;; support (for /etc/services).
457 (let ((raw (build-system
458 (name 'raw)
459 (description "Raw build system with direct store access")
460 (lower make-raw-bag))))
461 (package
462 (name "guile-bootstrap")
463 (version "2.0")
464 (source #f)
465 (build-system raw)
466 (synopsis "Bootstrap Guile")
467 (description "Pre-built Guile for bootstrapping purposes.")
468 (home-page #f)
469 (license lgpl3+))))
470
471 (define %bootstrap-coreutils&co
472 (package-from-tarball "bootstrap-binaries"
473 (lambda (system)
474 (origin
475 (method url-fetch)
476 (uri (map (cut string-append <> "/" system
477 (match system
478 ("armhf-linux"
479 "/20150101/static-binaries.tar.xz")
480 ("aarch64-linux"
481 "/20170217/static-binaries.tar.xz")
482 ("i586-gnu"
483 "/20200326/static-binaries-0-i586-pc-gnu.tar.xz")
484 (_
485 "/20131110/static-binaries.tar.xz")))
486 %bootstrap-base-urls))
487 (sha256
488 (match system
489 ("x86_64-linux"
490 (base32
491 "0c533p9dhczzcsa1117gmfq3pc8w362g4mx84ik36srpr7cx2bg4"))
492 ("i686-linux"
493 (base32
494 "0s5b3jb315n13m1k8095l0a5hfrsz8g0fv1b6riyc5hnxqyphlak"))
495 ("armhf-linux"
496 (base32
497 "0gf0fn2kbpxkjixkmx5f4z6hv6qpmgixl69zgg74dbsfdfj8jdv5"))
498 ("aarch64-linux"
499 (base32
500 "18dfiq6c6xhsdpbidigw6480wh0vdgsxqq3xindq4lpdgqlccpfh"))
501 ("i586-gnu"
502 (base32
503 "17kllqnf3fg79gzy9ansgi801c46yh9c23h4d923plvb0nfm1cfn"))
504 ("mips64el-linux"
505 (base32
506 "072y4wyfsj1bs80r6vbybbafy8ya4vfy7qj25dklwk97m6g71753"))))))
507 "fgrep" ; the program to test
508 "Bootstrap binaries of Coreutils, Awk, etc."
509 #:snippet
510 '(let ((path (list (string-append (getcwd) "/bin"))))
511 (chmod "bin" #o755)
512 (patch-shebang "bin/egrep" path)
513 (patch-shebang "bin/fgrep" path)
514 ;; Starting with grep@2.25 'egrep' and 'fgrep' are shell files
515 ;; that call 'grep'. If the bootstrap 'egrep' and 'fgrep'
516 ;; are not binaries then patch them to execute 'grep' via its
517 ;; absolute file name instead of searching for it in $PATH.
518 (if (not (elf-file? "bin/egrep"))
519 (substitute* '("bin/egrep" "bin/fgrep")
520 (("^exec grep") (string-append (getcwd) "/bin/grep"))))
521 (chmod "bin" #o555))))
522
523 (define-public %bootstrap-linux-libre-headers
524 (package-from-tarball
525 "linux-libre-headers-bootstrap"
526 (lambda (system)
527 (origin
528 (method url-fetch)
529 (uri (map (cute string-append <>
530 "/i686-linux/20190815/"
531 "linux-libre-headers-stripped-4.14.67-i686-linux.tar.xz")
532 %bootstrap-base-urls))
533 (sha256
534 (base32
535 "0sm2z9x4wk45bh6qfs94p0w1d6hsy6dqx9sw38qsqbvxwa1qzk8s"))))
536 #f ; no program to test
537 "Bootstrap linux-libre-headers"))
538
539 (define %bootstrap-binutils
540 (package-from-tarball "binutils-bootstrap"
541 (lambda (system)
542 (origin
543 (method url-fetch)
544 (uri (map (cut string-append <> "/" system
545 (match system
546 ("armhf-linux"
547 "/20150101/binutils-2.25.tar.xz")
548 ("aarch64-linux"
549 "/20170217/binutils-2.27.tar.xz")
550 ("i586-gnu"
551 "/20200326/binutils-static-stripped-2.34-i586-pc-gnu.tar.xz")
552 (_
553 "/20131110/binutils-2.23.2.tar.xz")))
554 %bootstrap-base-urls))
555 (sha256
556 (match system
557 ("x86_64-linux"
558 (base32
559 "1j5yivz7zkjqfsfmxzrrrffwyayjqyfxgpi89df0w4qziqs2dg20"))
560 ("i686-linux"
561 (base32
562 "14jgwf9gscd7l2pnz610b1zia06dvcm2qyzvni31b8zpgmcai2v9"))
563 ("armhf-linux"
564 (base32
565 "1v7dj6bzn6m36f20gw31l99xaabq4xrhrx3gwqkhhig0mdlmr69q"))
566 ("aarch64-linux"
567 (base32
568 "111s7ilfiby033rczc71797xrmaa3qlv179wdvsaq132pd51xv3n"))
569 ("i586-gnu"
570 (base32
571 "11kykv1kmqc5wln57rs4klaqa13hm952smkc57qcsyss21kfjprs"))
572 ("mips64el-linux"
573 (base32
574 "1x8kkhcxmfyzg1ddpz2pxs6fbdl6412r7x0nzbmi5n7mj8zw2gy7"))))))
575 "ld" ; the program to test
576 "Bootstrap binaries of the GNU Binutils"))
577
578 (define %bootstrap-glibc
579 ;; The initial libc.
580 (package
581 (name "glibc-bootstrap")
582 (version "0")
583 (source #f)
584 (build-system trivial-build-system)
585 (arguments
586 `(#:guile ,%bootstrap-guile
587 #:modules ((guix build utils))
588 #:builder
589 (begin
590 (use-modules (guix build utils))
591
592 (let ((out (assoc-ref %outputs "out"))
593 (tar (assoc-ref %build-inputs "tar"))
594 (xz (assoc-ref %build-inputs "xz"))
595 (tarball (assoc-ref %build-inputs "tarball")))
596
597 (mkdir out)
598 (copy-file tarball "binaries.tar.xz")
599 (invoke xz "-d" "binaries.tar.xz")
600 (let ((builddir (getcwd)))
601 (with-directory-excursion out
602 (invoke tar "xvf"
603 (string-append builddir
604 "/binaries.tar"))
605 (chmod "lib" #o755)
606
607 ;; Patch libc.so so it refers to the right path.
608 (substitute* "lib/libc.so"
609 (("/[^ ]+/lib/(libc|ld)" _ prefix)
610 (string-append out "/lib/" prefix)))
611
612 #t))))))
613 (inputs
614 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
615 ("xz" ,(bootstrap-executable "xz" (%current-system)))
616 ("tarball" ,(bootstrap-origin
617 (origin
618 (method url-fetch)
619 (uri (map (cut string-append <> "/" (%current-system)
620 (match (%current-system)
621 ("armhf-linux"
622 "/20150101/glibc-2.20.tar.xz")
623 ("aarch64-linux"
624 "/20170217/glibc-2.25.tar.xz")
625 ("i586-gnu"
626 "/20200326/glibc-stripped-2.31-i586-pc-gnu.tar.xz")
627 (_
628 "/20131110/glibc-2.18.tar.xz")))
629 %bootstrap-base-urls))
630 (sha256
631 (match (%current-system)
632 ("x86_64-linux"
633 (base32
634 "0jlqrgavvnplj1b083s20jj9iddr4lzfvwybw5xrcis9spbfzk7v"))
635 ("i686-linux"
636 (base32
637 "1hgrccw1zqdc7lvgivwa54d9l3zsim5pqm0dykxg0z522h6gr05w"))
638 ("armhf-linux"
639 (base32
640 "18cmgvpllqfpn6khsmivqib7ys8ymnq0hdzi3qp24prik0ykz8gn"))
641 ("aarch64-linux"
642 (base32
643 "07nx3x8598i2924rjnlrncg6rm61c9bmcczbbcpbx0fb742nvv5c"))
644 ("i586-gnu"
645 (base32
646 "14ddm10lpbas8bankmn5bcrlqvz1v5dnn1qjzxb19r57vd2w5952"))
647 ("mips64el-linux"
648 (base32
649 "0k97a3whzx3apsi9n2cbsrr79ad6lh00klxph9hw4fqyp1abkdsg")))))))))
650 (synopsis "Bootstrap binaries and headers of the GNU C Library")
651 (description synopsis)
652 (home-page #f)
653 (license lgpl2.1+)))
654
655 (define %bootstrap-gcc
656 ;; The initial GCC. Uses binaries from a tarball typically built by
657 ;; %GCC-BOOTSTRAP-TARBALL.
658 (package
659 (name "gcc-bootstrap")
660 (version "0")
661 (source #f)
662 (build-system trivial-build-system)
663 (arguments
664 `(#:guile ,%bootstrap-guile
665 #:modules ((guix build utils))
666 #:builder
667 (begin
668 (use-modules (guix build utils)
669 (ice-9 popen))
670
671 (let ((out (assoc-ref %outputs "out"))
672 (tar (assoc-ref %build-inputs "tar"))
673 (xz (assoc-ref %build-inputs "xz"))
674 (bash (assoc-ref %build-inputs "bash"))
675 (libc (assoc-ref %build-inputs "libc"))
676 (tarball (assoc-ref %build-inputs "tarball")))
677
678 (mkdir out)
679 (copy-file tarball "binaries.tar.xz")
680 (invoke xz "-d" "binaries.tar.xz")
681 (let ((builddir (getcwd))
682 (bindir (string-append out "/bin")))
683 (with-directory-excursion out
684 (invoke tar "xvf"
685 (string-append builddir "/binaries.tar")))
686
687 (with-directory-excursion bindir
688 (chmod "." #o755)
689 (rename-file "gcc" ".gcc-wrapped")
690 (call-with-output-file "gcc"
691 (lambda (p)
692 (format p "#!~a
693 exec ~a/bin/.gcc-wrapped -B~a/lib \
694 -Wl,-rpath -Wl,~a/lib \
695 -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
696 bash
697 out libc libc libc
698 ,(glibc-dynamic-linker))))
699
700 (chmod "gcc" #o555)
701 #t))))))
702 (inputs
703 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
704 ("xz" ,(bootstrap-executable "xz" (%current-system)))
705 ("bash" ,(bootstrap-executable "bash" (%current-system)))
706 ("libc" ,%bootstrap-glibc)
707 ("tarball" ,(bootstrap-origin
708 (origin
709 (method url-fetch)
710 (uri (map (cut string-append <> "/" (%current-system)
711 (match (%current-system)
712 ("armhf-linux"
713 "/20150101/gcc-4.8.4.tar.xz")
714 ("aarch64-linux"
715 "/20170217/gcc-5.4.0.tar.xz")
716 ("i586-gnu"
717 "/20200326/gcc-stripped-5.5.0-i586-pc-gnu.tar.xz")
718 (_
719 "/20131110/gcc-4.8.2.tar.xz")))
720 %bootstrap-base-urls))
721 (sha256
722 (match (%current-system)
723 ("x86_64-linux"
724 (base32
725 "17ga4m6195n4fnbzdkmik834znkhs53nkypp6557pl1ps7dgqbls"))
726 ("i686-linux"
727 (base32
728 "150c1arrf2k8vfy6dpxh59vcgs4p1bgiz2av5m19dynpks7rjnyw"))
729 ("armhf-linux"
730 (base32
731 "0ghz825yzp43fxw53kd6afm8nkz16f7dxi9xi40bfwc8x3nbbr8v"))
732 ("aarch64-linux"
733 (base32
734 "1ar3vdzyqbfm0z36kmvazvfswxhcihlacl2dzdjgiq25cqnq9ih1"))
735 ("i586-gnu"
736 (base32
737 "1j2zc58wzil71a34h7c70sd68dmqvcscrw3rmn2whq79vd70zvv5"))
738 ("mips64el-linux"
739 (base32
740 "1m5miqkyng45l745n0sfafdpjkqv9225xf44jqkygwsipj2cv9ks")))))))))
741 (native-search-paths
742 (list (search-path-specification
743 (variable "CPATH")
744 (files '("include")))
745 (search-path-specification
746 (variable "LIBRARY_PATH")
747 (files '("lib" "lib64")))))
748 (synopsis "Bootstrap binaries of the GNU Compiler Collection")
749 (description synopsis)
750 (home-page #f)
751 (license gpl3+)))
752
753 (define %bootstrap-mescc-tools
754 ;; The initial MesCC tools. Uses binaries from a tarball typically built by
755 ;; %MESCC-TOOLS-BOOTSTRAP-TARBALL.
756 (package
757 (name "bootstrap-mescc-tools")
758 (version "0.5.2")
759 (source #f)
760 (build-system trivial-build-system)
761 (arguments
762 `(#:guile ,%bootstrap-guile
763 #:modules ((guix build utils))
764 #:builder
765 (begin
766 (use-modules (guix build utils)
767 (ice-9 popen))
768 (let ((out (assoc-ref %outputs "out"))
769 (tar (assoc-ref %build-inputs "tar"))
770 (xz (assoc-ref %build-inputs "xz"))
771 (tarball (assoc-ref %build-inputs "tarball")))
772
773 (mkdir out)
774 (copy-file tarball "binaries.tar.xz")
775 (invoke xz "-d" "binaries.tar.xz")
776 (let ((builddir (getcwd))
777 (bindir (string-append out "/bin")))
778 (with-directory-excursion out
779 (invoke tar "xvf"
780 (string-append builddir "/binaries.tar"))))))))
781 (inputs
782 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
783 ("xz" ,(bootstrap-executable "xz" (%current-system)))
784 ("tarball"
785 ,(bootstrap-origin
786 (origin
787 (method url-fetch)
788 (uri (map
789 (cute string-append <>
790 "/i686-linux/20190815/"
791 "mescc-tools-static-stripped-0.5.2-i686-linux.tar.xz")
792 %bootstrap-base-urls))
793 (sha256
794 (base32
795 "0c3kklgghzh4q2dbpl6asb74cimp7hp6jscdwqwmzxbapgcl6582")))))))
796 (synopsis "Bootstrap binaries of MesCC Tools")
797 (description synopsis)
798 (home-page #f)
799 (supported-systems '("i686-linux" "x86_64-linux"))
800 (license gpl3+)))
801
802 (define %bootstrap-mes
803 ;; The initial Mes. Uses binaries from a tarball typically built by
804 ;; %MES-BOOTSTRAP-TARBALL.
805 (package
806 (name "bootstrap-mes")
807 (version "0")
808 (source #f)
809 (build-system trivial-build-system)
810 (arguments
811 `(#:guile ,%bootstrap-guile
812 #:modules ((guix build utils))
813 #:builder
814 (begin
815 (use-modules (guix build utils)
816 (ice-9 popen))
817 (let ((out (assoc-ref %outputs "out"))
818 (tar (assoc-ref %build-inputs "tar"))
819 (xz (assoc-ref %build-inputs "xz"))
820 (tarball (assoc-ref %build-inputs "tarball")))
821
822 (mkdir out)
823 (copy-file tarball "binaries.tar.xz")
824 (invoke xz "-d" "binaries.tar.xz")
825 (let ((builddir (getcwd))
826 (bindir (string-append out "/bin")))
827 (with-directory-excursion out
828 (invoke tar "xvf"
829 (string-append builddir "/binaries.tar"))))))))
830 (inputs
831 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
832 ("xz" ,(bootstrap-executable "xz" (%current-system)))
833 ("tarball"
834 ,(bootstrap-origin
835 (origin
836 (method url-fetch)
837 (uri (map
838 (cute string-append <>
839 "/i686-linux/20190815/"
840 "mes-minimal-stripped-0.19-i686-linux.tar.xz")
841 %bootstrap-base-urls))
842 (sha256
843 (base32
844 "1q4xjpx6nbn44kxnilpgl12bhpmwy2bblzwszc2ci7xkf400jcpv")))))))
845 (supported-systems '("i686-linux" "x86_64-linux"))
846 (synopsis "Bootstrap binaries of Mes")
847 (description synopsis)
848 (home-page #f)
849 (license gpl3+)))
850
851 (define (%bootstrap-inputs)
852 ;; The initial, pre-built inputs. From now on, we can start building our
853 ;; own packages.
854 (match (%current-system)
855 ((or "i686-linux" "x86_64-linux")
856 `(("linux-libre-headers" ,%bootstrap-linux-libre-headers)
857 ("bootstrap-mescc-tools" ,%bootstrap-mescc-tools)
858 ("mes" ,%bootstrap-mes)))
859 (_
860 `(("libc" ,%bootstrap-glibc)
861 ("gcc" ,%bootstrap-gcc)
862 ("binutils" ,%bootstrap-binutils)
863 ("coreutils&co" ,%bootstrap-coreutils&co)
864 ;; In gnu-build-system.scm, we rely on the availability of Bash.
865 ("bash" ,%bootstrap-coreutils&co)))))
866
867 (define %bootstrap-inputs-for-tests
868 ;; These are bootstrap inputs that are cheap to produce (no compilation
869 ;; needed) and that are meant to be used for testing. (These are those we
870 ;; used before the Mes-based reduced bootstrap.)
871 `(("libc" ,%bootstrap-glibc)
872 ("gcc" ,%bootstrap-gcc)
873 ("binutils" ,%bootstrap-binutils)
874 ("coreutils&co" ,%bootstrap-coreutils&co)
875 ("bash" ,%bootstrap-coreutils&co)))
876
877 ;;; bootstrap.scm ends here