cross-base.scm 25 KB

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