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