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