cross-base.scm 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
  4. ;;; Copyright © 2016, 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  5. ;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
  6. ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  7. ;;; Copyright © 2019, 2020, 2021 Marius Bakke <marius@gnu.org>
  8. ;;; Copyright © 2019 Carl Dong <contact@carldong.me>
  9. ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
  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. (define-module (gnu packages cross-base)
  26. #:use-module (gnu packages)
  27. #:use-module (gnu packages gcc)
  28. #:use-module (gnu packages base)
  29. #:use-module (gnu packages linux)
  30. #:use-module (gnu packages hurd)
  31. #:use-module (gnu packages mingw)
  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)
  39. #:use-module (ice-9 match)
  40. #:use-module (ice-9 regex)
  41. #:export (cross-binutils
  42. cross-libc
  43. cross-gcc
  44. cross-kernel-headers))
  45. (define-syntax %xgcc
  46. ;; GCC package used as the basis for cross-compilation. It doesn't have to
  47. ;; be 'gcc' and can be a specific variant such as 'gcc-4.8'.
  48. ;;
  49. ;; Note: This is a macro so that we do not refer to 'gcc' from the top
  50. ;; level, which would lead to circular-dependency issues.
  51. (identifier-syntax gcc))
  52. (define %gcc-include-paths
  53. ;; Environment variables for header search paths.
  54. ;; Note: See <http://bugs.gnu.org/22186> for why not 'CPATH'.
  55. '("C_INCLUDE_PATH"
  56. "CPLUS_INCLUDE_PATH"
  57. "OBJC_INCLUDE_PATH"
  58. "OBJCPLUS_INCLUDE_PATH"))
  59. (define %gcc-cross-include-paths
  60. ;; Search path for target headers when cross-compiling.
  61. (map (cut string-append "CROSS_" <>) %gcc-include-paths))
  62. (define (cross p target)
  63. (package (inherit p)
  64. (name (string-append (package-name p) "-cross-" target))
  65. (arguments
  66. (substitute-keyword-arguments (package-arguments p)
  67. ((#:configure-flags flags)
  68. `(cons ,(string-append "--target=" target)
  69. ,flags))))))
  70. (define* (cross-binutils target #:optional (binutils binutils))
  71. "Return a cross-Binutils for TARGET using BINUTILS."
  72. (let ((binutils (package (inherit binutils)
  73. (arguments
  74. (substitute-keyword-arguments (package-arguments
  75. binutils)
  76. ((#:configure-flags flags)
  77. ;; Build with `--with-sysroot' so that ld honors
  78. ;; DT_RUNPATH entries when searching for a needed
  79. ;; library. This works because as a side effect
  80. ;; `genscripts.sh' sets `USE_LIBPATH=yes', which tells
  81. ;; elf32.em to use DT_RUNPATH in its search list.
  82. ;; See <http://sourceware.org/ml/binutils/2013-05/msg00312.html>.
  83. ;;
  84. ;; In theory choosing / as the sysroot could lead ld
  85. ;; to pick up native libs instead of target ones. In
  86. ;; practice the RUNPATH of target libs only refers to
  87. ;; target libs, not native libs, so this is safe.
  88. `(cons "--with-sysroot=/" ,flags)))))))
  89. ;; For Xtensa, apply Qualcomm's patch.
  90. (cross (cond ((string-prefix? "xtensa-" target)
  91. (package-with-patches binutils
  92. (search-patches
  93. "ath9k-htc-firmware-binutils.patch")))
  94. ((target-mingw? target)
  95. (package-with-extra-patches
  96. (package-with-extra-configure-variable
  97. ;; mingw binutils does not work correctly when configured
  98. ;; with `--enable-compressed-debug-sections`. An error
  99. ;; like the following will occur whenever you try to link:
  100. ;;
  101. ;; x86_64-w64-mingw32-ld: final link failed: bad value
  102. ;;
  103. ;; TODO: This seems like a deeper problem that warrants
  104. ;; deeper investigation.
  105. binutils "--enable-compressed-debug-sections" "no")
  106. (search-patches "binutils-mingw-w64-timestamp.patch"
  107. "binutils-mingw-w64-deterministic.patch")))
  108. (else binutils))
  109. target)))
  110. (define (cross-gcc-arguments target xgcc libc)
  111. "Return build system arguments for a cross-gcc for TARGET, using XGCC as the
  112. base compiler and using LIBC (which may be either a libc package or #f.)"
  113. ;; Set the current target system so that 'glibc-dynamic-linker' returns the
  114. ;; right name.
  115. (parameterize ((%current-target-system target))
  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
  121. ,@(package-arguments xgcc))))
  122. (substitute-keyword-arguments args
  123. ((#:configure-flags flags)
  124. `(append (list ,(string-append "--target=" target)
  125. ,@(if libc
  126. `( ;; Disable libcilkrts because it is not
  127. ;; ported to GNU/Hurd.
  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=/")
  137. `( ;; Disable features not needed at this stage.
  138. "--disable-shared" "--enable-static"
  139. "--enable-languages=c,c++"
  140. ;; libstdc++ cannot be built at this stage
  141. ;; ("Link tests are not allowed after
  142. ;; GCC_NO_EXECUTABLES.").
  143. "--disable-libstdc++-v3"
  144. "--disable-threads" ;libgcc, would need libc
  145. "--disable-libatomic"
  146. "--disable-libmudflap"
  147. "--disable-libgomp"
  148. "--disable-libmpx"
  149. "--disable-libssp"
  150. "--disable-libquadmath"
  151. "--disable-decimal-float" ;would need libc
  152. "--disable-libcilkrts"
  153. ;; When target is any OS other than 'none' these
  154. ;; libraries will fail if there is no libc
  155. ;; present. See
  156. ;; <https://lists.gnu.org/archive/html/guix-devel/2016-02/msg01311.html>
  157. "--disable-libitm"
  158. "--disable-libvtv"
  159. "--disable-libsanitizer"
  160. ))
  161. ;; Install cross-built libraries such as libgcc_s.so in
  162. ;; the "lib" output.
  163. ,@(if libc
  164. `((string-append "--with-toolexeclibdir="
  165. (assoc-ref %outputs "lib")
  166. "/" ,target "/lib"))
  167. '()))
  168. ,(if libc
  169. flags
  170. `(remove (cut string-match "--enable-languages.*" <>)
  171. ,flags))))
  172. ((#:make-flags flags)
  173. (if libc
  174. `(let ((libc (assoc-ref %build-inputs "libc")))
  175. ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
  176. ;; the -Bxxx for the startfiles.
  177. (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
  178. ,flags))
  179. flags))
  180. ((#:phases phases)
  181. `(cross-gcc-build-phases ,target ,phases))))))
  182. (define (cross-gcc-patches xgcc target)
  183. "Return GCC patches needed for XGCC and TARGET."
  184. (cond ((string-prefix? "xtensa-" target)
  185. ;; Patch by Qualcomm needed to build the ath9k-htc firmware.
  186. (search-patches "ath9k-htc-firmware-gcc.patch"))
  187. ((target-mingw? target)
  188. (append (search-patches "gcc-4.9.3-mingw-gthr-default.patch")
  189. (if (version>=? (package-version xgcc) "7.0")
  190. (search-patches "gcc-7-cross-mingw.patch")
  191. '())))
  192. (else '())))
  193. (define (cross-gcc-snippet target)
  194. "Return GCC snippet needed for TARGET."
  195. `(begin
  196. ,@(if (target-mingw? target)
  197. '((copy-recursively "libstdc++-v3/config/os/mingw32-w64"
  198. "libstdc++-v3/config/os/newlib"))
  199. '())
  200. ;; TOOLDIR_BASE_PREFIX is erroneous when using a separate "lib"
  201. ;; output. Specify it correctly, otherwise GCC won't find its shared
  202. ;; libraries installed in the "lib" output. See:
  203. ;; https://lists.gnu.org/archive/html/bug-guix/2020-03/msg00196.html.
  204. (substitute* "gcc/Makefile.in"
  205. (("-DTOOLDIR_BASE_PREFIX=[^ ]*")
  206. "-DTOOLDIR_BASE_PREFIX=\\\"../../../../\\\""))
  207. #t))
  208. (define* (cross-gcc target
  209. #:key
  210. (xgcc %xgcc)
  211. (xbinutils (cross-binutils target))
  212. (libc #f))
  213. "Return a cross-compiler for TARGET, where TARGET is a GNU triplet. Use
  214. XGCC as the base compiler. Use XBINUTILS as the associated cross-Binutils.
  215. If LIBC is false, then build a GCC that does not target a libc; otherwise,
  216. target that libc."
  217. (package (inherit xgcc)
  218. (name (string-append "gcc-cross-"
  219. (if libc "" "sans-libc-")
  220. target))
  221. (source
  222. (origin
  223. (inherit (package-source xgcc))
  224. (patches
  225. (append
  226. (origin-patches (package-source xgcc))
  227. (append (cond
  228. ((version>=? (package-version xgcc) "10.0")
  229. (search-patches "gcc-10-cross-environment-variables.patch"
  230. "gcc-cross-gxx-include-dir.patch"))
  231. ((version>=? (package-version xgcc) "8.0")
  232. (search-patches "gcc-8-cross-environment-variables.patch"))
  233. ((version>=? (package-version xgcc) "6.0")
  234. (search-patches "gcc-7-cross-toolexeclibdir.patch"
  235. "gcc-6-cross-environment-variables.patch"))
  236. (else
  237. (search-patches "gcc-cross-environment-variables.patch")))
  238. (cross-gcc-patches xgcc target))))
  239. (modules '((guix build utils)))
  240. (snippet
  241. (cross-gcc-snippet target))))
  242. (outputs '("out" "lib"))
  243. (arguments
  244. `(#:implicit-inputs? #f
  245. #:imported-modules ((gnu build cross-toolchain)
  246. ,@%gnu-build-system-modules)
  247. #:modules ((guix build gnu-build-system)
  248. (guix build utils)
  249. (gnu build cross-toolchain)
  250. (srfi srfi-1)
  251. (srfi srfi-26)
  252. (ice-9 regex))
  253. ,@(cross-gcc-arguments target xgcc libc)))
  254. (native-inputs
  255. `(("ld-wrapper-cross" ,(make-ld-wrapper
  256. (string-append "ld-wrapper-" target)
  257. #:target (const target)
  258. #:binutils xbinutils))
  259. ("binutils-cross" ,xbinutils)
  260. ,@(let ((inputs (append (package-inputs xgcc)
  261. (fold alist-delete (%final-inputs)
  262. '("libc" "libc:static"))
  263. ;; Call it differently so that the builder can
  264. ;; check whether the "libc" input is #f.
  265. `(("libc-native"
  266. ,@(assoc-ref (%final-inputs) "libc"))
  267. ("libc-native:static"
  268. ,@(assoc-ref (%final-inputs)
  269. "libc:static"))))))
  270. (cond
  271. ((target-mingw? target)
  272. (if libc
  273. `(,@inputs
  274. ("libc" ,libc))
  275. `(,@inputs
  276. ("mingw-source" ,(package-source mingw-w64)))))
  277. (libc
  278. `(,@inputs
  279. ("libc" ,libc)
  280. ("libc:static" ,libc "static")
  281. ("xkernel-headers" ;the target headers
  282. ,@(assoc-ref (package-propagated-inputs libc)
  283. "kernel-headers"))))
  284. (else inputs)))))
  285. (inputs '())
  286. ;; Only search target inputs, not host inputs.
  287. (search-paths (cons (search-path-specification
  288. (variable "CROSS_LIBRARY_PATH")
  289. (files '("lib" "lib64")))
  290. (map (lambda (variable)
  291. (search-path-specification
  292. (variable variable)
  293. ;; Add 'include/c++' here so that <cstdlib>'s
  294. ;; "#include_next <stdlib.h>" finds GCC's
  295. ;; <stdlib.h>, not libc's.
  296. (files (match variable
  297. ("CROSS_CPLUS_INCLUDE_PATH"
  298. '("include/c++" "include"))
  299. (_
  300. '("include"))))))
  301. %gcc-cross-include-paths)))
  302. (native-search-paths '())))
  303. (define* (cross-kernel-headers target
  304. #:optional
  305. (linux-headers linux-libre-headers)
  306. (xgcc (cross-gcc target))
  307. (xbinutils (cross-binutils target)))
  308. "Return headers depending on TARGET."
  309. (define xlinux-headers
  310. (package (inherit linux-headers)
  311. (name (string-append (package-name linux-headers)
  312. "-cross-" target))
  313. (arguments
  314. (substitute-keyword-arguments
  315. `(#:implicit-cross-inputs? #f
  316. ,@(package-arguments linux-headers))
  317. ((#:phases phases)
  318. `(modify-phases ,phases
  319. (replace 'build
  320. (lambda _
  321. (setenv "ARCH" ,(system->linux-architecture target))
  322. (format #t "`ARCH' set to `~a' (cross compiling)~%"
  323. (getenv "ARCH"))
  324. (invoke "make" ,(system->defconfig target))
  325. (invoke "make" "mrproper"
  326. ,@(if (version>=? (package-version linux-headers) "5.3")
  327. '("headers")
  328. '("headers_check")))))))))
  329. (native-inputs `(("cross-gcc" ,xgcc)
  330. ("cross-binutils" ,xbinutils)
  331. ,@(package-native-inputs linux-headers)))))
  332. (define xgnumach-headers
  333. (package (inherit gnumach-headers)
  334. (name (string-append (package-name gnumach-headers)
  335. "-cross-" target))
  336. (native-inputs `(("cross-gcc" ,xgcc)
  337. ("cross-binutils" ,xbinutils)
  338. ,@(package-native-inputs gnumach-headers)))))
  339. (define xmig
  340. (package (inherit mig)
  341. (name (string-append "mig-cross"))
  342. (arguments
  343. `(#:modules ((guix build gnu-build-system)
  344. (guix build utils)
  345. (srfi srfi-26))
  346. #:phases (modify-phases %standard-phases
  347. (add-before 'configure 'set-cross-headers-path
  348. (lambda* (#:key inputs #:allow-other-keys)
  349. (let* ((mach (assoc-ref inputs "cross-gnumach-headers"))
  350. (cpath (string-append mach "/include")))
  351. (for-each (cut setenv <> cpath)
  352. ',%gcc-cross-include-paths)
  353. #t))))
  354. #:configure-flags (list ,(string-append "--target=" target))
  355. #:tests? #f))
  356. (propagated-inputs `(("cross-gnumach-headers" ,xgnumach-headers)))
  357. (native-inputs `(("cross-gcc" ,xgcc)
  358. ("cross-binutils" ,xbinutils)
  359. ,@(package-native-inputs mig)))))
  360. (define xhurd-headers
  361. (package (inherit hurd-headers)
  362. (name (string-append (package-name hurd-headers)
  363. "-cross-" target))
  364. (native-inputs `(("cross-gcc" ,xgcc)
  365. ("cross-binutils" ,xbinutils)
  366. ("cross-mig" ,xmig)
  367. ,@(alist-delete "mig"(package-native-inputs hurd-headers))))))
  368. (define xglibc/hurd-headers
  369. (package (inherit glibc/hurd-headers)
  370. (name (string-append (package-name glibc/hurd-headers)
  371. "-cross-" target))
  372. (arguments
  373. (substitute-keyword-arguments
  374. `(#:modules ((guix build gnu-build-system)
  375. (guix build utils)
  376. (srfi srfi-26))
  377. ,@(package-arguments glibc/hurd-headers))
  378. ((#:phases phases)
  379. `(modify-phases ,phases
  380. (add-after 'unpack 'set-cross-headers-path
  381. (lambda* (#:key inputs #:allow-other-keys)
  382. (let* ((mach (assoc-ref inputs "gnumach-headers"))
  383. (hurd (assoc-ref inputs "hurd-headers"))
  384. (cpath (string-append mach "/include:"
  385. hurd "/include")))
  386. (for-each (cut setenv <> cpath)
  387. ',%gcc-cross-include-paths)
  388. #t)))))))
  389. (propagated-inputs `(("gnumach-headers" ,xgnumach-headers)
  390. ("hurd-headers" ,xhurd-headers)))
  391. (native-inputs `(("cross-gcc" ,xgcc)
  392. ("cross-binutils" ,xbinutils)
  393. ("cross-mig" ,xmig)
  394. ,@(alist-delete "mig"(package-native-inputs glibc/hurd-headers))))))
  395. (define xhurd-minimal
  396. (package (inherit hurd-minimal)
  397. (name (string-append (package-name hurd-minimal)
  398. "-cross-" target))
  399. (arguments
  400. (substitute-keyword-arguments
  401. `(#:modules ((guix build gnu-build-system)
  402. (guix build utils)
  403. (srfi srfi-26))
  404. ,@(package-arguments hurd-minimal))
  405. ((#:phases phases)
  406. `(modify-phases ,phases
  407. (add-before 'configure 'set-cross-headers-path
  408. (lambda* (#:key inputs #:allow-other-keys)
  409. (let* ((glibc-headers (assoc-ref inputs "cross-glibc-hurd-headers"))
  410. (cpath (string-append glibc-headers "/include")))
  411. (for-each (cut setenv <> cpath)
  412. ',%gcc-cross-include-paths)
  413. #t)))))))
  414. (inputs `(("cross-glibc-hurd-headers" ,xglibc/hurd-headers)))
  415. (native-inputs `(("cross-gcc" ,xgcc)
  416. ("cross-binutils" ,xbinutils)
  417. ("cross-mig" ,xmig)
  418. ,@(alist-delete "mig"(package-native-inputs hurd-minimal))))))
  419. (define xhurd-core-headers
  420. (package (inherit hurd-core-headers)
  421. (name (string-append (package-name hurd-core-headers)
  422. "-cross-" target))
  423. (inputs `(("gnumach-headers" ,xgnumach-headers)
  424. ("hurd-headers" ,xhurd-headers)
  425. ("hurd-minimal" ,xhurd-minimal)))
  426. (native-inputs `(("cross-gcc" ,xgcc)
  427. ("cross-binutils" ,xbinutils)
  428. ("cross-mig" ,xmig)
  429. ,@(package-native-inputs hurd-core-headers)))))
  430. (match target
  431. ((or "i586-pc-gnu" "i586-gnu") xhurd-core-headers)
  432. (_ xlinux-headers)))
  433. (define* (cross-libc target
  434. #:optional
  435. (libc glibc)
  436. (xgcc (cross-gcc target))
  437. (xbinutils (cross-binutils target))
  438. (xheaders (cross-kernel-headers target)))
  439. "Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS
  440. and the cross tool chain."
  441. (if (target-mingw? target)
  442. (let ((machine (substring target 0 (string-index target #\-))))
  443. (make-mingw-w64 machine
  444. #:xgcc xgcc
  445. #:xbinutils xbinutils))
  446. (package
  447. (inherit libc)
  448. (name (string-append "glibc-cross-" target))
  449. (arguments
  450. (substitute-keyword-arguments
  451. `( ;; Disable stripping (see above.)
  452. #:strip-binaries? #f
  453. ;; This package is used as a target input, but it should not have
  454. ;; the usual cross-compilation inputs since that would include
  455. ;; itself.
  456. #:implicit-cross-inputs? #f
  457. ;; We need SRFI 26.
  458. #:modules ((guix build gnu-build-system)
  459. (guix build utils)
  460. (srfi srfi-26))
  461. ,@(package-arguments libc))
  462. ((#:configure-flags flags)
  463. `(cons ,(string-append "--host=" target)
  464. ,(if (target-hurd? target)
  465. `(cons "--disable-werror" ,flags)
  466. flags)))
  467. ((#:phases phases)
  468. `(modify-phases ,phases
  469. (add-before 'configure 'set-cross-kernel-headers-path
  470. (lambda* (#:key inputs #:allow-other-keys)
  471. (let* ((kernel (assoc-ref inputs "kernel-headers"))
  472. (cpath (string-append kernel "/include")))
  473. (for-each (cut setenv <> cpath)
  474. ',%gcc-cross-include-paths)
  475. (setenv "CROSS_LIBRARY_PATH"
  476. (string-append kernel "/lib")) ; for Hurd's libihash
  477. #t)))
  478. ,@(if (target-hurd? target)
  479. '((add-after 'install 'augment-libc.so
  480. (lambda* (#:key outputs #:allow-other-keys)
  481. (let* ((out (assoc-ref outputs "out")))
  482. (substitute* (string-append out "/lib/libc.so")
  483. (("/[^ ]+/lib/libc.so.0.3")
  484. (string-append out "/lib/libc.so.0.3"
  485. " libmachuser.so libhurduser.so"))))
  486. #t)))
  487. '())))))
  488. ;; Shadow the native "kernel-headers" because glibc's recipe expects the
  489. ;; "kernel-headers" input to point to the right thing.
  490. (propagated-inputs `(("kernel-headers" ,xheaders)))
  491. (native-inputs `(("cross-gcc" ,xgcc)
  492. ("cross-binutils" ,xbinutils)
  493. ,@(if (target-hurd? target)
  494. `(("cross-mig"
  495. ,@(assoc-ref (package-native-inputs xheaders)
  496. "cross-mig")))
  497. '())
  498. ,@(package-inputs libc) ;FIXME: static-bash
  499. ,@(package-native-inputs libc))))))
  500. ;;; Concrete cross tool chains are instantiated like this:
  501. ;;
  502. ;; (define-public xgcc-armhf
  503. ;; (let ((triplet "arm-linux-gnueabihf"))
  504. ;; (cross-gcc triplet
  505. ;; #:xbinutils (cross-binutils triplet)
  506. ;; #:libc (cross-libc triplet))))
  507. ;;
  508. ;;; We don't do that here because we'd be referring to bindings from (gnu
  509. ;;; packages gcc) from the top level, which doesn't play well with circular
  510. ;;; dependencies among modules.