You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

281 lines
12 KiB

gnu: Split (gnu packages base), adding (gnu packages commencement). * gnu/packages/base.scm (gnu-make-boot0, diffutils-boot0, findutils-boot0, %boot0-inputs, nix-system->gnu-triplet, boot-triplet, binutils-boot0, gcc-boot0, perl-boot0, linux-libre-headers-boot0, texinfo-boot0, %boot1-inputs, glibc-final-with-bootstrap-bash, cross-gcc-wrapper, static-bash-for-glibc, glibc-final, gcc-boot0-wrapped, %boot2-inputs, binutils-final, libstdc++, gcc-final, ld-wrapper-boot3, %boot3-inputs, bash-final, %boot4-inputs, guile-final, gnu-make-final, ld-wrapper, coreutils-final, grep-final, %boot5-inputs, %final-inputs, canonical-package, gcc-toolchain, gcc-toolchain-4.8, gcc-toolchain-4.9): Move to... * gnu/packages/commencement.scm: ... here. New file. * gnu-system.am (GNU_SYSTEM_MODULES): Add it. * build-aux/check-final-inputs-self-contained.scm: Adjust accordingly. * gnu/packages/cross-base.scm: Likewise. * gnu/packages/make-bootstrap.scm: Likewise. * guix/build-system/cmake.scm (cmake-build): Likewise. * guix/build-system/gnu.scm (standard-packages, gnu-build, gnu-cross-build): Likewise. * guix/build-system/perl.scm (perl-build): Likewise. * guix/build-system/python.scm (python-build): Likewise. * guix/build-system/trivial.scm (guile-for-build): Likewise. * guix/download.scm (url-fetch): Likewise. * guix/gexp.scm (default-guile): Likewise. * guix/git-download.scm (git-fetch): Likewise. * guix/monads.scm (run-with-store): Likewise. * guix/packages.scm (default-guile): Likewise. * guix/scripts/package.scm (guix-package): Likewise. * guix/scripts/refresh.scm: Likewise. * guix/svn-download.scm (svn-fetch): Likewise. * tests/builders.scm (%bootstrap-inputs, %bootstrap-search-paths): Likewise. * tests/packages.scm ("GNU Make, bootstrap"): Likewise. * tests/guix-package.sh: Likewise. * gnu/services/base.scm: Use 'canonical-package' instead of xxx-final. * gnu/services/xorg.scm: Likewise. * gnu/system/vm.scm: Likewise. * guix/scripts/pull.scm (guix-pull): Likewise.
7 years ago
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (gnu packages cross-base)
  19. #:use-module (guix licenses)
  20. #:use-module (gnu packages)
  21. #:use-module (gnu packages gcc)
  22. #:use-module (gnu packages base)
  23. #:use-module (gnu packages commencement)
  24. #:use-module (gnu packages linux)
  25. #:use-module (guix packages)
  26. #:use-module (guix download)
  27. #:use-module (guix utils)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (guix build-system trivial)
  30. #:use-module (srfi srfi-1)
  31. #:use-module (srfi srfi-26)
  32. #:use-module (ice-9 match)
  33. #:export (cross-binutils
  34. cross-libc
  35. cross-gcc))
  36. (define (cross p target)
  37. (package (inherit p)
  38. (location (source-properties->location (current-source-location)))
  39. (name (string-append (package-name p) "-cross-" target))
  40. (arguments
  41. (substitute-keyword-arguments (package-arguments p)
  42. ((#:configure-flags flags)
  43. `(cons ,(string-append "--target=" target)
  44. ,flags))))))
  45. (define (cross-binutils target)
  46. "Return a cross-Binutils for TARGET."
  47. (let ((binutils (package (inherit binutils)
  48. (arguments
  49. (substitute-keyword-arguments (package-arguments
  50. binutils)
  51. ((#:configure-flags flags)
  52. ;; Build with `--with-sysroot' so that ld honors
  53. ;; DT_RUNPATH entries when searching for a needed
  54. ;; library. This works because as a side effect
  55. ;; `genscripts.sh' sets `USE_LIBPATH=yes', which tells
  56. ;; elf32.em to use DT_RUNPATH in its search list.
  57. ;; See <http://sourceware.org/ml/binutils/2013-05/msg00312.html>.
  58. ;;
  59. ;; In theory choosing / as the sysroot could lead ld
  60. ;; to pick up native libs instead of target ones. In
  61. ;; practice the RUNPATH of target libs only refers to
  62. ;; target libs, not native libs, so this is safe.
  63. `(cons "--with-sysroot=/" ,flags)))))))
  64. (cross binutils target)))
  65. (define* (cross-gcc target
  66. #:optional (xbinutils (cross-binutils target)) libc)
  67. "Return a cross-compiler for TARGET, where TARGET is a GNU triplet. Use
  68. XBINUTILS as the associated cross-Binutils. If LIBC is false, then build a
  69. GCC that does not target a libc; otherwise, target that libc."
  70. (package (inherit gcc-4.8)
  71. (name (string-append "gcc-cross-"
  72. (if libc "" "sans-libc-")
  73. target))
  74. (source (origin (inherit (package-source gcc-4.8))
  75. (patches
  76. (list (search-patch
  77. "gcc-cross-environment-variables.patch")))))
  78. ;; For simplicity, use a single output. Otherwise libgcc_s & co. are not
  79. ;; found by default, etc.
  80. (outputs '("out"))
  81. (arguments
  82. `(#:implicit-inputs? #f
  83. #:modules ((guix build gnu-build-system)
  84. (guix build utils)
  85. (ice-9 regex)
  86. (srfi srfi-1)
  87. (srfi srfi-26))
  88. ,@(substitute-keyword-arguments (package-arguments gcc-4.8)
  89. ((#:configure-flags flags)
  90. `(append (list ,(string-append "--target=" target)
  91. ,@(gcc-configure-flags-for-triplet target)
  92. ,@(if libc
  93. '()
  94. `( ;; Disable features not needed at this stage.
  95. "--disable-shared" "--enable-static"
  96. ;; Disable C++ because libstdc++'s
  97. ;; configure script otherwise fails with
  98. ;; "Link tests are not allowed after
  99. ;; GCC_NO_EXECUTABLES."
  100. "--enable-languages=c"
  101. "--disable-threads" ; libgcc, would need libc
  102. "--disable-libatomic"
  103. "--disable-libmudflap"
  104. "--disable-libgomp"
  105. "--disable-libssp"
  106. "--disable-libquadmath"
  107. "--disable-decimal-float" ; would need libc
  108. )))
  109. ,(if libc
  110. flags
  111. `(remove (cut string-match "--enable-languages.*" <>)
  112. ,flags))))
  113. ((#:make-flags flags)
  114. (if libc
  115. `(let ((libc (assoc-ref %build-inputs "libc")))
  116. ;; FLAGS_FOR_TARGET are needed for the target libraries to
  117. ;; receive the -Bxxx for the startfiles.
  118. (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
  119. ,flags))
  120. flags))
  121. ((#:phases phases)
  122. (let ((phases
  123. `(alist-cons-after
  124. 'install 'make-cross-binutils-visible
  125. (lambda* (#:key outputs inputs #:allow-other-keys)
  126. (let* ((out (assoc-ref outputs "out"))
  127. (libexec (string-append out "/libexec/gcc/"
  128. ,target))
  129. (binutils (string-append
  130. (assoc-ref inputs "binutils-cross")
  131. "/bin/" ,target "-")))
  132. (for-each (lambda (file)
  133. (symlink (string-append binutils file)
  134. (string-append libexec "/"
  135. file)))
  136. '("as" "ld" "nm"))
  137. #t))
  138. ,phases)))
  139. (if libc
  140. `(alist-cons-before
  141. 'configure 'set-cross-path
  142. (lambda* (#:key inputs #:allow-other-keys)
  143. ;; Add the cross Linux headers to CROSS_CPATH, and remove
  144. ;; them from CPATH.
  145. (let ((libc (assoc-ref inputs "libc"))
  146. (linux (assoc-ref inputs
  147. "libc/cross-linux-headers")))
  148. (define (cross? x)
  149. ;; Return #t if X is a cross-libc or cross Linux.
  150. (or (string-prefix? libc x)
  151. (string-prefix? linux x)))
  152. (setenv "CROSS_CPATH"
  153. (string-append libc "/include:"
  154. linux "/include"))
  155. (setenv "CROSS_LIBRARY_PATH"
  156. (string-append libc "/lib"))
  157. (let ((cpath (search-path-as-string->list
  158. (getenv "CPATH")))
  159. (libpath (search-path-as-string->list
  160. (getenv "LIBRARY_PATH"))))
  161. (setenv "CPATH"
  162. (list->search-path-as-string
  163. (remove cross? cpath) ":"))
  164. (setenv "LIBRARY_PATH"
  165. (list->search-path-as-string
  166. (remove cross? libpath) ":"))
  167. #t)))
  168. ,phases)
  169. phases)))
  170. ((#:strip-binaries? _)
  171. ;; Disable stripping as this can break binaries, with object files
  172. ;; of libgcc.a showing up as having an unknown architecture. See
  173. ;; <http://lists.fedoraproject.org/pipermail/arm/2010-August/000663.html>
  174. ;; for instance.
  175. #f))))
  176. (native-inputs
  177. `(("binutils-cross" ,xbinutils)
  178. ;; Call it differently so that the builder can check whether the "libc"
  179. ;; input is #f.
  180. ("libc-native" ,@(assoc-ref %final-inputs "libc"))
  181. ;; Remaining inputs.
  182. ,@(let ((inputs (append (package-inputs gcc-4.8)
  183. (alist-delete "libc" %final-inputs))))
  184. (if libc
  185. `(("libc" ,libc)
  186. ,@inputs)
  187. inputs))))
  188. (inputs '())
  189. ;; Only search target inputs, not host inputs.
  190. (search-paths
  191. (list (search-path-specification
  192. (variable "CROSS_CPATH")
  193. (directories '("include")))
  194. (search-path-specification
  195. (variable "CROSS_LIBRARY_PATH")
  196. (directories '("lib" "lib64")))))
  197. (native-search-paths '())))
  198. (define* (cross-libc target
  199. #:optional
  200. (xgcc (cross-gcc target))
  201. (xbinutils (cross-binutils target)))
  202. "Return a libc cross-built for TARGET, a GNU triplet. Use XGCC and
  203. XBINUTILS and the cross tool chain."
  204. (define xlinux-headers
  205. (package (inherit linux-libre-headers)
  206. (name (string-append (package-name linux-libre-headers)
  207. "-cross-" target))
  208. (arguments
  209. (substitute-keyword-arguments (package-arguments linux-libre-headers)
  210. ((#:phases phases)
  211. `(alist-replace
  212. 'build
  213. (lambda _
  214. (setenv "ARCH" ,(system->linux-architecture target))
  215. (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH"))
  216. (and (zero? (system* "make" "defconfig"))
  217. (zero? (system* "make" "mrproper" "headers_check"))))
  218. ,phases))))
  219. (native-inputs `(("cross-gcc" ,xgcc)
  220. ("cross-binutils" ,xbinutils)
  221. ,@(package-native-inputs linux-libre-headers)))))
  222. (package (inherit glibc)
  223. (name (string-append "glibc-cross-" target))
  224. (arguments
  225. (substitute-keyword-arguments
  226. `(#:strip-binaries? #f ; disable stripping (see above)
  227. ,@(package-arguments glibc))
  228. ((#:configure-flags flags)
  229. `(cons ,(string-append "--host=" target)
  230. ,flags))
  231. ((#:phases phases)
  232. `(alist-cons-before
  233. 'configure 'set-cross-linux-headers-path
  234. (lambda* (#:key inputs #:allow-other-keys)
  235. (let ((linux (assoc-ref inputs "cross-linux-headers")))
  236. (setenv "CROSS_CPATH"
  237. (string-append linux "/include"))
  238. #t))
  239. ,phases))))
  240. (propagated-inputs `(("cross-linux-headers" ,xlinux-headers)))
  241. (native-inputs `(("cross-gcc" ,xgcc)
  242. ("cross-binutils" ,xbinutils)
  243. ,@(package-native-inputs glibc)))))
  244. ;;;
  245. ;;; Concrete cross toolchains.
  246. ;;;
  247. (define-public xgcc-mips64el
  248. (let ((triplet "mips64el-linux-gnuabi64")) ; N64 ABI
  249. (cross-gcc triplet
  250. (cross-binutils triplet)
  251. (cross-libc triplet))))
  252. ;; (define-public xgcc-armel
  253. ;; (let ((triplet "armel-linux-gnueabi"))
  254. ;; (cross-gcc triplet
  255. ;; (cross-binutils triplet)
  256. ;; (cross-libc triplet))))