Commit | Line | Data |
---|---|---|
bdb36958 | 1 | ;;; GNU Guix --- Functional package management for GNU |
20bf5fce | 2 | ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> |
bdb36958 LC |
3 | ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr> |
4 | ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org> | |
13f7f2fd | 5 | ;;; Copyright © 2014, 2015, 2017 Mark H Weaver <mhw@netris.org> |
809b0a90 | 6 | ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il> |
53bfec7b | 7 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
bdb36958 LC |
8 | ;;; |
9 | ;;; This file is part of GNU Guix. | |
10 | ;;; | |
11 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
12 | ;;; under the terms of the GNU General Public License as published by | |
13 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
14 | ;;; your option) any later version. | |
15 | ;;; | |
16 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
17 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;;; GNU General Public License for more details. | |
20 | ;;; | |
21 | ;;; You should have received a copy of the GNU General Public License | |
22 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
23 | ||
24 | (define-module (gnu packages commencement) | |
25 | #:use-module ((guix licenses) | |
26 | #:select (gpl3+ lgpl2.0+ public-domain)) | |
b2fd8f63 | 27 | #:use-module (gnu packages) |
bdb36958 LC |
28 | #:use-module (gnu packages bootstrap) |
29 | #:use-module (gnu packages base) | |
30 | #:use-module (gnu packages bash) | |
31 | #:use-module (gnu packages gcc) | |
2d5d63d7 | 32 | #:use-module (gnu packages m4) |
8efe2a22 | 33 | #:use-module (gnu packages code) |
c00a9fbf | 34 | #:use-module (gnu packages file) |
bdb36958 | 35 | #:use-module (gnu packages gawk) |
2d5d63d7 | 36 | #:use-module (gnu packages bison) |
d75acc29 | 37 | #:use-module (gnu packages flex) |
bdb36958 | 38 | #:use-module (gnu packages guile) |
6162b95d | 39 | #:use-module (gnu packages gettext) |
bdb36958 LC |
40 | #:use-module (gnu packages multiprecision) |
41 | #:use-module (gnu packages compression) | |
42 | #:use-module (gnu packages perl) | |
43 | #:use-module (gnu packages linux) | |
d75acc29 | 44 | #:use-module (gnu packages hurd) |
bdb36958 LC |
45 | #:use-module (gnu packages texinfo) |
46 | #:use-module (gnu packages pkg-config) | |
47 | #:use-module (guix packages) | |
48 | #:use-module (guix download) | |
49 | #:use-module (guix build-system gnu) | |
50 | #:use-module (guix build-system trivial) | |
8102cf0b | 51 | #:use-module (guix memoization) |
bdb36958 LC |
52 | #:use-module (guix utils) |
53 | #:use-module (srfi srfi-1) | |
54 | #:use-module (srfi srfi-26) | |
55 | #:use-module (ice-9 vlist) | |
d75acc29 MR |
56 | #:use-module (ice-9 match) |
57 | #:use-module (ice-9 regex)) | |
bdb36958 LC |
58 | |
59 | ;;; Commentary: | |
60 | ;;; | |
61 | ;;; This is the commencement, this is where things start. Before the | |
62 | ;;; commencement, of course, there's the 'bootstrap' module, which provides us | |
63 | ;;; with the initial binaries. This module uses those bootstrap binaries to | |
64 | ;;; actually build up the whole tool chain that make up the implicit inputs of | |
65 | ;;; 'gnu-build-system'. | |
66 | ;;; | |
67 | ;;; To avoid circular dependencies, this module should not be imported | |
68 | ;;; directly from anywhere. | |
69 | ;;; | |
a1df45e9 CM |
70 | ;;; Below, we frequently use "inherit" to create modified packages. The |
71 | ;;; reason why we use "inherit" instead of "package/inherit" is because we do | |
72 | ;;; not want these commencement packages to inherit grafts. By definition, | |
73 | ;;; these packages are not depended on at run time by any of the packages we | |
74 | ;;; use. Thus it does not make sense to inherit grafts. Furthermore, those | |
75 | ;;; grafts would often lead to extra overhead for users who would end up | |
76 | ;;; downloading those "-boot0" packages just to build package replacements | |
77 | ;;; that are in fact not going to be used. | |
78 | ;;; | |
bdb36958 LC |
79 | ;;; Code: |
80 | ||
81 | (define gnu-make-boot0 | |
82 | (package-with-bootstrap-guile | |
83 | (package (inherit gnu-make) | |
84 | (name "make-boot0") | |
bdb36958 LC |
85 | (arguments |
86 | `(#:guile ,%bootstrap-guile | |
87 | #:implicit-inputs? #f | |
88 | #:tests? #f ; cannot run "make check" | |
89 | ,@(substitute-keyword-arguments (package-arguments gnu-make) | |
90 | ((#:phases phases) | |
8e5e8724 LC |
91 | `(modify-phases ,phases |
92 | (replace 'build | |
93 | (lambda _ | |
53bfec7b TGR |
94 | (invoke "./build.sh") |
95 | #t)) | |
8e5e8724 LC |
96 | (replace 'install |
97 | (lambda* (#:key outputs #:allow-other-keys) | |
98 | (let* ((out (assoc-ref outputs "out")) | |
99 | (bin (string-append out "/bin"))) | |
53bfec7b TGR |
100 | (install-file "make" bin) |
101 | #t)))))))) | |
bdb36958 LC |
102 | (native-inputs '()) ; no need for 'pkg-config' |
103 | (inputs %bootstrap-inputs)))) | |
104 | ||
105 | (define diffutils-boot0 | |
106 | (package-with-bootstrap-guile | |
107 | (let ((p (package-with-explicit-inputs diffutils | |
108 | `(("make" ,gnu-make-boot0) | |
109 | ,@%bootstrap-inputs) | |
110 | #:guile %bootstrap-guile))) | |
111 | (package (inherit p) | |
09964b4f | 112 | (name "diffutils-boot0") |
bdb36958 LC |
113 | (arguments `(#:tests? #f ; the test suite needs diffutils |
114 | ,@(package-arguments p))))))) | |
115 | ||
116 | (define findutils-boot0 | |
117 | (package-with-bootstrap-guile | |
09964b4f LC |
118 | (package-with-explicit-inputs (package |
119 | (inherit findutils) | |
120 | (name "findutils-boot0")) | |
bdb36958 LC |
121 | `(("make" ,gnu-make-boot0) |
122 | ("diffutils" ,diffutils-boot0) ; for tests | |
123 | ,@%bootstrap-inputs) | |
124 | (current-source-location) | |
125 | #:guile %bootstrap-guile))) | |
126 | ||
c00a9fbf MW |
127 | (define file-boot0 |
128 | (package-with-bootstrap-guile | |
f00b85ff LC |
129 | (package-with-explicit-inputs (package |
130 | (inherit file) | |
09964b4f | 131 | (name "file-boot0")) |
c00a9fbf MW |
132 | `(("make" ,gnu-make-boot0) |
133 | ,@%bootstrap-inputs) | |
134 | (current-source-location) | |
135 | #:guile %bootstrap-guile))) | |
136 | ||
bdb36958 LC |
137 | |
138 | (define %boot0-inputs | |
139 | `(("make" ,gnu-make-boot0) | |
140 | ("diffutils" ,diffutils-boot0) | |
141 | ("findutils" ,findutils-boot0) | |
c00a9fbf | 142 | ("file" ,file-boot0) |
bdb36958 LC |
143 | ,@%bootstrap-inputs)) |
144 | ||
bdb36958 LC |
145 | (define* (boot-triplet #:optional (system (%current-system))) |
146 | ;; Return the triplet used to create the cross toolchain needed in the | |
147 | ;; first bootstrapping stage. | |
148 | (nix-system->gnu-triplet system "guix")) | |
149 | ||
150 | ;; Following Linux From Scratch, build a cross-toolchain in stage 0. That | |
151 | ;; toolchain actually targets the same OS and arch, but it has the advantage | |
152 | ;; of being independent of the libc and tools in %BOOTSTRAP-INPUTS, since | |
153 | ;; GCC-BOOT0 (below) is built without any reference to the target libc. | |
154 | ||
155 | (define binutils-boot0 | |
156 | (package-with-bootstrap-guile | |
45953b1f | 157 | (package (inherit binutils) |
bdb36958 LC |
158 | (name "binutils-cross-boot0") |
159 | (arguments | |
160 | `(#:guile ,%bootstrap-guile | |
161 | #:implicit-inputs? #f | |
f8badf15 MW |
162 | |
163 | #:modules ((guix build gnu-build-system) | |
164 | (guix build utils) | |
165 | (ice-9 ftw)) ; for 'scandir' | |
ac423120 EF |
166 | #:phases (modify-phases %standard-phases |
167 | (add-after 'install 'add-symlinks | |
168 | (lambda* (#:key outputs #:allow-other-keys) | |
169 | ;; The cross-gcc invokes 'as', 'ld', etc, without the | |
170 | ;; triplet prefix, so add symlinks. | |
171 | (let ((out (assoc-ref outputs "out")) | |
172 | (triplet-prefix (string-append ,(boot-triplet) "-"))) | |
173 | (define (has-triplet-prefix? name) | |
174 | (string-prefix? triplet-prefix name)) | |
175 | (define (remove-triplet-prefix name) | |
176 | (substring name (string-length triplet-prefix))) | |
177 | (with-directory-excursion (string-append out "/bin") | |
178 | (for-each (lambda (name) | |
179 | (symlink name (remove-triplet-prefix name))) | |
180 | (scandir "." has-triplet-prefix?))) | |
181 | #t)))) | |
f8badf15 | 182 | |
bdb36958 LC |
183 | ,@(substitute-keyword-arguments (package-arguments binutils) |
184 | ((#:configure-flags cf) | |
185 | `(cons ,(string-append "--target=" (boot-triplet)) | |
186 | ,cf))))) | |
187 | (inputs %boot0-inputs)))) | |
188 | ||
b810a850 LC |
189 | (define libstdc++-boot0 |
190 | ;; GCC's libcc1 is always built as a shared library (the top-level | |
191 | ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer | |
192 | ;; to libstdc++.so. We cannot build libstdc++-5.3 because it relies on | |
809b0a90 | 193 | ;; C++14 features missing in some of our bootstrap compilers. |
5e268faf | 194 | (let ((lib (package-with-bootstrap-guile (make-libstdc++ gcc-4.9)))) |
b810a850 LC |
195 | (package |
196 | (inherit lib) | |
197 | (name "libstdc++-boot0") | |
198 | (arguments | |
199 | `(#:guile ,%bootstrap-guile | |
200 | #:implicit-inputs? #f | |
201 | ||
202 | ;; XXX: libstdc++.so NEEDs ld.so for some reason. | |
203 | #:validate-runpath? #f | |
204 | ||
205 | ,@(package-arguments lib))) | |
206 | (inputs %boot0-inputs) | |
207 | (native-inputs '())))) | |
208 | ||
bdb36958 LC |
209 | (define gcc-boot0 |
210 | (package-with-bootstrap-guile | |
c92f1c0a | 211 | (package (inherit gcc) |
bdb36958 LC |
212 | (name "gcc-cross-boot0") |
213 | (arguments | |
214 | `(#:guile ,%bootstrap-guile | |
215 | #:implicit-inputs? #f | |
216 | #:modules ((guix build gnu-build-system) | |
217 | (guix build utils) | |
218 | (ice-9 regex) | |
219 | (srfi srfi-1) | |
220 | (srfi srfi-26)) | |
c92f1c0a | 221 | ,@(substitute-keyword-arguments (package-arguments gcc) |
bdb36958 LC |
222 | ((#:configure-flags flags) |
223 | `(append (list ,(string-append "--target=" (boot-triplet)) | |
224 | ||
225 | ;; No libc yet. | |
226 | "--without-headers" | |
227 | ||
228 | ;; Disable features not needed at this stage. | |
229 | "--disable-shared" | |
230 | "--enable-languages=c,c++" | |
231 | ||
232 | ;; libstdc++ cannot be built at this stage | |
233 | ;; ("Link tests are not allowed after | |
234 | ;; GCC_NO_EXECUTABLES."). | |
235 | "--disable-libstdc++-v3" | |
236 | ||
237 | "--disable-threads" | |
238 | "--disable-libmudflap" | |
239 | "--disable-libatomic" | |
240 | "--disable-libsanitizer" | |
241 | "--disable-libitm" | |
242 | "--disable-libgomp" | |
de4ac325 LC |
243 | "--disable-libcilkrts" |
244 | "--disable-libvtv" | |
bdb36958 LC |
245 | "--disable-libssp" |
246 | "--disable-libquadmath" | |
247 | "--disable-decimal-float") | |
98bd851e LC |
248 | (remove (cut string-match |
249 | "--(with-system-zlib|enable-languages.*)" <>) | |
bdb36958 LC |
250 | ,flags))) |
251 | ((#:phases phases) | |
53bfec7b TGR |
252 | `(modify-phases ,phases |
253 | (add-after 'unpack 'unpack-gmp&co | |
254 | (lambda* (#:key inputs #:allow-other-keys) | |
255 | (let ((gmp (assoc-ref %build-inputs "gmp-source")) | |
256 | (mpfr (assoc-ref %build-inputs "mpfr-source")) | |
257 | (mpc (assoc-ref %build-inputs "mpc-source"))) | |
258 | ||
259 | ;; To reduce the set of pre-built bootstrap inputs, build | |
260 | ;; GMP & co. from GCC. | |
261 | (for-each (lambda (source) | |
262 | (invoke "tar" "xvf" source)) | |
263 | (list gmp mpfr mpc)) | |
264 | ||
265 | ;; Create symlinks like `gmp' -> `gmp-x.y.z'. | |
266 | ,@(map (lambda (lib) | |
267 | ;; Drop trailing letters, as gmp-6.0.0a unpacks | |
268 | ;; into gmp-6.0.0. | |
269 | `(symlink ,(string-trim-right | |
539bf8f2 | 270 | (package-full-name lib "-") |
53bfec7b TGR |
271 | char-set:letter) |
272 | ,(package-name lib))) | |
273 | (list gmp-6.0 mpfr mpc)) | |
274 | #t))) | |
275 | (add-after 'install 'symlink-libgcc_eh | |
276 | (lambda* (#:key outputs #:allow-other-keys) | |
277 | (let ((out (assoc-ref outputs "lib"))) | |
278 | ;; Glibc wants to link against libgcc_eh, so provide | |
279 | ;; it. | |
280 | (with-directory-excursion | |
281 | (string-append out "/lib/gcc/" | |
282 | ,(boot-triplet) | |
283 | "/" ,(package-version gcc)) | |
284 | (symlink "libgcc.a" "libgcc_eh.a")) | |
285 | #t)))))))) | |
bdb36958 | 286 | |
8309c389 | 287 | (inputs `(("gmp-source" ,(package-source gmp-6.0)) |
bdb36958 LC |
288 | ("mpfr-source" ,(package-source mpfr)) |
289 | ("mpc-source" ,(package-source mpc)) | |
290 | ("binutils-cross" ,binutils-boot0) | |
291 | ||
b810a850 LC |
292 | ;; The libstdc++ that libcc1 links against. |
293 | ("libstdc++" ,libstdc++-boot0) | |
294 | ||
bdb36958 LC |
295 | ;; Call it differently so that the builder can check whether |
296 | ;; the "libc" input is #f. | |
297 | ("libc-native" ,@(assoc-ref %boot0-inputs "libc")) | |
9dee9e8f LC |
298 | ,@(alist-delete "libc" %boot0-inputs))) |
299 | ||
19d27131 MC |
300 | ;; No need for the native-inputs to build the documentation at this stage. |
301 | (native-inputs `())))) | |
bdb36958 LC |
302 | |
303 | (define perl-boot0 | |
4de35074 LC |
304 | (let ((perl (package |
305 | (inherit perl) | |
09964b4f | 306 | (name "perl-boot0") |
4de35074 | 307 | (arguments |
81cea47d LC |
308 | ;; At the very least, this must not depend on GCC & co. |
309 | (let ((args `(#:disallowed-references | |
310 | ,(list %bootstrap-binutils)))) | |
311 | (substitute-keyword-arguments (package-arguments perl) | |
312 | ((#:phases phases) | |
313 | `(modify-phases ,phases | |
314 | ;; Pthread support is missing in the bootstrap compiler | |
315 | ;; (broken spec file), so disable it. | |
316 | (add-before 'configure 'disable-pthreads | |
317 | (lambda _ | |
318 | (substitute* "Configure" | |
319 | (("^libswanted=(.*)pthread" _ before) | |
75f3aace MW |
320 | (string-append "libswanted=" before))) |
321 | #t)))) | |
156c0810 BW |
322 | ;; Do not configure with '-Dusethreads' since pthread |
323 | ;; support is missing. | |
324 | ((#:configure-flags configure-flags) | |
325 | `(delete "-Dusethreads" ,configure-flags)))))))) | |
81cea47d LC |
326 | (package-with-bootstrap-guile |
327 | (package-with-explicit-inputs perl | |
328 | %boot0-inputs | |
329 | (current-source-location) | |
330 | #:guile %bootstrap-guile)))) | |
bdb36958 | 331 | |
d75acc29 MR |
332 | (define bison-boot0 |
333 | ;; This Bison is needed to build MiG so we need it early in the process. | |
334 | ;; It is also needed to rebuild Bash's parser, which is modified by | |
335 | ;; its CVE patches. Remove it when it's no longer needed. | |
336 | (let* ((m4 (package-with-bootstrap-guile | |
337 | (package-with-explicit-inputs m4 %boot0-inputs | |
338 | (current-source-location) | |
339 | #:guile %bootstrap-guile))) | |
340 | (bison (package (inherit bison) | |
341 | (propagated-inputs `(("m4" ,m4))) | |
342 | (inputs '()) ;remove Flex... | |
343 | (arguments | |
344 | '(#:tests? #f ;... and thus disable tests | |
345 | ||
346 | ;; Zero timestamps in liby.a; this must be done | |
347 | ;; explicitly here because the bootstrap Binutils don't | |
348 | ;; do that (default is "cru".) | |
349 | #:make-flags '("ARFLAGS=crD" "RANLIB=ranlib -D" | |
350 | "V=1")))))) | |
351 | (package | |
352 | (inherit (package-with-bootstrap-guile | |
353 | (package-with-explicit-inputs bison %boot0-inputs | |
354 | (current-source-location) | |
355 | #:guile %bootstrap-guile))) | |
356 | (native-inputs `(("perl" ,perl-boot0)))))) | |
357 | ||
358 | (define flex-boot0 | |
359 | ;; This Flex is needed to build MiG. | |
360 | (let* ((flex (package (inherit flex) | |
361 | (native-inputs `(("bison" ,bison-boot0))) | |
362 | (propagated-inputs `(("m4" ,m4))) | |
363 | (inputs `(("indent" ,indent))) | |
364 | (arguments '(#:tests? #f))))) | |
365 | (package-with-bootstrap-guile | |
366 | (package-with-explicit-inputs flex %boot0-inputs | |
367 | (current-source-location) | |
368 | #:guile %bootstrap-guile)))) | |
369 | ||
8102cf0b LC |
370 | (define linux-libre-headers-boot0 |
371 | (mlambda () | |
372 | "Return Linux-Libre header files for the bootstrap environment." | |
373 | ;; Note: this is wrapped in a thunk to nicely handle circular dependencies | |
374 | ;; between (gnu packages linux) and this module. Additionally, memoize | |
375 | ;; the result to play well with further memoization and code that relies | |
376 | ;; on pointer identity; see <https://bugs.gnu.org/30155>. | |
377 | (package-with-bootstrap-guile | |
378 | (package (inherit linux-libre-headers) | |
379 | (arguments `(#:guile ,%bootstrap-guile | |
380 | #:implicit-inputs? #f | |
381 | ,@(package-arguments linux-libre-headers))) | |
382 | (native-inputs | |
383 | `(("perl" ,perl-boot0) | |
384 | ,@%boot0-inputs)))))) | |
bdb36958 | 385 | |
d75acc29 MR |
386 | (define gnumach-headers-boot0 |
387 | (package-with-bootstrap-guile | |
388 | (package-with-explicit-inputs gnumach-headers | |
389 | %boot0-inputs | |
390 | (current-source-location) | |
391 | #:guile %bootstrap-guile))) | |
392 | ||
393 | (define mig-boot0 | |
394 | (let* ((mig (package (inherit mig) | |
395 | (native-inputs `(("bison" ,bison-boot0) | |
396 | ("flex" ,flex-boot0))) | |
397 | (inputs `(("flex" ,flex-boot0))) | |
398 | (arguments | |
399 | `(#:configure-flags | |
400 | `(,(string-append "LDFLAGS=-Wl,-rpath=" | |
401 | (assoc-ref %build-inputs "flex") "/lib/"))))))) | |
402 | (package-with-bootstrap-guile | |
403 | (package-with-explicit-inputs mig %boot0-inputs | |
404 | (current-source-location) | |
405 | #:guile %bootstrap-guile)))) | |
406 | ||
407 | (define hurd-headers-boot0 | |
408 | (let ((hurd-headers (package (inherit hurd-headers) | |
409 | (native-inputs `(("mig" ,mig-boot0))) | |
410 | (inputs '())))) | |
411 | (package-with-bootstrap-guile | |
412 | (package-with-explicit-inputs hurd-headers %boot0-inputs | |
413 | (current-source-location) | |
414 | #:guile %bootstrap-guile)))) | |
415 | ||
416 | (define hurd-minimal-boot0 | |
417 | (let ((hurd-minimal (package (inherit hurd-minimal) | |
418 | (native-inputs `(("mig" ,mig-boot0))) | |
419 | (inputs '())))) | |
420 | (package-with-bootstrap-guile | |
421 | (package-with-explicit-inputs hurd-minimal %boot0-inputs | |
422 | (current-source-location) | |
423 | #:guile %bootstrap-guile)))) | |
424 | ||
8102cf0b LC |
425 | (define hurd-core-headers-boot0 |
426 | (mlambda () | |
427 | "Return the Hurd and Mach headers as well as initial Hurd libraries for | |
d75acc29 | 428 | the bootstrap environment." |
8102cf0b LC |
429 | (package-with-bootstrap-guile |
430 | (package (inherit hurd-core-headers) | |
431 | (arguments `(#:guile ,%bootstrap-guile | |
432 | ,@(package-arguments hurd-core-headers))) | |
433 | (inputs | |
434 | `(("gnumach-headers" ,gnumach-headers-boot0) | |
435 | ("hurd-headers" ,hurd-headers-boot0) | |
436 | ("hurd-minimal" ,hurd-minimal-boot0) | |
437 | ,@%boot0-inputs)))))) | |
d75acc29 MR |
438 | |
439 | (define* (kernel-headers-boot0 #:optional (system (%current-system))) | |
440 | (match system | |
441 | ("i586-gnu" (hurd-core-headers-boot0)) | |
442 | (_ (linux-libre-headers-boot0)))) | |
443 | ||
bdb36958 LC |
444 | (define texinfo-boot0 |
445 | ;; Texinfo used to build libc's manual. | |
446 | ;; We build without ncurses because it fails to build at this stage, and | |
447 | ;; because we don't need the stand-alone Info reader. | |
448 | ;; Also, use %BOOT0-INPUTS to avoid building Perl once more. | |
449 | (let ((texinfo (package (inherit texinfo) | |
47ed8e04 | 450 | (native-inputs '()) |
5d6c4d37 LC |
451 | (inputs `(("perl" ,perl-boot0))) |
452 | ||
453 | ;; Some of Texinfo 6.1's tests would fail with "Couldn't | |
454 | ;; set UTF-8 character type in locale" but we don't have a | |
455 | ;; UTF-8 locale at this stage, so skip them. | |
456 | (arguments '(#:tests? #f))))) | |
bdb36958 LC |
457 | (package-with-bootstrap-guile |
458 | (package-with-explicit-inputs texinfo %boot0-inputs | |
459 | (current-source-location) | |
460 | #:guile %bootstrap-guile)))) | |
461 | ||
d75acc29 MR |
462 | (define ld-wrapper-boot0 |
463 | ;; We need this so binaries on Hurd will have libmachuser and libhurduser | |
464 | ;; in their RUNPATH, otherwise validate-runpath will fail. | |
168c4000 LC |
465 | (make-ld-wrapper "ld-wrapper-boot0" |
466 | #:target boot-triplet | |
d75acc29 MR |
467 | #:binutils binutils-boot0 |
468 | #:guile %bootstrap-guile | |
469 | #:bash (car (assoc-ref %boot0-inputs "bash")))) | |
470 | ||
bdb36958 LC |
471 | (define %boot1-inputs |
472 | ;; 2nd stage inputs. | |
473 | `(("gcc" ,gcc-boot0) | |
d75acc29 | 474 | ("ld-wrapper-cross" ,ld-wrapper-boot0) |
bdb36958 | 475 | ("binutils-cross" ,binutils-boot0) |
f8badf15 | 476 | ,@(alist-delete "binutils" %boot0-inputs))) |
bdb36958 LC |
477 | |
478 | (define glibc-final-with-bootstrap-bash | |
479 | ;; The final libc, "cross-built". If everything went well, the resulting | |
480 | ;; store path has no dependencies. Actually, the really-final libc is | |
481 | ;; built just below; the only difference is that this one uses the | |
482 | ;; bootstrap Bash. | |
483 | (package-with-bootstrap-guile | |
848f550f | 484 | (package (inherit glibc) |
bdb36958 LC |
485 | (name "glibc-intermediate") |
486 | (arguments | |
487 | `(#:guile ,%bootstrap-guile | |
488 | #:implicit-inputs? #f | |
489 | ||
490 | ,@(substitute-keyword-arguments (package-arguments glibc) | |
491 | ((#:configure-flags flags) | |
492 | `(append (list ,(string-append "--host=" (boot-triplet)) | |
493 | ,(string-append "--build=" | |
494 | (nix-system->gnu-triplet)) | |
495 | ||
496 | ;; Build Sun/ONC RPC support. In particular, | |
497 | ;; install rpc/*.h. | |
498 | "--enable-obsolete-rpc") | |
499 | ,flags)) | |
500 | ((#:phases phases) | |
53bfec7b TGR |
501 | `(modify-phases ,phases |
502 | (add-before 'configure 'pre-configure | |
503 | (lambda* (#:key inputs #:allow-other-keys) | |
504 | ;; Don't clobber CPATH with the bootstrap libc. | |
505 | (setenv "NATIVE_CPATH" (getenv "CPATH")) | |
506 | (unsetenv "CPATH") | |
507 | ||
508 | ;; Tell 'libpthread' where to find 'libihash' on Hurd systems. | |
509 | ,@(if (hurd-triplet? (%current-system)) | |
510 | `((substitute* "libpthread/Makefile" | |
511 | (("LDLIBS-pthread.so =.*") | |
512 | (string-append "LDLIBS-pthread.so = " | |
513 | (assoc-ref %build-inputs "kernel-headers") | |
514 | "/lib/libihash.a\n")))) | |
515 | '()) | |
516 | ||
517 | ;; 'rpcgen' needs native libc headers to be built. | |
518 | (substitute* "sunrpc/Makefile" | |
519 | (("sunrpc-CPPFLAGS =.*" all) | |
520 | (string-append "CPATH = $(NATIVE_CPATH)\n" | |
521 | "export CPATH\n" | |
522 | all "\n"))) | |
523 | #t))))))) | |
d75acc29 | 524 | (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0)))) |
bdb36958 | 525 | (native-inputs |
5e8cb5e6 MB |
526 | `(("bison" ,bison-boot0) |
527 | ("texinfo" ,texinfo-boot0) | |
ff647c3d | 528 | ("perl" ,perl-boot0))) |
bdb36958 LC |
529 | (inputs |
530 | `(;; The boot inputs. That includes the bootstrap libc. We don't want | |
531 | ;; it in $CPATH, hence the 'pre-configure' phase above. | |
532 | ,@%boot1-inputs | |
533 | ||
d75acc29 | 534 | ;; A native MiG is needed to build Glibc on Hurd. |
62596a15 | 535 | ,@(if (hurd-triplet? (%current-system)) |
d75acc29 MR |
536 | `(("mig" ,mig-boot0)) |
537 | '()) | |
538 | ||
bdb36958 LC |
539 | ;; A native GCC is needed to build `cross-rpcgen'. |
540 | ("native-gcc" ,@(assoc-ref %boot0-inputs "gcc")) | |
541 | ||
542 | ;; Here, we use the bootstrap Bash, which is not satisfactory | |
543 | ;; because we don't want to depend on bootstrap tools. | |
544 | ("static-bash" ,@(assoc-ref %boot0-inputs "bash"))))))) | |
545 | ||
546 | (define (cross-gcc-wrapper gcc binutils glibc bash) | |
547 | "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC | |
548 | that makes it available under the native tool names." | |
c92f1c0a | 549 | (package (inherit gcc) |
bdb36958 LC |
550 | (name (string-append (package-name gcc) "-wrapped")) |
551 | (source #f) | |
552 | (build-system trivial-build-system) | |
553 | (outputs '("out")) | |
554 | (arguments | |
555 | `(#:guile ,%bootstrap-guile | |
556 | #:modules ((guix build utils)) | |
557 | #:builder (begin | |
558 | (use-modules (guix build utils)) | |
559 | ||
560 | (let* ((binutils (assoc-ref %build-inputs "binutils")) | |
561 | (gcc (assoc-ref %build-inputs "gcc")) | |
562 | (libc (assoc-ref %build-inputs "libc")) | |
563 | (bash (assoc-ref %build-inputs "bash")) | |
564 | (out (assoc-ref %outputs "out")) | |
565 | (bindir (string-append out "/bin")) | |
566 | (triplet ,(boot-triplet))) | |
567 | (define (wrap-program program) | |
568 | ;; GCC-BOOT0 is a libc-less cross-compiler, so it | |
569 | ;; needs to be told where to find the crt files and | |
570 | ;; the dynamic linker. | |
571 | (call-with-output-file program | |
572 | (lambda (p) | |
573 | (format p "#!~a/bin/bash | |
574 | exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%" | |
575 | bash | |
576 | gcc triplet program | |
577 | libc libc | |
578 | ,(glibc-dynamic-linker)))) | |
579 | ||
580 | (chmod program #o555)) | |
581 | ||
582 | (mkdir-p bindir) | |
583 | (with-directory-excursion bindir | |
584 | (for-each (lambda (tool) | |
585 | (symlink (string-append binutils "/bin/" | |
586 | triplet "-" tool) | |
587 | tool)) | |
588 | '("ar" "ranlib")) | |
e3cfef22 MW |
589 | (for-each wrap-program '("gcc" "g++"))) |
590 | ||
591 | #t)))) | |
bdb36958 LC |
592 | (native-inputs |
593 | `(("binutils" ,binutils) | |
594 | ("gcc" ,gcc) | |
595 | ("libc" ,glibc) | |
596 | ("bash" ,bash))) | |
597 | (inputs '()))) | |
598 | ||
599 | (define static-bash-for-glibc | |
90d891fc | 600 | ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co. |
bdb36958 LC |
601 | (let* ((gcc (cross-gcc-wrapper gcc-boot0 binutils-boot0 |
602 | glibc-final-with-bootstrap-bash | |
603 | (car (assoc-ref %boot1-inputs "bash")))) | |
6dff905e LC |
604 | (bash (package |
605 | (inherit static-bash) | |
bdb36958 | 606 | (arguments |
6dff905e LC |
607 | (substitute-keyword-arguments |
608 | (package-arguments static-bash) | |
609 | ((#:guile _ #f) | |
610 | '%bootstrap-guile) | |
611 | ((#:configure-flags flags '()) | |
612 | ;; Add a '-L' flag so that the pseudo-cross-ld of | |
613 | ;; BINUTILS-BOOT0 can find libc.a. | |
614 | `(append ,flags | |
615 | (list (string-append "LDFLAGS=-static -L" | |
616 | (assoc-ref %build-inputs | |
617 | "libc:static") | |
618 | "/lib")))))))) | |
32243bfb LC |
619 | (inputs `(("gcc" ,gcc) |
620 | ("libc" ,glibc-final-with-bootstrap-bash) | |
6dff905e | 621 | ("libc:static" ,glibc-final-with-bootstrap-bash "static") |
32243bfb LC |
622 | ,@(fold alist-delete %boot1-inputs |
623 | '("gcc" "libc"))))) | |
c573f5a5 LC |
624 | (package-with-bootstrap-guile |
625 | (package-with-explicit-inputs bash inputs | |
626 | (current-source-location) | |
627 | #:guile %bootstrap-guile)))) | |
bdb36958 | 628 | |
6162b95d LC |
629 | (define gettext-boot0 |
630 | ;; A minimal gettext used during bootstrap. | |
669b8639 | 631 | (let ((gettext-minimal |
b94a6ca0 | 632 | (package (inherit gettext-minimal) |
669b8639 LC |
633 | (name "gettext-boot0") |
634 | (inputs '()) ;zero dependencies | |
635 | (arguments | |
636 | (substitute-keyword-arguments | |
637 | `(#:tests? #f | |
b94a6ca0 | 638 | ,@(package-arguments gettext-minimal)) |
669b8639 LC |
639 | ((#:phases phases) |
640 | `(modify-phases ,phases | |
641 | ;; Build only the tools. | |
642 | (add-after 'unpack 'chdir | |
643 | (lambda _ | |
60ff6ec4 MW |
644 | (chdir "gettext-tools") |
645 | #t)) | |
669b8639 LC |
646 | |
647 | ;; Some test programs require pthreads, which we don't have. | |
648 | (add-before 'configure 'no-test-programs | |
649 | (lambda _ | |
650 | (substitute* "tests/Makefile.in" | |
651 | (("^PROGRAMS =.*$") | |
652 | "PROGRAMS =\n")) | |
653 | #t)) | |
654 | ||
655 | ;; Don't try to link against libexpat. | |
656 | (delete 'link-expat) | |
657 | (delete 'patch-tests)))))))) | |
6162b95d LC |
658 | (package-with-bootstrap-guile |
659 | (package-with-explicit-inputs gettext-minimal | |
660 | %boot1-inputs | |
661 | (current-source-location) | |
662 | #:guile %bootstrap-guile)))) | |
663 | ||
89223417 | 664 | (define glibc-final |
bdb36958 | 665 | ;; The final glibc, which embeds the statically-linked Bash built above. |
7c788ed2 LC |
666 | ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any. |
667 | (let ((glibc (package-with-bootstrap-guile glibc))) | |
668 | (package/inherit glibc | |
669 | (name "glibc") | |
670 | (inputs `(("static-bash" ,static-bash-for-glibc) | |
671 | ,@(alist-delete | |
672 | "static-bash" | |
673 | (package-inputs glibc-final-with-bootstrap-bash)))) | |
674 | ||
675 | ;; This time we need 'msgfmt' to install all the libc.mo files. | |
676 | (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash) | |
677 | ("gettext" ,gettext-boot0))) | |
678 | ||
679 | (propagated-inputs | |
680 | (package-propagated-inputs glibc-final-with-bootstrap-bash)) | |
681 | ||
682 | ;; The final libc only refers to itself, but the 'debug' output contains | |
683 | ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great | |
684 | ;; if 'allowed-references' were per-output. | |
685 | (arguments | |
686 | `(#:allowed-references | |
687 | ,(cons* `(,gcc-boot0 "lib") (kernel-headers-boot0) | |
688 | static-bash-for-glibc | |
689 | (package-outputs glibc-final-with-bootstrap-bash)) | |
bdb36958 | 690 | |
7c788ed2 | 691 | ,@(package-arguments glibc-final-with-bootstrap-bash)))))) |
bdb36958 LC |
692 | |
693 | (define gcc-boot0-wrapped | |
694 | ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the | |
695 | ;; non-cross names. | |
696 | (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final | |
697 | (car (assoc-ref %boot1-inputs "bash")))) | |
698 | ||
699 | (define %boot2-inputs | |
700 | ;; 3rd stage inputs. | |
701 | `(("libc" ,glibc-final) | |
6dff905e | 702 | ("libc:static" ,glibc-final "static") |
bdb36958 LC |
703 | ("gcc" ,gcc-boot0-wrapped) |
704 | ,@(fold alist-delete %boot1-inputs '("libc" "gcc")))) | |
705 | ||
706 | (define binutils-final | |
707 | (package-with-bootstrap-guile | |
45953b1f | 708 | (package (inherit binutils) |
bdb36958 LC |
709 | (arguments |
710 | `(#:guile ,%bootstrap-guile | |
711 | #:implicit-inputs? #f | |
712 | #:allowed-references ("out" ,glibc-final) | |
713 | ,@(package-arguments binutils))) | |
714 | (inputs %boot2-inputs)))) | |
715 | ||
716 | (define libstdc++ | |
717 | ;; Intermediate libstdc++ that will allow us to build the final GCC | |
718 | ;; (remember that GCC-BOOT0 cannot build libstdc++.) | |
86d02fa8 EF |
719 | (let ((lib (package-with-bootstrap-guile (make-libstdc++ gcc)))) |
720 | (package | |
721 | (inherit lib) | |
722 | (arguments | |
723 | `(#:guile ,%bootstrap-guile | |
724 | #:implicit-inputs? #f | |
725 | #:allowed-references ("out") | |
726 | ||
727 | ;; XXX: libstdc++.so NEEDs ld.so for some reason. | |
728 | #:validate-runpath? #f | |
729 | ||
730 | ;; All of the package arguments from 'make-libstdc++ | |
731 | ;; except for the configure-flags. | |
732 | ,@(package-arguments lib) | |
733 | #:configure-flags `("--disable-shared" | |
734 | "--disable-libstdcxx-threads" | |
735 | "--disable-libstdcxx-pch" | |
736 | ,(string-append "--with-gxx-include-dir=" | |
737 | (assoc-ref %outputs "out") | |
738 | "/include")))) | |
739 | (outputs '("out")) | |
740 | (inputs %boot2-inputs) | |
741 | (synopsis "GNU C++ standard library (intermediate)")))) | |
bdb36958 | 742 | |
98bd851e LC |
743 | (define zlib-final |
744 | ;; Zlib used by GCC-FINAL. | |
745 | (package-with-bootstrap-guile | |
746 | (package | |
747 | (inherit zlib) | |
748 | (arguments | |
749 | `(#:guile ,%bootstrap-guile | |
750 | #:implicit-inputs? #f | |
751 | #:allowed-references ("out" ,glibc-final) | |
752 | ,@(package-arguments zlib))) | |
753 | (inputs %boot2-inputs)))) | |
754 | ||
755 | (define ld-wrapper-boot3 | |
756 | ;; A linker wrapper that uses the bootstrap Guile. | |
757 | (make-ld-wrapper "ld-wrapper-boot3" | |
758 | #:binutils binutils-final | |
759 | #:guile %bootstrap-guile | |
760 | #:bash (car (assoc-ref %boot2-inputs "bash")))) | |
761 | ||
89223417 | 762 | (define gcc-final |
bdb36958 LC |
763 | ;; The final GCC. |
764 | (package (inherit gcc-boot0) | |
765 | (name "gcc") | |
ab999c25 LC |
766 | |
767 | ;; XXX: Currently #:allowed-references applies to all the outputs but the | |
768 | ;; "debug" output contains disallowed references, notably | |
769 | ;; linux-libre-headers. Disable the debugging output to work around that. | |
770 | (outputs (delete "debug" (package-outputs gcc-boot0))) | |
771 | ||
bdb36958 LC |
772 | (arguments |
773 | `(#:guile ,%bootstrap-guile | |
774 | #:implicit-inputs? #f | |
775 | ||
98bd851e | 776 | #:allowed-references ("out" "lib" ,zlib-final |
90d891fc | 777 | ,glibc-final ,static-bash-for-glibc) |
bdb36958 | 778 | |
d485ebba LC |
779 | ;; Things like libasan.so and libstdc++.so NEED ld.so for some |
780 | ;; reason, but it is not in their RUNPATH. This is a false | |
781 | ;; positive, so turn it off. | |
782 | #:validate-runpath? #f | |
783 | ||
bdb36958 LC |
784 | ;; Build again GMP & co. within GCC's build process, because it's hard |
785 | ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus | |
786 | ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.) | |
787 | ,@(substitute-keyword-arguments (package-arguments gcc-boot0) | |
788 | ((#:configure-flags boot-flags) | |
c92f1c0a | 789 | (let loop ((args (package-arguments gcc))) |
bdb36958 LC |
790 | (match args |
791 | ((#:configure-flags normal-flags _ ...) | |
792 | normal-flags) | |
793 | ((_ rest ...) | |
794 | (loop rest))))) | |
795 | ((#:make-flags flags) | |
52cfd8cb | 796 | ;; Since $LIBRARY_PATH is not honored, add the relevant flags. |
98bd851e LC |
797 | `(let ((zlib (assoc-ref %build-inputs "zlib"))) |
798 | (map (lambda (flag) | |
799 | (if (string-prefix? "LDFLAGS=" flag) | |
800 | (string-append flag " -L" | |
801 | (assoc-ref %build-inputs "libstdc++") | |
802 | "/lib -L" zlib "/lib -Wl,-rpath=" | |
803 | zlib "/lib") | |
804 | flag)) | |
805 | ,flags))) | |
bdb36958 LC |
806 | ((#:phases phases) |
807 | `(alist-delete 'symlink-libgcc_eh ,phases))))) | |
808 | ||
90d891fc LC |
809 | ;; This time we want Texinfo, so we get the manual. Add |
810 | ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of | |
811 | ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these | |
812 | ;; scripts?). | |
bdb36958 | 813 | (native-inputs `(("texinfo" ,texinfo-boot0) |
19d27131 | 814 | ("perl" ,perl-boot0) ;for manpages |
90d891fc | 815 | ("static-bash" ,static-bash-for-glibc) |
bdb36958 LC |
816 | ,@(package-native-inputs gcc-boot0))) |
817 | ||
8309c389 | 818 | (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0))) |
bdb36958 LC |
819 | ("mpfr-source" ,(package-source mpfr)) |
820 | ("mpc-source" ,(package-source mpc)) | |
98bd851e | 821 | ("ld-wrapper" ,ld-wrapper-boot3) |
bdb36958 LC |
822 | ("binutils" ,binutils-final) |
823 | ("libstdc++" ,libstdc++) | |
98bd851e | 824 | ("zlib" ,zlib-final) |
bdb36958 LC |
825 | ,@%boot2-inputs)))) |
826 | ||
bdb36958 LC |
827 | (define %boot3-inputs |
828 | ;; 4th stage inputs. | |
829 | `(("gcc" ,gcc-final) | |
830 | ("ld-wrapper" ,ld-wrapper-boot3) | |
831 | ,@(alist-delete "gcc" %boot2-inputs))) | |
832 | ||
833 | (define bash-final | |
834 | ;; Link with `-static-libgcc' to make sure we don't retain a reference | |
704243e0 LC |
835 | ;; to the bootstrap GCC. Use "bash-minimal" to avoid an extra dependency |
836 | ;; on Readline and ncurses. | |
d9b4cbc2 | 837 | (let ((bash (package |
704243e0 | 838 | (inherit bash-minimal) |
d9b4cbc2 LC |
839 | (arguments |
840 | `(#:disallowed-references | |
841 | ,(assoc-ref %boot3-inputs "coreutils&co") | |
704243e0 | 842 | ,@(package-arguments bash-minimal)))))) |
d9b4cbc2 LC |
843 | (package-with-bootstrap-guile |
844 | (package-with-explicit-inputs (static-libgcc-package bash) | |
845 | %boot3-inputs | |
846 | (current-source-location) | |
847 | #:guile %bootstrap-guile)))) | |
bdb36958 LC |
848 | |
849 | (define %boot4-inputs | |
850 | ;; Now use the final Bash. | |
851 | `(("bash" ,bash-final) | |
852 | ,@(alist-delete "bash" %boot3-inputs))) | |
853 | ||
854 | (define-public guile-final | |
386b71d1 LC |
855 | ;; This package must be public because other modules refer to it. However, |
856 | ;; mark it as hidden so that 'fold-packages' ignores it. | |
bdb36958 | 857 | (package-with-bootstrap-guile |
34d624ce | 858 | (package-with-explicit-inputs (hidden-package guile-2.2/fixed) |
bdb36958 LC |
859 | %boot4-inputs |
860 | (current-source-location) | |
861 | #:guile %bootstrap-guile))) | |
862 | ||
89223417 | 863 | (define glibc-utf8-locales-final |
87c8b92f LC |
864 | ;; Now that we have GUILE-FINAL, build the UTF-8 locales. They are needed |
865 | ;; by the build processes afterwards so their 'scm_to_locale_string' works | |
866 | ;; with the full range of Unicode codepoints (remember | |
867 | ;; 'scm_to_locale_string' is called every time a string is passed to a C | |
868 | ;; function.) | |
869 | (package | |
870 | (inherit glibc-utf8-locales) | |
871 | (inputs `(("glibc" ,glibc-final) | |
872 | ("gzip" | |
873 | ,(package-with-explicit-inputs gzip %boot4-inputs | |
874 | (current-source-location) | |
875 | #:guile %bootstrap-guile)))))) | |
876 | ||
28cbc587 LC |
877 | (define-public ld-wrapper |
878 | ;; The final 'ld' wrapper, which uses the final Guile and Binutils. | |
78dea6f1 LC |
879 | (make-ld-wrapper "ld-wrapper" |
880 | #:binutils binutils-final | |
881 | #:guile guile-final | |
882 | #:bash bash-final)) | |
28cbc587 | 883 | |
87c8b92f | 884 | (define %boot5-inputs |
b6ac5451 LC |
885 | ;; Now with UTF-8 locales. Remember that the bootstrap binaries were built |
886 | ;; with an older libc, which cannot load the new locale format. See | |
28cbc587 | 887 | ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>. |
b6ac5451 LC |
888 | `(("locales" ,glibc-utf8-locales-final) |
889 | ,@%boot4-inputs)) | |
87c8b92f | 890 | |
bdb36958 LC |
891 | (define gnu-make-final |
892 | ;; The final GNU Make, which uses the final Guile. | |
893 | (package-with-bootstrap-guile | |
894 | (package-with-explicit-inputs gnu-make | |
895 | `(("guile" ,guile-final) | |
87c8b92f | 896 | ,@%boot5-inputs) |
bdb36958 LC |
897 | (current-source-location)))) |
898 | ||
bdb36958 LC |
899 | (define coreutils-final |
900 | ;; The final Coreutils. Treat them specially because some packages, such as | |
901 | ;; Findutils, keep a reference to the Coreutils they were built with. | |
902 | (package-with-bootstrap-guile | |
903 | (package-with-explicit-inputs coreutils | |
87c8b92f | 904 | %boot5-inputs |
bdb36958 LC |
905 | (current-source-location) |
906 | ||
907 | ;; Use the final Guile, linked against the | |
908 | ;; final libc with working iconv, so that | |
909 | ;; 'substitute*' works well when touching | |
910 | ;; test files in Gettext. | |
911 | #:guile guile-final))) | |
912 | ||
913 | (define grep-final | |
914 | ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be | |
915 | ;; built before gzip. | |
78ca500a LC |
916 | (let ((grep (package-with-bootstrap-guile |
917 | (package-with-explicit-inputs grep %boot5-inputs | |
918 | (current-source-location) | |
919 | #:guile guile-final)))) | |
920 | (package/inherit grep | |
921 | (inputs (alist-delete "pcre" (package-inputs grep))) | |
922 | (native-inputs `(("perl" ,perl-boot0)))))) | |
bdb36958 | 923 | |
87c8b92f | 924 | (define %boot6-inputs |
bdb36958 LC |
925 | ;; Now use the final Coreutils. |
926 | `(("coreutils" ,coreutils-final) | |
927 | ("grep" ,grep-final) | |
87c8b92f | 928 | ,@%boot5-inputs)) |
b0fd2bd3 | 929 | |
301a4249 LC |
930 | (define sed-final |
931 | ;; The final sed. | |
932 | (let ((sed (package-with-bootstrap-guile | |
933 | (package-with-explicit-inputs sed %boot6-inputs | |
934 | (current-source-location) | |
935 | #:guile guile-final)))) | |
936 | (package/inherit sed (native-inputs `(("perl" ,perl-boot0)))))) | |
937 | ||
bdb36958 LC |
938 | (define-public %final-inputs |
939 | ;; Final derivations used as implicit inputs by 'gnu-build-system'. We | |
940 | ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are | |
941 | ;; used for origins that have patches, thereby avoiding circular | |
942 | ;; dependencies. | |
943 | (let ((finalize (compose package-with-bootstrap-guile | |
87c8b92f | 944 | (cut package-with-explicit-inputs <> %boot6-inputs |
bdb36958 LC |
945 | (current-source-location))))) |
946 | `(,@(map (match-lambda | |
947 | ((name package) | |
948 | (list name (finalize package)))) | |
949 | `(("tar" ,tar) | |
87c8b92f | 950 | ("gzip" ,gzip) |
bdb36958 LC |
951 | ("bzip2" ,bzip2) |
952 | ("xz" ,xz) | |
c00a9fbf | 953 | ("file" ,file) |
bdb36958 LC |
954 | ("diffutils" ,diffutils) |
955 | ("patch" ,patch) | |
bdb36958 LC |
956 | ("findutils" ,findutils) |
957 | ("gawk" ,gawk))) | |
301a4249 | 958 | ("sed" ,sed-final) |
bdb36958 LC |
959 | ("grep" ,grep-final) |
960 | ("coreutils" ,coreutils-final) | |
961 | ("make" ,gnu-make-final) | |
962 | ("bash" ,bash-final) | |
963 | ("ld-wrapper" ,ld-wrapper) | |
964 | ("binutils" ,binutils-final) | |
965 | ("gcc" ,gcc-final) | |
b0fd2bd3 | 966 | ("libc" ,glibc-final) |
6dff905e | 967 | ("libc:static" ,glibc-final "static") |
b0fd2bd3 | 968 | ("locales" ,glibc-utf8-locales-final)))) |
bdb36958 LC |
969 | |
970 | (define-public canonical-package | |
971 | (let ((name->package (fold (lambda (input result) | |
972 | (match input | |
6dff905e | 973 | ((_ package . outputs) |
bdb36958 LC |
974 | (vhash-cons (package-full-name package) |
975 | package result)))) | |
976 | vlist-null | |
977 | `(("guile" ,guile-final) | |
978 | ,@%final-inputs)))) | |
979 | (lambda (package) | |
980 | "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of | |
981 | the implicit inputs of 'gnu-build-system', return that one, otherwise return | |
982 | PACKAGE. | |
983 | ||
34d624ce | 984 | The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2, |
bdb36958 LC |
985 | COREUTILS-FINAL vs. COREUTILS, etc." |
986 | ;; XXX: This doesn't handle dependencies of the final inputs, such as | |
987 | ;; libunistring, GMP, etc. | |
988 | (match (vhash-assoc (package-full-name package) name->package) | |
989 | ((_ . canon) | |
990 | ;; In general we want CANON, except if we're cross-compiling: CANON | |
991 | ;; uses explicit inputs, so it is "anchored" in the bootstrapped | |
992 | ;; process, with dependencies on things that cannot be | |
993 | ;; cross-compiled. | |
994 | (if (%current-target-system) | |
995 | package | |
996 | canon)) | |
997 | (_ package))))) | |
998 | ||
999 | \f | |
1000 | ;;; | |
1001 | ;;; GCC toolchain. | |
1002 | ;;; | |
1003 | ||
b887ede1 | 1004 | (define (make-gcc-toolchain gcc) |
bdb36958 LC |
1005 | "Return a complete toolchain for GCC." |
1006 | (package | |
1007 | (name "gcc-toolchain") | |
1008 | (version (package-version gcc)) | |
1009 | (source #f) | |
1010 | (build-system trivial-build-system) | |
1011 | (arguments | |
1012 | '(#:modules ((guix build union)) | |
1013 | #:builder (begin | |
1014 | (use-modules (ice-9 match) | |
6f450b87 | 1015 | (srfi srfi-26) |
bdb36958 LC |
1016 | (guix build union)) |
1017 | ||
6f450b87 | 1018 | (let ((out (assoc-ref %outputs "out"))) |
bdb36958 | 1019 | |
6f450b87 LC |
1020 | (match %build-inputs |
1021 | (((names . directories) ...) | |
1022 | (union-build out directories))) | |
1023 | ||
6f450b87 LC |
1024 | (union-build (assoc-ref %outputs "debug") |
1025 | (list (assoc-ref %build-inputs | |
e3cfef22 | 1026 | "libc-debug"))) |
5a48a066 LC |
1027 | (union-build (assoc-ref %outputs "static") |
1028 | (list (assoc-ref %build-inputs | |
3d5ad159 | 1029 | "libc-static"))) |
e3cfef22 | 1030 | #t)))) |
d474d5d0 LC |
1031 | |
1032 | (native-search-paths (package-native-search-paths gcc)) | |
1033 | (search-paths (package-search-paths gcc)) | |
1034 | ||
bdb36958 LC |
1035 | (license (package-license gcc)) |
1036 | (synopsis "Complete GCC tool chain for C/C++ development") | |
1037 | (description | |
1038 | "This package provides a complete GCC tool chain for C/C++ development to | |
1039 | be installed in user profiles. This includes GCC, as well as libc (headers | |
1040 | and binaries, plus debugging symbols in the 'debug' output), and Binutils.") | |
6fd52309 | 1041 | (home-page "https://gcc.gnu.org/") |
5a48a066 | 1042 | (outputs '("out" "debug" "static")) |
bdb36958 LC |
1043 | |
1044 | ;; The main raison d'être of this "meta-package" is (1) to conveniently | |
1045 | ;; install everything that we need, and (2) to make sure ld-wrapper comes | |
1046 | ;; before Binutils' ld in the user's profile. | |
1047 | (inputs `(("gcc" ,gcc) | |
cbbb11c8 | 1048 | ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper"))) |
bdb36958 LC |
1049 | ("binutils" ,binutils-final) |
1050 | ("libc" ,glibc-final) | |
5a48a066 LC |
1051 | ("libc-debug" ,glibc-final "debug") |
1052 | ("libc-static" ,glibc-final "static"))))) | |
bdb36958 LC |
1053 | |
1054 | (define-public gcc-toolchain-4.8 | |
b887ede1 | 1055 | (make-gcc-toolchain gcc-4.8)) |
bdb36958 LC |
1056 | |
1057 | (define-public gcc-toolchain-4.9 | |
b887ede1 LC |
1058 | (make-gcc-toolchain gcc-4.9)) |
1059 | ||
1060 | (define-public gcc-toolchain | |
1061 | (make-gcc-toolchain gcc-final)) | |
bdb36958 | 1062 | |
629f4d2e | 1063 | (define-public gcc-toolchain-5 |
b887ede1 | 1064 | gcc-toolchain) |
60e2d5fe | 1065 | |
e760ec41 | 1066 | (define-public gcc-toolchain-6 |
b887ede1 | 1067 | (make-gcc-toolchain gcc-6)) |
e760ec41 | 1068 | |
d7ecab74 | 1069 | (define-public gcc-toolchain-7 |
b887ede1 | 1070 | (make-gcc-toolchain gcc-7)) |
d7ecab74 | 1071 | |
bdb36958 | 1072 | ;;; commencement.scm ends here |