gnu: multipath-tools: Treat libaio headers as system headers.
[jackhill/guix/guix.git] / gnu / packages / bootstrap.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
836a85da 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
ad1656dc 3;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
3b88f376 4;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
dbabfc47 5;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
18633d4f 6;;;
233e7676 7;;; This file is part of GNU Guix.
18633d4f 8;;;
233e7676 9;;; GNU Guix is free software; you can redistribute it and/or modify it
18633d4f
LC
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;;;
233e7676 14;;; GNU Guix is distributed in the hope that it will be useful, but
18633d4f
LC
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
233e7676 20;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18633d4f 21
1ffa7090 22(define-module (gnu packages bootstrap)
4a44e743 23 #:use-module (guix licenses)
59a43334 24 #:use-module (gnu packages)
18633d4f 25 #:use-module (guix packages)
62cab99c 26 #:use-module (guix download)
18633d4f
LC
27 #:use-module (guix build-system)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system trivial)
5c93d233
LC
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))
958dd3ce 34 #:use-module ((guix utils) #:select (gnu-triplet->nix-system))
f9704f17 35 #:use-module (guix memoization)
836a85da 36 #:use-module (guix i18n)
18633d4f
LC
37 #:use-module (srfi srfi-1)
38 #:use-module (srfi srfi-26)
836a85da
LC
39 #:use-module (srfi srfi-34)
40 #:use-module (srfi srfi-35)
18633d4f
LC
41 #:use-module (ice-9 match)
42 #:export (bootstrap-origin
43 package-with-bootstrap-guile
44 glibc-dynamic-linker
45
1ba0b1e6 46 bootstrap-executable
3e5750af
LC
47 bootstrap-guile-origin
48
18633d4f
LC
49 %bootstrap-guile
50 %bootstrap-coreutils&co
aec77e86 51 %bootstrap-linux-libre-headers
18633d4f
LC
52 %bootstrap-binutils
53 %bootstrap-gcc
54 %bootstrap-glibc
aec77e86 55 %bootstrap-inputs
b00a95be 56 %bootstrap-mescc-tools
03d76577
LC
57 %bootstrap-mes
58
59 %bootstrap-inputs-for-tests))
18633d4f
LC
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
836a85da
LC
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
125built 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' \
136for 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
18633d4f
LC
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)
f220a838 154 (lambda* (url hash-algo hash
18633d4f 155 #:optional name #:key system)
52c0c82f 156 (fetch url hash-algo hash name
18633d4f
LC
157 #:guile %bootstrap-guile
158 #:system system)))
159
5fbeb4e6
LC
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
18633d4f
LC
168 (let ((orig-method (origin-method source)))
169 (origin (inherit source)
87f5d366 170 (method (cond ((eq? orig-method url-fetch)
62cab99c 171 (boot url-fetch))
5fbeb4e6
LC
172 (else orig-method)))
173 (patch-guile %bootstrap-guile)
ce517b20
LC
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))))))
18633d4f 182
2959dbe9
MW
183(define* (package-from-tarball name source program-to-test description
184 #:key snippet)
dfb52abb 185 "Return a package that correspond to the extraction of SOURCE.
dbabfc47
JN
186PROGRAM-TO-TEST is #f or a string: the program to run after extraction of
187SOURCE to check whether everything is alright. If SNIPPET is provided, it is
188evaluated after extracting SOURCE. SNIPPET should return true if successful,
189or false to signal an error."
18633d4f 190 (package
dfb52abb 191 (name name)
18633d4f 192 (version "0")
18633d4f
LC
193 (build-system trivial-build-system)
194 (arguments
195 `(#:guile ,%bootstrap-guile
196 #:modules ((guix build utils))
197 #:builder
668ffe1e 198 (begin
18633d4f
LC
199 (use-modules (guix build utils))
200
668ffe1e
JN
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"))))))))
18633d4f 217 (inputs
836a85da
LC
218 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
219 ("xz" ,(bootstrap-executable "xz" (%current-system)))
dfb52abb
LC
220 ("tarball" ,(bootstrap-origin (source (%current-system))))))
221 (source #f)
222 (synopsis description)
7de1f103 223 (description description)
1fb78cb2 224 (home-page #f)
90f2801e 225 (license gpl3+)))
18633d4f
LC
226
227(define package-with-bootstrap-guile
6d7b26a3 228 (mlambdaq (p)
18633d4f
LC
229 "Return a variant of P such that all its origins are fetched with
230%BOOTSTRAP-GUILE."
231 (define rewritten-input
232 (match-lambda
55b2d921
LC
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)))
18633d4f
LC
238
239 (package (inherit p)
55b2d921
LC
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)))))
18633d4f 251
e7133c76
LC
252(define* (glibc-dynamic-linker
253 #:optional (system (or (and=> (%current-target-system)
254 gnu-triplet->nix-system)
255 (%current-system))))
18633d4f 256 "Return the name of Glibc's dynamic linker for SYSTEM."
c89e2107 257 ;; See the 'SYSDEP_KNOWN_INTERPRETER_NAMES' cpp macro in libc.
18633d4f
LC
258 (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2")
259 ((string=? system "i686-linux") "/lib/ld-linux.so.2")
3f00ff8b 260 ((string=? system "armhf-linux") "/lib/ld-linux-armhf.so.3")
827d2891 261 ((string=? system "mips64el-linux") "/lib/ld.so.1")
66feaa32
MB
262 ((string=? system "i586-gnu") "/lib/ld.so.1")
263 ((string=? system "i686-gnu") "/lib/ld.so.1")
19c444f4 264 ((string=? system "aarch64-linux") "/lib/ld-linux-aarch64.so.1")
4a6f099e 265 ((string=? system "powerpc-linux") "/lib/ld.so.1")
c89e2107 266 ((string=? system "powerpc64le-linux") "/lib/ld64.so.2")
605fec78 267 ((string=? system "alpha-linux") "/lib/ld-linux.so.2")
b91004c2 268 ((string=? system "s390x-linux") "/lib/ld64.so.1")
7180dd67 269 ((string=? system "riscv64-linux") "/lib/ld-linux-riscv64-lp64d.so.1")
9d307460
LC
270
271 ;; XXX: This one is used bare-bones, without a libc, so add a case
272 ;; here just so we can keep going.
7f2d67c8 273 ((string=? system "arm-elf") "no-ld.so")
35a37efb 274 ((string=? system "arm-eabi") "no-ld.so")
9d307460 275 ((string=? system "xtensa-elf") "no-ld.so")
a5b60e3c 276 ((string=? system "avr") "no-ld.so")
6f5b1c91 277 ((string=? system "propeller-elf") "no-ld.so")
3135b95f 278 ((string=? system "i686-mingw") "no-ld.so")
7cf06d62 279 ((string=? system "vc4-elf") "no-ld.so")
9d307460 280
18633d4f
LC
281 (else (error "dynamic linker name not known for this system"
282 system))))
283
284\f
285;;;
286;;; Bootstrap packages.
287;;;
288
5c93d233
LC
289(define %bootstrap-base-urls
290 ;; This is where the initial binaries come from.
894fc4e9 291 '("https://alpha.gnu.org/gnu/guix/bootstrap"
5c93d233 292 "http://alpha.gnu.org/gnu/guix/bootstrap"
894fc4e9 293 "ftp://alpha.gnu.org/gnu/guix/bootstrap"
5c93d233
LC
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
3e5750af
LC
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
5c93d233
LC
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
0d5a559f
LC
339(define* (raw-build store name inputs
340 #:key outputs system search-paths
341 #:allow-other-keys)
342 (define (->store file)
836a85da
LC
343 (run-with-store store
344 (origin->derivation (bootstrap-executable file system)
345 system)))
0d5a559f
LC
346
347 (let* ((tar (->store "tar"))
348 (xz (->store "xz"))
349 (mkdir (->store "mkdir"))
350 (bash (->store "bash"))
5c93d233 351 (guile (download-bootstrap-guile store system))
5d6792f0
MW
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
373export GUILE_SYSTEM_PATH=~a/share/guile/2.0
374export GUILE_SYSTEM_COMPILED_PATH=~a/lib/guile/2.0/ccache
375exec -a \"~a0\" ~a \"~a@\"\n"
376 bash out out dollar guile-real dollar)))
377 (chmod guile #o555)
378 (chmod bin-dir #o555))))))
0d5a559f
LC
379 (builder
380 (add-text-to-store store
381 "build-bootstrap-guile.sh"
382 (format #f "
383echo \"unpacking bootstrap Guile to '$out'...\"
384~a $out
385cd $out
5c93d233 386~a -dc < $GUILE_TARBALL | ~a xv
0d5a559f 387
5d6792f0
MW
388# Use the bootstrap guile to create its own wrapper to set the load path.
389GUILE_SYSTEM_PATH=$out/share/guile/2.0 \
390GUILE_SYSTEM_COMPILED_PATH=$out/lib/guile/2.0/ccache \
391$out/bin/guile -c ~s $out ~a
392
0d5a559f
LC
393# Sanity check.
394$out/bin/guile --version~%"
836a85da
LC
395 (derivation->output-path mkdir)
396 (derivation->output-path xz)
397 (derivation->output-path tar)
5d6792f0 398 (format #f "~s" make-guile-wrapper)
836a85da 399 (derivation->output-path bash)))))
0d5a559f 400 (derivation store name
836a85da 401 (derivation->output-path bash) `(,builder)
0d5a559f 402 #:system system
836a85da
LC
403 #:inputs `((,bash) (,mkdir) (,tar) (,xz)
404 (,builder) (,guile))
5c93d233
LC
405 #:env-vars `(("GUILE_TARBALL"
406 . ,(derivation->output-path guile))))))
0d5a559f
LC
407
408(define* (make-raw-bag name
d3d337d2
LC
409 #:key source inputs native-inputs outputs
410 system target)
0d5a559f
LC
411 (bag
412 (name name)
d3d337d2 413 (system system)
0d5a559f
LC
414 (build-inputs inputs)
415 (build raw-build)))
416
18633d4f
LC
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
0d5a559f
LC
425 (name 'raw)
426 (description "Raw build system with direct store access")
427 (lower make-raw-bag))))
18633d4f
LC
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)
4a44e743 436 (license lgpl3+))))
18633d4f 437
18633d4f
LC
438(define %bootstrap-coreutils&co
439 (package-from-tarball "bootstrap-binaries"
440 (lambda (system)
441 (origin
87f5d366 442 (method url-fetch)
04732c37 443 (uri (map (cut string-append <> "/" system
aa1e1947
MW
444 (match system
445 ("armhf-linux"
446 "/20150101/static-binaries.tar.xz")
3b88f376
EF
447 ("aarch64-linux"
448 "/20170217/static-binaries.tar.xz")
aa1e1947
MW
449 (_
450 "/20131110/static-binaries.tar.xz")))
04732c37 451 %bootstrap-base-urls))
18633d4f
LC
452 (sha256
453 (match system
454 ("x86_64-linux"
455 (base32
06213498 456 "0c533p9dhczzcsa1117gmfq3pc8w362g4mx84ik36srpr7cx2bg4"))
18633d4f
LC
457 ("i686-linux"
458 (base32
06213498 459 "0s5b3jb315n13m1k8095l0a5hfrsz8g0fv1b6riyc5hnxqyphlak"))
aa1e1947
MW
460 ("armhf-linux"
461 (base32
462 "0gf0fn2kbpxkjixkmx5f4z6hv6qpmgixl69zgg74dbsfdfj8jdv5"))
3b88f376
EF
463 ("aarch64-linux"
464 (base32
465 "18dfiq6c6xhsdpbidigw6480wh0vdgsxqq3xindq4lpdgqlccpfh"))
f57ff219
MW
466 ("mips64el-linux"
467 (base32
06213498 468 "072y4wyfsj1bs80r6vbybbafy8ya4vfy7qj25dklwk97m6g71753"))))))
84cbe39c
MW
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)
653add37
EF
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"))))
ad1656dc 483 (chmod "bin" #o555))))
18633d4f 484
aec77e86
JN
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)
da3c6a7f
JN
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))
aec77e86
JN
495 (sha256
496 (base32
da3c6a7f 497 "0sm2z9x4wk45bh6qfs94p0w1d6hsy6dqx9sw38qsqbvxwa1qzk8s"))))
aec77e86
JN
498 #f ; no program to test
499 "Bootstrap linux-libre-headers"))
500
18633d4f
LC
501(define %bootstrap-binutils
502 (package-from-tarball "binutils-bootstrap"
503 (lambda (system)
504 (origin
87f5d366 505 (method url-fetch)
04732c37 506 (uri (map (cut string-append <> "/" system
aa1e1947
MW
507 (match system
508 ("armhf-linux"
509 "/20150101/binutils-2.25.tar.xz")
3b88f376
EF
510 ("aarch64-linux"
511 "/20170217/binutils-2.27.tar.xz")
aa1e1947
MW
512 (_
513 "/20131110/binutils-2.23.2.tar.xz")))
04732c37 514 %bootstrap-base-urls))
18633d4f
LC
515 (sha256
516 (match system
517 ("x86_64-linux"
518 (base32
06213498 519 "1j5yivz7zkjqfsfmxzrrrffwyayjqyfxgpi89df0w4qziqs2dg20"))
18633d4f
LC
520 ("i686-linux"
521 (base32
06213498 522 "14jgwf9gscd7l2pnz610b1zia06dvcm2qyzvni31b8zpgmcai2v9"))
aa1e1947
MW
523 ("armhf-linux"
524 (base32
525 "1v7dj6bzn6m36f20gw31l99xaabq4xrhrx3gwqkhhig0mdlmr69q"))
3b88f376
EF
526 ("aarch64-linux"
527 (base32
528 "111s7ilfiby033rczc71797xrmaa3qlv179wdvsaq132pd51xv3n"))
f57ff219
MW
529 ("mips64el-linux"
530 (base32
06213498 531 "1x8kkhcxmfyzg1ddpz2pxs6fbdl6412r7x0nzbmi5n7mj8zw2gy7"))))))
18633d4f
LC
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
668ffe1e 546 (begin
18633d4f
LC
547 (use-modules (guix build utils))
548
668ffe1e
JN
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))))))
18633d4f 570 (inputs
836a85da
LC
571 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
572 ("xz" ,(bootstrap-executable "xz" (%current-system)))
dd6b9a37
LC
573 ("tarball" ,(bootstrap-origin
574 (origin
575 (method url-fetch)
576 (uri (map (cut string-append <> "/" (%current-system)
aa1e1947
MW
577 (match (%current-system)
578 ("armhf-linux"
579 "/20150101/glibc-2.20.tar.xz")
3b88f376
EF
580 ("aarch64-linux"
581 "/20170217/glibc-2.25.tar.xz")
aa1e1947
MW
582 (_
583 "/20131110/glibc-2.18.tar.xz")))
dd6b9a37
LC
584 %bootstrap-base-urls))
585 (sha256
586 (match (%current-system)
587 ("x86_64-linux"
588 (base32
06213498 589 "0jlqrgavvnplj1b083s20jj9iddr4lzfvwybw5xrcis9spbfzk7v"))
dd6b9a37
LC
590 ("i686-linux"
591 (base32
06213498 592 "1hgrccw1zqdc7lvgivwa54d9l3zsim5pqm0dykxg0z522h6gr05w"))
aa1e1947
MW
593 ("armhf-linux"
594 (base32
595 "18cmgvpllqfpn6khsmivqib7ys8ymnq0hdzi3qp24prik0ykz8gn"))
3b88f376
EF
596 ("aarch64-linux"
597 (base32
598 "07nx3x8598i2924rjnlrncg6rm61c9bmcczbbcpbx0fb742nvv5c"))
f57ff219
MW
599 ("mips64el-linux"
600 (base32
06213498 601 "0k97a3whzx3apsi9n2cbsrr79ad6lh00klxph9hw4fqyp1abkdsg")))))))))
18633d4f 602 (synopsis "Bootstrap binaries and headers of the GNU C Library")
7de1f103 603 (description synopsis)
1fb78cb2
LC
604 (home-page #f)
605 (license lgpl2.1+)))
18633d4f
LC
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
21c203a5
LC
616 `(#:guile ,%bootstrap-guile
617 #:modules ((guix build utils))
618 #:builder
668ffe1e 619 (begin
21c203a5
LC
620 (use-modules (guix build utils)
621 (ice-9 popen))
18633d4f 622
668ffe1e
JN
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
18633d4f
LC
645exec ~a/bin/.gcc-wrapped -B~a/lib \
646 -Wl,-rpath -Wl,~a/lib \
647 -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
668ffe1e
JN
648 bash
649 out libc libc libc
650 ,(glibc-dynamic-linker))))
18633d4f 651
668ffe1e
JN
652 (chmod "gcc" #o555)
653 #t))))))
18633d4f 654 (inputs
836a85da
LC
655 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
656 ("xz" ,(bootstrap-executable "xz" (%current-system)))
657 ("bash" ,(bootstrap-executable "bash" (%current-system)))
18633d4f 658 ("libc" ,%bootstrap-glibc)
dd6b9a37
LC
659 ("tarball" ,(bootstrap-origin
660 (origin
668ffe1e
JN
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")))))))))
a18eda27
LC
688 (native-search-paths
689 (list (search-path-specification
690 (variable "CPATH")
af070955 691 (files '("include")))
a18eda27
LC
692 (search-path-specification
693 (variable "LIBRARY_PATH")
af070955 694 (files '("lib" "lib64")))))
18633d4f 695 (synopsis "Bootstrap binaries of the GNU Compiler Collection")
7de1f103 696 (description synopsis)
1fb78cb2
LC
697 (home-page #f)
698 (license gpl3+)))
18633d4f 699
b00a95be
JN
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
836a85da
LC
729 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
730 ("xz" ,(bootstrap-executable "xz" (%current-system)))
da3c6a7f
JN
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")))))))
b00a95be
JN
743 (synopsis "Bootstrap binaries of MesCC Tools")
744 (description synopsis)
745 (home-page #f)
0b07f227 746 (supported-systems '("i686-linux" "x86_64-linux"))
b00a95be
JN
747 (license gpl3+)))
748
5f02c9b7
JN
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
836a85da
LC
778 `(("tar" ,(bootstrap-executable "tar" (%current-system)))
779 ("xz" ,(bootstrap-executable "xz" (%current-system)))
da3c6a7f
JN
780 ("tarball"
781 ,(bootstrap-origin
782 (origin
783 (method url-fetch)
c89bbccc
JN
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))
da3c6a7f 789 (sha256
0b07f227
LC
790 (base32
791 "0k7kkl68a6xaadv47ij0nr9jm5ca1ffj38n7f2lg80y72wdkwr9h")))))))
792 (supported-systems '("i686-linux" "x86_64-linux"))
5f02c9b7
JN
793 (synopsis "Bootstrap binaries of Mes")
794 (description synopsis)
795 (home-page #f)
796 (license gpl3+)))
797
a2b2070b 798(define (%bootstrap-inputs)
18633d4f
LC
799 ;; The initial, pre-built inputs. From now on, we can start building our
800 ;; own packages.
d536c39e 801 `(,@(match (%current-system)
eb443459
JN
802 ((or "i686-linux" "x86_64-linux")
803 `(("linux-libre-headers" ,%bootstrap-linux-libre-headers)
4fd4efc8 804 ("bootstrap-mescc-tools" ,%bootstrap-mescc-tools)
03a45a40 805 ("mes" ,%bootstrap-mes)))
eb443459
JN
806 (_
807 `(("libc" ,%bootstrap-glibc)
808 ("gcc" ,%bootstrap-gcc)
809 ("binutils" ,%bootstrap-binutils))))
9d1d434c
LC
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)))
18633d4f 814
03d76577
LC
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
18633d4f 825;;; bootstrap.scm ends here