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