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