gnu: emacs-svg-icon: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / cross-base.scm
CommitLineData
827d2891 1;;; GNU Guix --- Functional package management for GNU
89da1270 2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
1e5005e2 3;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
308eb5c1 4;;; Copyright © 2016, 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
2d558e31 5;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
273cab96 6;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
a493a526 7;;; Copyright © 2019, 2020 Marius Bakke <mbakke@fastmail.com>
67dac6b8 8;;; Copyright © 2019 Carl Dong <contact@carldong.me>
53de3e74 9;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
827d2891
LC
10;;;
11;;; This file is part of GNU Guix.
12;;;
13;;; GNU Guix is free software; you can redistribute it and/or modify it
14;;; under the terms of the GNU General Public License as published by
15;;; the Free Software Foundation; either version 3 of the License, or (at
16;;; your option) any later version.
17;;;
18;;; GNU Guix is distributed in the hope that it will be useful, but
19;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;;; GNU General Public License for more details.
22;;;
23;;; You should have received a copy of the GNU General Public License
24;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26(define-module (gnu packages cross-base)
827d2891 27 #:use-module (gnu packages)
f594028a 28 #:use-module (gnu packages gcc)
827d2891
LC
29 #:use-module (gnu packages base)
30 #:use-module (gnu packages linux)
2d558e31 31 #:use-module (gnu packages hurd)
cba36e64 32 #:use-module (gnu packages mingw)
827d2891
LC
33 #:use-module (guix packages)
34 #:use-module (guix download)
35 #:use-module (guix utils)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system trivial)
38 #:use-module (srfi srfi-1)
39 #:use-module (srfi srfi-26)
264218a4 40 #:use-module (ice-9 match)
2d558e31 41 #:use-module (ice-9 regex)
264218a4
LC
42 #:export (cross-binutils
43 cross-libc
cba36e64 44 cross-gcc
2ea77d48
CD
45 cross-newlib?
46 cross-kernel-headers))
827d2891 47
be99170d 48(define-syntax %xgcc
c92f1c0a
LC
49 ;; GCC package used as the basis for cross-compilation. It doesn't have to
50 ;; be 'gcc' and can be a specific variant such as 'gcc-4.8'.
be99170d
LC
51 ;;
52 ;; Note: This is a macro so that we do not refer to 'gcc' from the top
53 ;; level, which would lead to circular-dependency issues.
54 (identifier-syntax gcc))
c92f1c0a 55
cba36e64
JN
56(define %gcc-include-paths
57 ;; Environment variables for header search paths.
89da1270
LC
58 ;; Note: See <http://bugs.gnu.org/22186> for why not 'CPATH'.
59 '("C_INCLUDE_PATH"
60 "CPLUS_INCLUDE_PATH"
61 "OBJC_INCLUDE_PATH"
62 "OBJCPLUS_INCLUDE_PATH"))
cba36e64
JN
63
64(define %gcc-cross-include-paths
65 ;; Search path for target headers when cross-compiling.
66 (map (cut string-append "CROSS_" <>) %gcc-include-paths))
67
827d2891
LC
68(define (cross p target)
69 (package (inherit p)
827d2891
LC
70 (name (string-append (package-name p) "-cross-" target))
71 (arguments
72 (substitute-keyword-arguments (package-arguments p)
73 ((#:configure-flags flags)
74 `(cons ,(string-append "--target=" target)
75 ,flags))))))
76
a493a526
MB
77(define* (cross-binutils target #:optional (binutils binutils))
78 "Return a cross-Binutils for TARGET using BINUTILS."
47e74d6e
LC
79 (let ((binutils (package (inherit binutils)
80 (arguments
81 (substitute-keyword-arguments (package-arguments
82 binutils)
83 ((#:configure-flags flags)
84 ;; Build with `--with-sysroot' so that ld honors
85 ;; DT_RUNPATH entries when searching for a needed
86 ;; library. This works because as a side effect
87 ;; `genscripts.sh' sets `USE_LIBPATH=yes', which tells
88 ;; elf32.em to use DT_RUNPATH in its search list.
c8fa51f2
LC
89 ;; See <http://sourceware.org/ml/binutils/2013-05/msg00312.html>.
90 ;;
91 ;; In theory choosing / as the sysroot could lead ld
92 ;; to pick up native libs instead of target ones. In
93 ;; practice the RUNPATH of target libs only refers to
94 ;; target libs, not native libs, so this is safe.
95 `(cons "--with-sysroot=/" ,flags)))))))
1306b0b0
LC
96
97 ;; For Xtensa, apply Qualcomm's patch.
79825bee 98 (cross (cond ((string-prefix? "xtensa-" target)
b256d136
LC
99 (package-with-patches binutils
100 (search-patches
101 "ath9k-htc-firmware-binutils.patch")))
79825bee
CD
102 ((target-mingw? target)
103 (package-with-extra-patches
104 binutils
523280e0
LC
105 (search-patches "binutils-mingw-w64-timestamp.patch"
106 "binutils-mingw-w64-deterministic.patch")))
79825bee 107 (else binutils))
1306b0b0 108 target)))
827d2891 109
7b3318e3
RW
110(define (cross-gcc-arguments target xgcc libc)
111 "Return build system arguments for a cross-gcc for TARGET, using XGCC as the
112base compiler and using LIBC (which may be either a libc package or #f.)"
b4469d8c
LC
113 ;; Set the current target system so that 'glibc-dynamic-linker' returns the
114 ;; right name.
115 (parameterize ((%current-target-system target))
2a1552c6
LC
116 ;; Disable stripping as this can break binaries, with object files of
117 ;; libgcc.a showing up as having an unknown architecture. See
118 ;; <http://lists.fedoraproject.org/pipermail/arm/2010-August/000663.html>
119 ;; for instance.
120 (let ((args `(#:strip-binaries? #f
7b3318e3 121 ,@(package-arguments xgcc))))
2a1552c6
LC
122 (substitute-keyword-arguments args
123 ((#:configure-flags flags)
124 `(append (list ,(string-append "--target=" target)
125 ,@(if libc
8fd857f5 126 `( ;; Disable libcilkrts because it is not
3009a9e4 127 ;; ported to GNU/Hurd.
871dbd6c
MB
128 "--disable-libcilkrts"
129 ;; When building a cross compiler, --with-sysroot is
130 ;; implicitly set to "$gcc_tooldir/sys-root". This does
131 ;; not work for us, because --with-native-system-header-dir
132 ;; is searched for relative to this location. Thus, we set
133 ;; it to "/" so GCC is able to find the target libc headers.
134 ;; This is safe because in practice GCC uses CROSS_CPATH
135 ;; & co to separate target and host libraries.
136 "--with-sysroot=/")
2a1552c6
LC
137 `( ;; Disable features not needed at this stage.
138 "--disable-shared" "--enable-static"
ca7ef4d4 139 "--enable-languages=c,c++"
cdb4b4b3 140
ca7ef4d4
RW
141 ;; libstdc++ cannot be built at this stage
142 ;; ("Link tests are not allowed after
143 ;; GCC_NO_EXECUTABLES.").
144 "--disable-libstdc++-v3"
cdb4b4b3 145
2a1552c6
LC
146 "--disable-threads" ;libgcc, would need libc
147 "--disable-libatomic"
148 "--disable-libmudflap"
149 "--disable-libgomp"
43124a54 150 "--disable-libmpx"
2a1552c6
LC
151 "--disable-libssp"
152 "--disable-libquadmath"
153 "--disable-decimal-float" ;would need libc
8fd857f5 154 "--disable-libcilkrts"
9a745d76 155
58452d08 156 ,@(if (string-prefix? "powerpc64le-" target)
4a914de9 157 ;; On POWER9 (little endian) glibc needs
158 ;; the 128-bit long double type.
159 '("--with-long-double-128")
160 '())
161
9a745d76
MR
162 ;; When target is any OS other than 'none' these
163 ;; libraries will fail if there is no libc
164 ;; present. See
165 ;; <https://lists.gnu.org/archive/html/guix-devel/2016-02/msg01311.html>
166 "--disable-libitm"
167 "--disable-libvtv"
168 "--disable-libsanitizer"
cba36e64
JN
169 ))
170
53de3e74
MO
171 ;; Install cross-built libraries such as libgcc_s.so in
172 ;; the "lib" output.
173 ,@(if libc
174 `((string-append "--with-toolexeclibdir="
175 (assoc-ref %outputs "lib")
176 "/" ,target "/lib"))
177 '())
cba36e64
JN
178 ;; For a newlib (non-glibc) target
179 ,@(if (cross-newlib? target)
180 '("--with-newlib")
181 '()))
cdb4b4b3 182
2a1552c6
LC
183 ,(if libc
184 flags
185 `(remove (cut string-match "--enable-languages.*" <>)
186 ,flags))))
187 ((#:make-flags flags)
188 (if libc
189 `(let ((libc (assoc-ref %build-inputs "libc")))
190 ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
191 ;; the -Bxxx for the startfiles.
192 (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
193 ,flags))
194 flags))
195 ((#:phases phases)
89da1270 196 `(cross-gcc-build-phases ,target ,phases))))))
cdb4b4b3 197
308eb5c1
JN
198(define (cross-gcc-patches xgcc target)
199 "Return GCC patches needed for XGCC and TARGET."
1306b0b0
LC
200 (cond ((string-prefix? "xtensa-" target)
201 ;; Patch by Qualcomm needed to build the ath9k-htc firmware.
fc1adab1 202 (search-patches "ath9k-htc-firmware-gcc.patch"))
cba36e64 203 ((target-mingw? target)
308eb5c1
JN
204 (append (search-patches "gcc-4.9.3-mingw-gthr-default.patch")
205 (if (version>=? (package-version xgcc) "7.0")
206 (search-patches "gcc-7-cross-mingw.patch")
207 '())))
1306b0b0
LC
208 (else '())))
209
cba36e64
JN
210(define (cross-gcc-snippet target)
211 "Return GCC snippet needed for TARGET."
53de3e74
MO
212 `(begin
213 ,@(if (target-mingw? target)
214 '((copy-recursively "libstdc++-v3/config/os/mingw32-w64"
215 "libstdc++-v3/config/os/newlib"))
216 '())
217 ;; TOOLDIR_BASE_PREFIX is erroneous when using a separate "lib"
218 ;; output. Specify it correctly, otherwise GCC won't find its shared
219 ;; libraries installed in the "lib" output. See:
220 ;; https://lists.gnu.org/archive/html/bug-guix/2020-03/msg00196.html.
221 (substitute* "gcc/Makefile.in"
222 (("-DTOOLDIR_BASE_PREFIX=[^ ]*")
223 "-DTOOLDIR_BASE_PREFIX=\\\"../../../../\\\""))
224 #t))
cba36e64 225
827d2891 226(define* (cross-gcc target
7b3318e3
RW
227 #:key
228 (xgcc %xgcc)
229 (xbinutils (cross-binutils target))
230 (libc #f))
827d2891 231 "Return a cross-compiler for TARGET, where TARGET is a GNU triplet. Use
7b3318e3
RW
232XGCC as the base compiler. Use XBINUTILS as the associated cross-Binutils.
233If LIBC is false, then build a GCC that does not target a libc; otherwise,
234target that libc."
235 (package (inherit xgcc)
827d2891
LC
236 (name (string-append "gcc-cross-"
237 (if libc "" "sans-libc-")
238 target))
53de3e74
MO
239 (source
240 (origin
241 (inherit (package-source xgcc))
242 (patches
243 (append
244 (origin-patches (package-source xgcc))
245 (append (cond
246 ((version>=? (package-version xgcc) "8.0")
247 (search-patches "gcc-8-cross-environment-variables.patch"))
248 ((version>=? (package-version xgcc) "6.0")
249 (search-patches "gcc-7-cross-toolexeclibdir.patch"
250 "gcc-6-cross-environment-variables.patch"))
251 (else
252 (search-patches "gcc-cross-environment-variables.patch")))
253 (cross-gcc-patches xgcc target))))
254 (modules '((guix build utils)))
255 (snippet
256 (cross-gcc-snippet target))))
a49c57a7 257
53de3e74 258 (outputs '("out" "lib"))
a49c57a7 259
827d2891
LC
260 (arguments
261 `(#:implicit-inputs? #f
3593e5d5
LC
262 #:imported-modules ((gnu build cross-toolchain)
263 ,@%gnu-build-system-modules)
827d2891
LC
264 #:modules ((guix build gnu-build-system)
265 (guix build utils)
3593e5d5 266 (gnu build cross-toolchain)
827d2891 267 (srfi srfi-1)
3593e5d5
LC
268 (srfi srfi-26)
269 (ice-9 regex))
827d2891 270
7b3318e3 271 ,@(cross-gcc-arguments target xgcc libc)))
0de71c23
LC
272
273 (native-inputs
4a740d0f
LC
274 `(("ld-wrapper-cross" ,(make-ld-wrapper
275 (string-append "ld-wrapper-" target)
5bde4503 276 #:target (const target)
4a740d0f
LC
277 #:binutils xbinutils))
278 ("binutils-cross" ,xbinutils)
827d2891 279
7b3318e3 280 ,@(let ((inputs (append (package-inputs xgcc)
89da1270
LC
281 (fold alist-delete (%final-inputs)
282 '("libc" "libc:static"))
283
284 ;; Call it differently so that the builder can
285 ;; check whether the "libc" input is #f.
286 `(("libc-native"
287 ,@(assoc-ref (%final-inputs) "libc"))
288 ("libc-native:static"
289 ,@(assoc-ref (%final-inputs)
290 "libc:static"))))))
cba36e64
JN
291 (cond
292 ((target-mingw? target)
293 (if libc
89da1270
LC
294 `(,@inputs
295 ("libc" ,libc))
296 `(,@inputs
297 ("mingw-source" ,(package-source mingw-w64)))))
cba36e64 298 (libc
89da1270
LC
299 `(,@inputs
300 ("libc" ,libc)
6dff905e 301 ("libc:static" ,libc "static")
cba36e64
JN
302 ("xkernel-headers" ;the target headers
303 ,@(assoc-ref (package-propagated-inputs libc)
89da1270 304 "kernel-headers"))))
cba36e64 305 (else inputs)))))
17bb886f 306
0de71c23
LC
307 (inputs '())
308
17bb886f 309 ;; Only search target inputs, not host inputs.
cba36e64
JN
310 (search-paths (cons (search-path-specification
311 (variable "CROSS_LIBRARY_PATH")
312 (files '("lib" "lib64")))
313 (map (lambda (variable)
314 (search-path-specification
315 (variable variable)
89da1270
LC
316
317 ;; Add 'include/c++' here so that <cstdlib>'s
318 ;; "#include_next <stdlib.h>" finds GCC's
319 ;; <stdlib.h>, not libc's.
320 (files (match variable
321 ("CROSS_CPLUS_INCLUDE_PATH"
322 '("include/c++" "include"))
323 (_
324 '("include"))))))
cba36e64 325 %gcc-cross-include-paths)))
17bb886f 326 (native-search-paths '())))
827d2891 327
2d558e31
MR
328(define* (cross-kernel-headers target
329 #:optional
2ea77d48 330 (linux-headers linux-libre-headers)
2d558e31
MR
331 (xgcc (cross-gcc target))
332 (xbinutils (cross-binutils target)))
333 "Return headers depending on TARGET."
334
827d2891 335 (define xlinux-headers
2ea77d48
CD
336 (package (inherit linux-headers)
337 (name (string-append (package-name linux-headers)
827d2891
LC
338 "-cross-" target))
339 (arguments
0d5a559f
LC
340 (substitute-keyword-arguments
341 `(#:implicit-cross-inputs? #f
2ea77d48 342 ,@(package-arguments linux-headers))
827d2891
LC
343 ((#:phases phases)
344 `(alist-replace
345 'build
346 (lambda _
347 (setenv "ARCH" ,(system->linux-architecture target))
348 (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH"))
349
1e5005e2
MW
350 (invoke "make" ,(system->defconfig target))
351 (invoke "make" "mrproper" "headers_check"))
827d2891 352 ,phases))))
0de71c23
LC
353 (native-inputs `(("cross-gcc" ,xgcc)
354 ("cross-binutils" ,xbinutils)
2ea77d48 355 ,@(package-native-inputs linux-headers)))))
827d2891 356
2d558e31
MR
357 (define xgnumach-headers
358 (package (inherit gnumach-headers)
359 (name (string-append (package-name gnumach-headers)
360 "-cross-" target))
361
362 (native-inputs `(("cross-gcc" ,xgcc)
363 ("cross-binutils" ,xbinutils)
364 ,@(package-native-inputs gnumach-headers)))))
365
366 (define xmig
367 (package (inherit mig)
368 (name (string-append "mig-cross"))
369 (arguments
370 `(#:modules ((guix build gnu-build-system)
371 (guix build utils)
372 (srfi srfi-26))
273cab96
TGR
373 #:phases (modify-phases %standard-phases
374 (add-before 'configure 'set-cross-headers-path
375 (lambda* (#:key inputs #:allow-other-keys)
376 (let* ((mach (assoc-ref inputs "cross-gnumach-headers"))
377 (cpath (string-append mach "/include")))
378 (for-each (cut setenv <> cpath)
379 ',%gcc-cross-include-paths)
380 #t))))
2d558e31 381 #:configure-flags (list ,(string-append "--target=" target))
00410bbe 382 #:tests? #f))
2d558e31
MR
383
384 (propagated-inputs `(("cross-gnumach-headers" ,xgnumach-headers)))
385 (native-inputs `(("cross-gcc" ,xgcc)
386 ("cross-binutils" ,xbinutils)
387 ,@(package-native-inputs mig)))))
388
389 (define xhurd-headers
390 (package (inherit hurd-headers)
391 (name (string-append (package-name hurd-headers)
392 "-cross-" target))
393
2d558e31
MR
394 (native-inputs `(("cross-gcc" ,xgcc)
395 ("cross-binutils" ,xbinutils)
396 ("cross-mig" ,xmig)
397 ,@(alist-delete "mig"(package-native-inputs hurd-headers))))))
398
399 (define xglibc/hurd-headers
400 (package (inherit glibc/hurd-headers)
401 (name (string-append (package-name glibc/hurd-headers)
402 "-cross-" target))
403
404 (arguments
405 (substitute-keyword-arguments
406 `(#:modules ((guix build gnu-build-system)
407 (guix build utils)
408 (srfi srfi-26))
409 ,@(package-arguments glibc/hurd-headers))
410 ((#:phases phases)
273cab96 411 `(modify-phases ,phases
2d546858 412 (add-after 'unpack 'set-cross-headers-path
273cab96
TGR
413 (lambda* (#:key inputs #:allow-other-keys)
414 (let* ((mach (assoc-ref inputs "gnumach-headers"))
415 (hurd (assoc-ref inputs "hurd-headers"))
416 (cpath (string-append mach "/include:"
417 hurd "/include")))
418 (for-each (cut setenv <> cpath)
419 ',%gcc-cross-include-paths)
420 #t)))))))
2d558e31
MR
421
422 (propagated-inputs `(("gnumach-headers" ,xgnumach-headers)
423 ("hurd-headers" ,xhurd-headers)))
424
425 (native-inputs `(("cross-gcc" ,xgcc)
426 ("cross-binutils" ,xbinutils)
427 ("cross-mig" ,xmig)
428 ,@(alist-delete "mig"(package-native-inputs glibc/hurd-headers))))))
429
430 (define xhurd-minimal
431 (package (inherit hurd-minimal)
432 (name (string-append (package-name hurd-minimal)
433 "-cross-" target))
434 (arguments
435 (substitute-keyword-arguments
436 `(#:modules ((guix build gnu-build-system)
437 (guix build utils)
438 (srfi srfi-26))
439 ,@(package-arguments hurd-minimal))
440 ((#:phases phases)
273cab96
TGR
441 `(modify-phases ,phases
442 (add-before 'configure 'set-cross-headers-path
443 (lambda* (#:key inputs #:allow-other-keys)
444 (let* ((glibc-headers (assoc-ref inputs "cross-glibc-hurd-headers"))
445 (cpath (string-append glibc-headers "/include")))
446 (for-each (cut setenv <> cpath)
447 ',%gcc-cross-include-paths)
448 #t)))))))
2d558e31
MR
449
450 (inputs `(("cross-glibc-hurd-headers" ,xglibc/hurd-headers)))
451
452 (native-inputs `(("cross-gcc" ,xgcc)
453 ("cross-binutils" ,xbinutils)
454 ("cross-mig" ,xmig)
455 ,@(alist-delete "mig"(package-native-inputs hurd-minimal))))))
456
457 (define xhurd-core-headers
458 (package (inherit hurd-core-headers)
459 (name (string-append (package-name hurd-core-headers)
460 "-cross-" target))
461
462 (inputs `(("gnumach-headers" ,xgnumach-headers)
463 ("hurd-headers" ,xhurd-headers)
464 ("hurd-minimal" ,xhurd-minimal)))
465
466 (native-inputs `(("cross-gcc" ,xgcc)
467 ("cross-binutils" ,xbinutils)
468 ("cross-mig" ,xmig)
469 ,@(package-native-inputs hurd-core-headers)))))
470
471 (match target
472 ((or "i586-pc-gnu" "i586-gnu") xhurd-core-headers)
473 (_ xlinux-headers)))
474
475(define* (cross-libc target
476 #:optional
102d3075 477 (libc glibc)
2d558e31
MR
478 (xgcc (cross-gcc target))
479 (xbinutils (cross-binutils target))
480 (xheaders (cross-kernel-headers target)))
102d3075
CD
481 "Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS
482and the cross tool chain."
483 (if (cross-newlib? target libc)
f5d6c88d
CD
484 (native-libc target libc
485 #:xgcc xgcc
486 #:xbinutils xbinutils)
be1e842a
LC
487 (package
488 (inherit libc)
489 (name (string-append "glibc-cross-" target))
490 (arguments
491 (substitute-keyword-arguments
492 `( ;; Disable stripping (see above.)
493 #:strip-binaries? #f
494
495 ;; This package is used as a target input, but it should not have
496 ;; the usual cross-compilation inputs since that would include
497 ;; itself.
498 #:implicit-cross-inputs? #f
499
500 ;; We need SRFI 26.
501 #:modules ((guix build gnu-build-system)
502 (guix build utils)
503 (srfi srfi-26))
504
505 ,@(package-arguments libc))
506 ((#:configure-flags flags)
507 `(cons ,(string-append "--host=" target)
508 ,(if (hurd-triplet? target)
509 `(cons "--disable-werror" ,flags)
510 flags)))
511 ((#:phases phases)
512 `(modify-phases ,phases
513 (add-before 'configure 'set-cross-kernel-headers-path
514 (lambda* (#:key inputs #:allow-other-keys)
515 (let* ((kernel (assoc-ref inputs "kernel-headers"))
516 (cpath (string-append kernel "/include")))
517 (for-each (cut setenv <> cpath)
518 ',%gcc-cross-include-paths)
519 (setenv "CROSS_LIBRARY_PATH"
520 (string-append kernel "/lib")) ; for Hurd's libihash
521 #t)))
522 ,@(if (hurd-triplet? target)
523 '((add-after 'install 'augment-libc.so
524 (lambda* (#:key outputs #:allow-other-keys)
525 (let* ((out (assoc-ref outputs "out")))
526 (substitute* (string-append out "/lib/libc.so")
527 (("/[^ ]+/lib/libc.so.0.3")
528 (string-append out "/lib/libc.so.0.3"
529 " libmachuser.so libhurduser.so"))))
7aad4609 530 #t))
1c4268e4 531 ;; TODO: move to glibc in the next rebuild cycle
7aad4609
LC
532 (add-after 'unpack 'patch-libc/hurd
533 (lambda* (#:key inputs #:allow-other-keys)
1c4268e4
JN
534 (for-each
535 (lambda (name)
536 (let ((patch (assoc-ref inputs name)))
537 (invoke "patch" "-p1" "--force" "-i" patch)))
538 '("hurd-mach-print.patch"
539 "hurd-gettyent.patch")))))
be1e842a
LC
540 '())))))
541
542 ;; Shadow the native "kernel-headers" because glibc's recipe expects the
543 ;; "kernel-headers" input to point to the right thing.
544 (propagated-inputs `(("kernel-headers" ,xheaders)))
545
546 ;; FIXME: 'static-bash' should really be an input, not a native input, but
547 ;; to do that will require building an intermediate cross libc.
bc475834
LC
548 (inputs (if (hurd-triplet? target)
549 `(;; TODO: move to glibc in the next rebuild cycle
550 ("hurd-mach-print.patch"
551 ,(search-patch "glibc-hurd-mach-print.patch"))
552 ("hurd-gettyent.patch"
553 ,(search-patch "glibc-hurd-gettyent.patch")))
554 '()))
be1e842a
LC
555
556 (native-inputs `(("cross-gcc" ,xgcc)
557 ("cross-binutils" ,xbinutils)
558 ,@(if (hurd-triplet? target)
559 `(("cross-mig"
560 ,@(assoc-ref (package-native-inputs xheaders)
bc475834 561 "cross-mig")))
be1e842a
LC
562 '())
563 ,@(package-inputs libc) ;FIXME: static-bash
564 ,@(package-native-inputs libc))))))
cba36e64 565
102d3075
CD
566(define* (native-libc target
567 #:optional
f5d6c88d
CD
568 (libc glibc)
569 #:key
570 xgcc
571 xbinutils)
cba36e64 572 (if (target-mingw? target)
67dac6b8 573 (let ((machine (substring target 0 (string-index target #\-))))
f5d6c88d
CD
574 (make-mingw-w64 machine
575 #:xgcc xgcc
576 #:xbinutils xbinutils))
102d3075 577 libc))
cba36e64 578
102d3075
CD
579(define* (cross-newlib? target
580 #:optional
581 (libc glibc))
582 (not (eq? (native-libc target libc) libc)))
827d2891
LC
583
584\f
bd2e1a8c
LC
585;;; Concrete cross tool chains are instantiated like this:
586;;
587;; (define-public xgcc-armhf
588;; (let ((triplet "arm-linux-gnueabihf"))
827d2891 589;; (cross-gcc triplet
e0775d2a
MW
590;; #:xbinutils (cross-binutils triplet)
591;; #:libc (cross-libc triplet))))
bd2e1a8c
LC
592;;
593;;; We don't do that here because we'd be referring to bindings from (gnu
594;;; packages gcc) from the top level, which doesn't play well with circular
595;;; dependencies among modules.