gnu: shflags: Update to 1.2.3.
[jackhill/guix/guix.git] / gnu / packages / bootstrap.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
f9704f17 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
2959dbe9 3;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
3b88f376 4;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
18633d4f 5;;;
233e7676 6;;; This file is part of GNU Guix.
18633d4f 7;;;
233e7676 8;;; GNU Guix is free software; you can redistribute it and/or modify it
18633d4f
LC
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
233e7676 13;;; GNU Guix is distributed in the hope that it will be useful, but
18633d4f
LC
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
233e7676 19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18633d4f 20
1ffa7090 21(define-module (gnu packages bootstrap)
4a44e743 22 #:use-module (guix licenses)
59a43334 23 #:use-module (gnu packages)
18633d4f 24 #:use-module (guix packages)
62cab99c 25 #:use-module (guix download)
18633d4f
LC
26 #:use-module (guix build-system)
27 #:use-module (guix build-system gnu)
28 #:use-module (guix build-system trivial)
5c93d233
LC
29 #:use-module ((guix store)
30 #:select (run-with-store add-to-store add-text-to-store))
31 #:use-module ((guix derivations)
32 #:select (derivation derivation->output-path))
958dd3ce 33 #:use-module ((guix utils) #:select (gnu-triplet->nix-system))
653add37 34 #:use-module ((guix build utils) #:select (elf-file?))
f9704f17 35 #:use-module (guix memoization)
18633d4f
LC
36 #:use-module (srfi srfi-1)
37 #:use-module (srfi srfi-26)
38 #:use-module (ice-9 match)
39 #:export (bootstrap-origin
40 package-with-bootstrap-guile
41 glibc-dynamic-linker
42
3e5750af
LC
43 bootstrap-guile-origin
44
18633d4f
LC
45 %bootstrap-guile
46 %bootstrap-coreutils&co
47 %bootstrap-binutils
48 %bootstrap-gcc
49 %bootstrap-glibc
50 %bootstrap-inputs))
51
52;;; Commentary:
53;;;
54;;; Pre-built packages that are used to bootstrap the
55;;; distribution--i.e., to build all the core packages from scratch.
56;;;
57;;; Code:
58
59
60\f
61;;;
62;;; Helper procedures.
63;;;
64
65(define (bootstrap-origin source)
66 "Return a variant of SOURCE, an <origin> instance, whose method uses
67%BOOTSTRAP-GUILE to do its job."
68 (define (boot fetch)
f220a838 69 (lambda* (url hash-algo hash
18633d4f 70 #:optional name #:key system)
52c0c82f 71 (fetch url hash-algo hash name
18633d4f
LC
72 #:guile %bootstrap-guile
73 #:system system)))
74
5fbeb4e6
LC
75 (define %bootstrap-patch-inputs
76 ;; Packages used when an <origin> has a non-empty 'patches' field.
77 `(("tar" ,%bootstrap-coreutils&co)
78 ("xz" ,%bootstrap-coreutils&co)
79 ("bzip2" ,%bootstrap-coreutils&co)
80 ("gzip" ,%bootstrap-coreutils&co)
81 ("patch" ,%bootstrap-coreutils&co)))
82
18633d4f
LC
83 (let ((orig-method (origin-method source)))
84 (origin (inherit source)
87f5d366 85 (method (cond ((eq? orig-method url-fetch)
62cab99c 86 (boot url-fetch))
5fbeb4e6
LC
87 (else orig-method)))
88 (patch-guile %bootstrap-guile)
ce517b20
LC
89 (patch-inputs %bootstrap-patch-inputs)
90
91 ;; Patches can be origins as well, so process them.
92 (patches (map (match-lambda
93 ((? origin? patch)
94 (bootstrap-origin patch))
95 (patch patch))
96 (origin-patches source))))))
18633d4f 97
2959dbe9
MW
98(define* (package-from-tarball name source program-to-test description
99 #:key snippet)
dfb52abb
LC
100 "Return a package that correspond to the extraction of SOURCE.
101PROGRAM-TO-TEST is a program to run after extraction of SOURCE, to
2959dbe9
MW
102check whether everything is alright. If SNIPPET is provided, it is
103evaluated after extracting SOURCE. SNIPPET should return true if
104successful, or false to signal an error."
18633d4f 105 (package
dfb52abb 106 (name name)
18633d4f 107 (version "0")
18633d4f
LC
108 (build-system trivial-build-system)
109 (arguments
110 `(#:guile ,%bootstrap-guile
111 #:modules ((guix build utils))
112 #:builder
113 (let ((out (assoc-ref %outputs "out"))
114 (tar (assoc-ref %build-inputs "tar"))
115 (xz (assoc-ref %build-inputs "xz"))
116 (tarball (assoc-ref %build-inputs "tarball")))
117 (use-modules (guix build utils))
118
119 (mkdir out)
120 (copy-file tarball "binaries.tar.xz")
121 (system* xz "-d" "binaries.tar.xz")
122 (let ((builddir (getcwd)))
123 (with-directory-excursion out
124 (and (zero? (system* tar "xvf"
125 (string-append builddir "/binaries.tar")))
2959dbe9 126 ,@(if snippet (list snippet) '())
18633d4f
LC
127 (zero? (system* (string-append "bin/" ,program-to-test)
128 "--version"))))))))
129 (inputs
dd6b9a37
LC
130 `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
131 ("xz" ,(search-bootstrap-binary "xz" (%current-system)))
dfb52abb
LC
132 ("tarball" ,(bootstrap-origin (source (%current-system))))))
133 (source #f)
134 (synopsis description)
7de1f103 135 (description description)
1fb78cb2 136 (home-page #f)
90f2801e 137 (license gpl3+)))
18633d4f
LC
138
139(define package-with-bootstrap-guile
6d7b26a3 140 (mlambdaq (p)
18633d4f
LC
141 "Return a variant of P such that all its origins are fetched with
142%BOOTSTRAP-GUILE."
143 (define rewritten-input
144 (match-lambda
55b2d921
LC
145 ((name (? origin? o))
146 `(,name ,(bootstrap-origin o)))
147 ((name (? package? p) sub-drvs ...)
148 `(,name ,(package-with-bootstrap-guile p) ,@sub-drvs))
149 (x x)))
18633d4f
LC
150
151 (package (inherit p)
55b2d921
LC
152 (source (match (package-source p)
153 ((? origin? o) (bootstrap-origin o))
154 (s s)))
155 (inputs (map rewritten-input
156 (package-inputs p)))
157 (native-inputs (map rewritten-input
158 (package-native-inputs p)))
159 (propagated-inputs (map rewritten-input
160 (package-propagated-inputs p)))
161 (replacement (and=> (package-replacement p)
162 package-with-bootstrap-guile)))))
18633d4f 163
e7133c76
LC
164(define* (glibc-dynamic-linker
165 #:optional (system (or (and=> (%current-target-system)
166 gnu-triplet->nix-system)
167 (%current-system))))
18633d4f 168 "Return the name of Glibc's dynamic linker for SYSTEM."
c89e2107 169 ;; See the 'SYSDEP_KNOWN_INTERPRETER_NAMES' cpp macro in libc.
18633d4f
LC
170 (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2")
171 ((string=? system "i686-linux") "/lib/ld-linux.so.2")
3f00ff8b 172 ((string=? system "armhf-linux") "/lib/ld-linux-armhf.so.3")
827d2891 173 ((string=? system "mips64el-linux") "/lib/ld.so.1")
66feaa32
MB
174 ((string=? system "i586-gnu") "/lib/ld.so.1")
175 ((string=? system "i686-gnu") "/lib/ld.so.1")
19c444f4 176 ((string=? system "aarch64-linux") "/lib/ld-linux-aarch64.so.1")
4a6f099e 177 ((string=? system "powerpc-linux") "/lib/ld.so.1")
c89e2107 178 ((string=? system "powerpc64le-linux") "/lib/ld64.so.2")
605fec78 179 ((string=? system "alpha-linux") "/lib/ld-linux.so.2")
b91004c2 180 ((string=? system "s390x-linux") "/lib/ld64.so.1")
9d307460
LC
181
182 ;; XXX: This one is used bare-bones, without a libc, so add a case
183 ;; here just so we can keep going.
35a37efb 184 ((string=? system "arm-eabi") "no-ld.so")
9d307460 185 ((string=? system "xtensa-elf") "no-ld.so")
a5b60e3c 186 ((string=? system "avr") "no-ld.so")
6f5b1c91 187 ((string=? system "propeller-elf") "no-ld.so")
3135b95f 188 ((string=? system "i686-mingw") "no-ld.so")
7cf06d62 189 ((string=? system "vc4-elf") "no-ld.so")
9d307460 190
18633d4f
LC
191 (else (error "dynamic linker name not known for this system"
192 system))))
193
194\f
195;;;
196;;; Bootstrap packages.
197;;;
198
5c93d233
LC
199(define %bootstrap-base-urls
200 ;; This is where the initial binaries come from.
894fc4e9 201 '("https://alpha.gnu.org/gnu/guix/bootstrap"
5c93d233 202 "http://alpha.gnu.org/gnu/guix/bootstrap"
894fc4e9 203 "ftp://alpha.gnu.org/gnu/guix/bootstrap"
5c93d233
LC
204 "http://www.fdn.fr/~lcourtes/software/guix/packages"
205 "http://flashner.co.il/guix/bootstrap"))
206
207(define (bootstrap-guile-url-path system)
208 "Return the URI for FILE."
209 (string-append "/" system
210 (match system
211 ("aarch64-linux"
212 "/20170217/guile-2.0.14.tar.xz")
213 ("armhf-linux"
214 "/20150101/guile-2.0.11.tar.xz")
215 (_
216 "/20131110/guile-2.0.9.tar.xz"))))
217
218(define (bootstrap-guile-hash system)
219 "Return the SHA256 hash of the Guile bootstrap tarball for SYSTEM."
220 (match system
221 ("x86_64-linux"
222 (base32 "1w2p5zyrglzzniqgvyn1b55vprfzhgk8vzbzkkbdgl5248si0yq3"))
223 ("i686-linux"
224 (base32 "0im800m30abgh7msh331pcbjvb4n02smz5cfzf1srv0kpx3csmxp"))
225 ("mips64el-linux"
226 (base32 "0fzp93lvi0hn54acc0fpvhc7bvl0yc853k62l958cihk03q80ilr"))
227 ("armhf-linux"
228 (base32 "1mi3brl7l58aww34rawhvja84xc7l1b4hmwdmc36fp9q9mfx0lg5"))
229 ("aarch64-linux"
230 (base32 "1giy2aprjmn5fp9c4s9r125fljw4wv6ixy5739i5bffw4jgr0f9r"))))
231
3e5750af
LC
232(define (bootstrap-guile-origin system)
233 "Return an <origin> object for the Guile tarball of SYSTEM."
234 (origin
235 (method url-fetch)
236 (uri (map (cute string-append <> (bootstrap-guile-url-path system))
237 %bootstrap-base-urls))
238 (sha256 (bootstrap-guile-hash system))))
239
5c93d233
LC
240(define (download-bootstrap-guile store system)
241 "Return a derivation that downloads the bootstrap Guile tarball for SYSTEM."
242 (let* ((path (bootstrap-guile-url-path system))
243 (base (basename path))
244 (urls (map (cut string-append <> path) %bootstrap-base-urls)))
245 (run-with-store store
246 (url-fetch urls 'sha256 (bootstrap-guile-hash system)
247 #:system system))))
248
0d5a559f
LC
249(define* (raw-build store name inputs
250 #:key outputs system search-paths
251 #:allow-other-keys)
252 (define (->store file)
253 (add-to-store store file #t "sha256"
254 (or (search-bootstrap-binary file
255 system)
256 (error "bootstrap binary not found"
257 file system))))
258
259 (let* ((tar (->store "tar"))
260 (xz (->store "xz"))
261 (mkdir (->store "mkdir"))
262 (bash (->store "bash"))
5c93d233 263 (guile (download-bootstrap-guile store system))
5d6792f0
MW
264 ;; The following code, run by the bootstrap guile after it is
265 ;; unpacked, creates a wrapper for itself to set its load path.
266 ;; This replaces the previous non-portable method based on
267 ;; reading the /proc/self/exe symlink.
268 (make-guile-wrapper
269 '(begin
270 (use-modules (ice-9 match))
271 (match (command-line)
272 ((_ out bash)
273 (let ((bin-dir (string-append out "/bin"))
274 (guile (string-append out "/bin/guile"))
275 (guile-real (string-append out "/bin/.guile-real"))
276 ;; We must avoid using a bare dollar sign in this code,
277 ;; because it would be interpreted by the shell.
278 (dollar (string (integer->char 36))))
279 (chmod bin-dir #o755)
280 (rename-file guile guile-real)
281 (call-with-output-file guile
282 (lambda (p)
283 (format p "\
284#!~a
285export GUILE_SYSTEM_PATH=~a/share/guile/2.0
286export GUILE_SYSTEM_COMPILED_PATH=~a/lib/guile/2.0/ccache
287exec -a \"~a0\" ~a \"~a@\"\n"
288 bash out out dollar guile-real dollar)))
289 (chmod guile #o555)
290 (chmod bin-dir #o555))))))
0d5a559f
LC
291 (builder
292 (add-text-to-store store
293 "build-bootstrap-guile.sh"
294 (format #f "
295echo \"unpacking bootstrap Guile to '$out'...\"
296~a $out
297cd $out
5c93d233 298~a -dc < $GUILE_TARBALL | ~a xv
0d5a559f 299
5d6792f0
MW
300# Use the bootstrap guile to create its own wrapper to set the load path.
301GUILE_SYSTEM_PATH=$out/share/guile/2.0 \
302GUILE_SYSTEM_COMPILED_PATH=$out/lib/guile/2.0/ccache \
303$out/bin/guile -c ~s $out ~a
304
0d5a559f
LC
305# Sanity check.
306$out/bin/guile --version~%"
5c93d233 307 mkdir xz tar
5d6792f0
MW
308 (format #f "~s" make-guile-wrapper)
309 bash)
5c93d233 310 (list mkdir xz tar bash))))
0d5a559f
LC
311 (derivation store name
312 bash `(,builder)
313 #:system system
5c93d233
LC
314 #:inputs `((,bash) (,builder) (,guile))
315 #:env-vars `(("GUILE_TARBALL"
316 . ,(derivation->output-path guile))))))
0d5a559f
LC
317
318(define* (make-raw-bag name
d3d337d2
LC
319 #:key source inputs native-inputs outputs
320 system target)
0d5a559f
LC
321 (bag
322 (name name)
d3d337d2 323 (system system)
0d5a559f
LC
324 (build-inputs inputs)
325 (build raw-build)))
326
18633d4f
LC
327(define %bootstrap-guile
328 ;; The Guile used to run the build scripts of the initial derivations.
329 ;; It is just unpacked from a tarball containing a pre-built binary.
330 ;; This is typically built using %GUILE-BOOTSTRAP-TARBALL below.
331 ;;
332 ;; XXX: Would need libc's `libnss_files2.so' for proper `getaddrinfo'
333 ;; support (for /etc/services).
334 (let ((raw (build-system
0d5a559f
LC
335 (name 'raw)
336 (description "Raw build system with direct store access")
337 (lower make-raw-bag))))
18633d4f
LC
338 (package
339 (name "guile-bootstrap")
340 (version "2.0")
341 (source #f)
342 (build-system raw)
343 (synopsis "Bootstrap Guile")
344 (description "Pre-built Guile for bootstrapping purposes.")
345 (home-page #f)
4a44e743 346 (license lgpl3+))))
18633d4f 347
18633d4f
LC
348(define %bootstrap-coreutils&co
349 (package-from-tarball "bootstrap-binaries"
350 (lambda (system)
351 (origin
87f5d366 352 (method url-fetch)
04732c37 353 (uri (map (cut string-append <> "/" system
aa1e1947
MW
354 (match system
355 ("armhf-linux"
356 "/20150101/static-binaries.tar.xz")
3b88f376
EF
357 ("aarch64-linux"
358 "/20170217/static-binaries.tar.xz")
aa1e1947
MW
359 (_
360 "/20131110/static-binaries.tar.xz")))
04732c37 361 %bootstrap-base-urls))
18633d4f
LC
362 (sha256
363 (match system
364 ("x86_64-linux"
365 (base32
06213498 366 "0c533p9dhczzcsa1117gmfq3pc8w362g4mx84ik36srpr7cx2bg4"))
18633d4f
LC
367 ("i686-linux"
368 (base32
06213498 369 "0s5b3jb315n13m1k8095l0a5hfrsz8g0fv1b6riyc5hnxqyphlak"))
aa1e1947
MW
370 ("armhf-linux"
371 (base32
372 "0gf0fn2kbpxkjixkmx5f4z6hv6qpmgixl69zgg74dbsfdfj8jdv5"))
3b88f376
EF
373 ("aarch64-linux"
374 (base32
375 "18dfiq6c6xhsdpbidigw6480wh0vdgsxqq3xindq4lpdgqlccpfh"))
f57ff219
MW
376 ("mips64el-linux"
377 (base32
06213498 378 "072y4wyfsj1bs80r6vbybbafy8ya4vfy7qj25dklwk97m6g71753"))))))
84cbe39c
MW
379 "fgrep" ; the program to test
380 "Bootstrap binaries of Coreutils, Awk, etc."
381 #:snippet
382 '(let ((path (list (string-append (getcwd) "/bin"))))
383 (chmod "bin" #o755)
384 (patch-shebang "bin/egrep" path)
385 (patch-shebang "bin/fgrep" path)
653add37
EF
386 ;; Starting with grep@2.25 'egrep' and 'fgrep' are shell files
387 ;; that call 'grep'. If the bootstrap 'egrep' and 'fgrep'
388 ;; are not binaries then patch them to execute 'grep' via its
389 ;; absolute file name instead of searching for it in $PATH.
390 (if (not (elf-file? "bin/egrep"))
391 (substitute* '("bin/egrep" "bin/fgrep")
392 (("^exec grep") (string-append (getcwd) "/bin/grep"))))
84cbe39c
MW
393 (chmod "bin" #o555)
394 #t)))
18633d4f
LC
395
396(define %bootstrap-binutils
397 (package-from-tarball "binutils-bootstrap"
398 (lambda (system)
399 (origin
87f5d366 400 (method url-fetch)
04732c37 401 (uri (map (cut string-append <> "/" system
aa1e1947
MW
402 (match system
403 ("armhf-linux"
404 "/20150101/binutils-2.25.tar.xz")
3b88f376
EF
405 ("aarch64-linux"
406 "/20170217/binutils-2.27.tar.xz")
aa1e1947
MW
407 (_
408 "/20131110/binutils-2.23.2.tar.xz")))
04732c37 409 %bootstrap-base-urls))
18633d4f
LC
410 (sha256
411 (match system
412 ("x86_64-linux"
413 (base32
06213498 414 "1j5yivz7zkjqfsfmxzrrrffwyayjqyfxgpi89df0w4qziqs2dg20"))
18633d4f
LC
415 ("i686-linux"
416 (base32
06213498 417 "14jgwf9gscd7l2pnz610b1zia06dvcm2qyzvni31b8zpgmcai2v9"))
aa1e1947
MW
418 ("armhf-linux"
419 (base32
420 "1v7dj6bzn6m36f20gw31l99xaabq4xrhrx3gwqkhhig0mdlmr69q"))
3b88f376
EF
421 ("aarch64-linux"
422 (base32
423 "111s7ilfiby033rczc71797xrmaa3qlv179wdvsaq132pd51xv3n"))
f57ff219
MW
424 ("mips64el-linux"
425 (base32
06213498 426 "1x8kkhcxmfyzg1ddpz2pxs6fbdl6412r7x0nzbmi5n7mj8zw2gy7"))))))
18633d4f
LC
427 "ld" ; the program to test
428 "Bootstrap binaries of the GNU Binutils"))
429
430(define %bootstrap-glibc
431 ;; The initial libc.
432 (package
433 (name "glibc-bootstrap")
434 (version "0")
435 (source #f)
436 (build-system trivial-build-system)
437 (arguments
438 `(#:guile ,%bootstrap-guile
439 #:modules ((guix build utils))
440 #:builder
441 (let ((out (assoc-ref %outputs "out"))
442 (tar (assoc-ref %build-inputs "tar"))
443 (xz (assoc-ref %build-inputs "xz"))
444 (tarball (assoc-ref %build-inputs "tarball")))
445 (use-modules (guix build utils))
446
447 (mkdir out)
448 (copy-file tarball "binaries.tar.xz")
449 (system* xz "-d" "binaries.tar.xz")
450 (let ((builddir (getcwd)))
451 (with-directory-excursion out
452 (system* tar "xvf"
453 (string-append builddir
454 "/binaries.tar"))
455 (chmod "lib" #o755)
456
457 ;; Patch libc.so so it refers to the right path.
458 (substitute* "lib/libc.so"
459 (("/[^ ]+/lib/(libc|ld)" _ prefix)
460 (string-append out "/lib/" prefix))))))))
461 (inputs
dd6b9a37
LC
462 `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
463 ("xz" ,(search-bootstrap-binary "xz" (%current-system)))
464 ("tarball" ,(bootstrap-origin
465 (origin
466 (method url-fetch)
467 (uri (map (cut string-append <> "/" (%current-system)
aa1e1947
MW
468 (match (%current-system)
469 ("armhf-linux"
470 "/20150101/glibc-2.20.tar.xz")
3b88f376
EF
471 ("aarch64-linux"
472 "/20170217/glibc-2.25.tar.xz")
aa1e1947
MW
473 (_
474 "/20131110/glibc-2.18.tar.xz")))
dd6b9a37
LC
475 %bootstrap-base-urls))
476 (sha256
477 (match (%current-system)
478 ("x86_64-linux"
479 (base32
06213498 480 "0jlqrgavvnplj1b083s20jj9iddr4lzfvwybw5xrcis9spbfzk7v"))
dd6b9a37
LC
481 ("i686-linux"
482 (base32
06213498 483 "1hgrccw1zqdc7lvgivwa54d9l3zsim5pqm0dykxg0z522h6gr05w"))
aa1e1947
MW
484 ("armhf-linux"
485 (base32
486 "18cmgvpllqfpn6khsmivqib7ys8ymnq0hdzi3qp24prik0ykz8gn"))
3b88f376
EF
487 ("aarch64-linux"
488 (base32
489 "07nx3x8598i2924rjnlrncg6rm61c9bmcczbbcpbx0fb742nvv5c"))
f57ff219
MW
490 ("mips64el-linux"
491 (base32
06213498 492 "0k97a3whzx3apsi9n2cbsrr79ad6lh00klxph9hw4fqyp1abkdsg")))))))))
18633d4f 493 (synopsis "Bootstrap binaries and headers of the GNU C Library")
7de1f103 494 (description synopsis)
1fb78cb2
LC
495 (home-page #f)
496 (license lgpl2.1+)))
18633d4f
LC
497
498(define %bootstrap-gcc
499 ;; The initial GCC. Uses binaries from a tarball typically built by
500 ;; %GCC-BOOTSTRAP-TARBALL.
501 (package
502 (name "gcc-bootstrap")
503 (version "0")
504 (source #f)
505 (build-system trivial-build-system)
506 (arguments
21c203a5
LC
507 `(#:guile ,%bootstrap-guile
508 #:modules ((guix build utils))
509 #:builder
510 (let ((out (assoc-ref %outputs "out"))
511 (tar (assoc-ref %build-inputs "tar"))
512 (xz (assoc-ref %build-inputs "xz"))
513 (bash (assoc-ref %build-inputs "bash"))
514 (libc (assoc-ref %build-inputs "libc"))
515 (tarball (assoc-ref %build-inputs "tarball")))
516 (use-modules (guix build utils)
517 (ice-9 popen))
18633d4f 518
21c203a5
LC
519 (mkdir out)
520 (copy-file tarball "binaries.tar.xz")
521 (system* xz "-d" "binaries.tar.xz")
522 (let ((builddir (getcwd))
523 (bindir (string-append out "/bin")))
524 (with-directory-excursion out
525 (system* tar "xvf"
526 (string-append builddir "/binaries.tar")))
18633d4f 527
21c203a5
LC
528 (with-directory-excursion bindir
529 (chmod "." #o755)
530 (rename-file "gcc" ".gcc-wrapped")
531 (call-with-output-file "gcc"
532 (lambda (p)
533 (format p "#!~a
18633d4f
LC
534exec ~a/bin/.gcc-wrapped -B~a/lib \
535 -Wl,-rpath -Wl,~a/lib \
536 -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
21c203a5
LC
537 bash
538 out libc libc libc
539 ,(glibc-dynamic-linker))))
18633d4f 540
21c203a5 541 (chmod "gcc" #o555))))))
18633d4f 542 (inputs
dd6b9a37
LC
543 `(("tar" ,(search-bootstrap-binary "tar" (%current-system)))
544 ("xz" ,(search-bootstrap-binary "xz" (%current-system)))
545 ("bash" ,(search-bootstrap-binary "bash" (%current-system)))
18633d4f 546 ("libc" ,%bootstrap-glibc)
dd6b9a37
LC
547 ("tarball" ,(bootstrap-origin
548 (origin
549 (method url-fetch)
550 (uri (map (cut string-append <> "/" (%current-system)
aa1e1947
MW
551 (match (%current-system)
552 ("armhf-linux"
553 "/20150101/gcc-4.8.4.tar.xz")
3b88f376
EF
554 ("aarch64-linux"
555 "/20170217/gcc-5.4.0.tar.xz")
aa1e1947
MW
556 (_
557 "/20131110/gcc-4.8.2.tar.xz")))
dd6b9a37
LC
558 %bootstrap-base-urls))
559 (sha256
560 (match (%current-system)
561 ("x86_64-linux"
562 (base32
06213498 563 "17ga4m6195n4fnbzdkmik834znkhs53nkypp6557pl1ps7dgqbls"))
dd6b9a37
LC
564 ("i686-linux"
565 (base32
06213498 566 "150c1arrf2k8vfy6dpxh59vcgs4p1bgiz2av5m19dynpks7rjnyw"))
aa1e1947
MW
567 ("armhf-linux"
568 (base32
569 "0ghz825yzp43fxw53kd6afm8nkz16f7dxi9xi40bfwc8x3nbbr8v"))
3b88f376
EF
570 ("aarch64-linux"
571 (base32
572 "1ar3vdzyqbfm0z36kmvazvfswxhcihlacl2dzdjgiq25cqnq9ih1"))
f57ff219
MW
573 ("mips64el-linux"
574 (base32
06213498 575 "1m5miqkyng45l745n0sfafdpjkqv9225xf44jqkygwsipj2cv9ks")))))))))
a18eda27
LC
576 (native-search-paths
577 (list (search-path-specification
578 (variable "CPATH")
af070955 579 (files '("include")))
a18eda27
LC
580 (search-path-specification
581 (variable "LIBRARY_PATH")
af070955 582 (files '("lib" "lib64")))))
18633d4f 583 (synopsis "Bootstrap binaries of the GNU Compiler Collection")
7de1f103 584 (description synopsis)
1fb78cb2
LC
585 (home-page #f)
586 (license gpl3+)))
18633d4f
LC
587
588(define %bootstrap-inputs
589 ;; The initial, pre-built inputs. From now on, we can start building our
590 ;; own packages.
591 `(("libc" ,%bootstrap-glibc)
592 ("gcc" ,%bootstrap-gcc)
593 ("binutils" ,%bootstrap-binutils)
9d1d434c
LC
594 ("coreutils&co" ,%bootstrap-coreutils&co)
595
596 ;; In gnu-build-system.scm, we rely on the availability of Bash.
597 ("bash" ,%bootstrap-coreutils&co)))
18633d4f
LC
598
599;;; bootstrap.scm ends here