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