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.
 
 
 
 
 
 

310 lines
13 KiB

  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013 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 gcc)
  19. #:use-module ((guix licenses)
  20. #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+))
  21. #:use-module (gnu packages)
  22. #:use-module (gnu packages bootstrap)
  23. #:use-module (gnu packages compression)
  24. #:use-module (gnu packages multiprecision)
  25. #:use-module (gnu packages texinfo)
  26. #:use-module (guix packages)
  27. #:use-module (guix download)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (ice-9 regex))
  30. (define %gcc-infrastructure
  31. ;; Base URL for GCC's infrastructure.
  32. "ftp://gcc.gnu.org/pub/gcc/infrastructure/")
  33. (define-public (gcc-configure-flags-for-triplet target)
  34. "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
  35. The purpose of this procedure is to translate extended GNU triplets---e.g.,
  36. where the OS part is overloaded to denote a specific ABI---into GCC
  37. `configure' options. We take extended GNU triplets that glibc recognizes."
  38. (cond ((string-match "^mips64el.*gnuabin?64$" target)
  39. ;; Triplets recognized by glibc as denoting the N64 ABI; see
  40. ;; ports/sysdeps/mips/preconfigure.
  41. '("--with-abi=64"))
  42. (else
  43. ;; TODO: Add `armel.*gnueabi', `hf', etc.
  44. '())))
  45. (define-public gcc-4.7
  46. (let* ((stripped? #t) ; TODO: make this a parameter
  47. (maybe-target-tools
  48. (lambda ()
  49. ;; Return the `_FOR_TARGET' variables that are needed when
  50. ;; cross-compiling GCC.
  51. (let ((target (%current-target-system)))
  52. (if target
  53. (map (lambda (var tool)
  54. (string-append (string-append var "_FOR_TARGET")
  55. "=" target "-" tool))
  56. '("CC" "CXX" "LD" "AR" "NM" "RANLIB" "STRIP")
  57. '("gcc" "g++" "ld" "ar" "nm" "ranlib" "strip"))
  58. '()))))
  59. (configure-flags
  60. (lambda ()
  61. ;; This is terrible. Since we have two levels of quasiquotation,
  62. ;; we have to do this convoluted thing just so we can insert the
  63. ;; contents of (maybe-target-tools).
  64. (list 'quasiquote
  65. (append
  66. '("--enable-plugin"
  67. "--enable-languages=c,c++"
  68. "--disable-multilib"
  69. "--with-local-prefix=/no-gcc-local-prefix"
  70. ,(let ((libc (assoc-ref %build-inputs "libc")))
  71. (if libc
  72. (string-append "--with-native-system-header-dir=" libc
  73. "/include")
  74. "--without-headers")))
  75. ;; When cross-compiling GCC, pass the right options for the
  76. ;; target triplet.
  77. (or (and=> (%current-target-system)
  78. gcc-configure-flags-for-triplet)
  79. '())
  80. (maybe-target-tools))))))
  81. (package
  82. (name "gcc")
  83. (version "4.7.3")
  84. (source (origin
  85. (method url-fetch)
  86. (uri (string-append "mirror://gnu/gcc/gcc-"
  87. version "/gcc-" version ".tar.bz2"))
  88. (sha256
  89. (base32
  90. "1hx9h64ivarlzi4hxvq42as5m9vlr5cyzaaq4gzj4i619zmkfz1g"))))
  91. (build-system gnu-build-system)
  92. (inputs `(("gmp" ,gmp)
  93. ("mpfr" ,mpfr)
  94. ("mpc" ,mpc)
  95. ("isl" ,isl)
  96. ("cloog" ,cloog)
  97. ("libelf" ,libelf)
  98. ("zlib" ,zlib)))
  99. ;; GCC is one of the few packages that doesn't ship .info files.
  100. (native-inputs `(("texinfo" ,texinfo)))
  101. (arguments
  102. `(#:out-of-source? #t
  103. #:strip-binaries? ,stripped?
  104. #:configure-flags ,(configure-flags)
  105. #:make-flags
  106. (let ((libc (assoc-ref %build-inputs "libc")))
  107. `(,@(if libc
  108. (list (string-append "LDFLAGS_FOR_TARGET="
  109. "-B" libc "/lib "
  110. "-Wl,-dynamic-linker "
  111. "-Wl," libc
  112. ,(glibc-dynamic-linker)))
  113. '())
  114. ,(string-append "BOOT_CFLAGS=-O2 "
  115. ,(if stripped? "-g0" "-g"))))
  116. #:tests? #f
  117. #:phases
  118. (alist-cons-before
  119. 'configure 'pre-configure
  120. (lambda* (#:key inputs outputs #:allow-other-keys)
  121. (let ((out (assoc-ref outputs "out"))
  122. (libc (assoc-ref inputs "libc")))
  123. (when libc
  124. ;; The following is not performed for `--without-headers'
  125. ;; cross-compiler builds.
  126. ;; Fix the dynamic linker's file name.
  127. (substitute* (find-files "gcc/config"
  128. "^linux(64|-elf)?\\.h$")
  129. (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
  130. (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
  131. suffix
  132. (string-append libc ,(glibc-dynamic-linker)))))
  133. ;; Tell where to find libstdc++, libc, and `?crt*.o', except
  134. ;; `crt{begin,end}.o', which come with GCC.
  135. (substitute* (find-files "gcc/config"
  136. "^(gnu-user(64)?|linux-elf)\\.h$")
  137. (("#define LIB_SPEC (.*)$" _ suffix)
  138. ;; Note that with this "lib" spec, we may still add a
  139. ;; RUNPATH to GCC even when `libgcc_s' is not NEEDED.
  140. ;; There's not much that can be done to avoid it, though.
  141. (format #f "#define LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib \
  142. %{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a"
  143. libc libc out out suffix))
  144. (("#define STARTFILE_SPEC.*$" line)
  145. (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
  146. #define STANDARD_STARTFILE_PREFIX_2 \"\"
  147. ~a~%"
  148. libc line))))
  149. ;; Don't retain a dependency on the build-time sed.
  150. (substitute* "fixincludes/fixincl.x"
  151. (("static char const sed_cmd_z\\[\\] =.*;")
  152. "static char const sed_cmd_z[] = \"sed\";"))))
  153. (alist-cons-after
  154. 'configure 'post-configure
  155. (lambda _
  156. ;; Don't store configure flags, to avoid retaining references to
  157. ;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
  158. (substitute* "Makefile"
  159. (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
  160. "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
  161. (alist-replace 'install
  162. (lambda* (#:key outputs #:allow-other-keys)
  163. (zero?
  164. (system* "make"
  165. ,(if stripped?
  166. "install-strip"
  167. "install"))))
  168. %standard-phases)))))
  169. (native-search-paths
  170. (list (search-path-specification
  171. (variable "CPATH")
  172. (directories '("include")))
  173. (search-path-specification
  174. (variable "LIBRARY_PATH")
  175. (directories '("lib" "lib64")))))
  176. (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
  177. (synopsis "GNU Compiler Collection")
  178. (description
  179. "GCC is the GNU Compiler Collection. It provides compiler front-ends
  180. for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
  181. Go. It also includes standard libraries for these languages.")
  182. (license gpl3+)
  183. (home-page "http://gcc.gnu.org/"))))
  184. (define-public gcc-4.8
  185. (package (inherit gcc-4.7)
  186. (version "4.8.2")
  187. (source (origin
  188. (method url-fetch)
  189. (uri (string-append "mirror://gnu/gcc/gcc-"
  190. version "/gcc-" version ".tar.bz2"))
  191. (sha256
  192. (base32
  193. "1j6dwgby4g3p3lz7zkss32ghr45zpdidrg8xvazvn91lqxv25p09"))))))
  194. (define-public isl
  195. (package
  196. (name "isl")
  197. (version "0.11.1")
  198. (source (origin
  199. (method url-fetch)
  200. (uri (list (string-append
  201. "http://isl.gforge.inria.fr/isl-"
  202. version
  203. ".tar.bz2")
  204. (string-append %gcc-infrastructure
  205. name "-" version ".tar.gz")))
  206. (sha256
  207. (base32
  208. "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))))
  209. (build-system gnu-build-system)
  210. (inputs `(("gmp" ,gmp)))
  211. (home-page "http://isl.gforge.inria.fr/")
  212. (synopsis
  213. "A library for manipulating sets and relations of integer points bounded
  214. by linear constraints")
  215. (description
  216. "isl is a library for manipulating sets and relations of integer points
  217. bounded by linear constraints. Supported operations on sets include
  218. intersection, union, set difference, emptiness check, convex hull, (integer)
  219. affine hull, integer projection, computing the lexicographic minimum using
  220. parametric integer programming, coalescing and parametric vertex
  221. enumeration. It also includes an ILP solver based on generalized basis
  222. reduction, transitive closures on maps (which may encode infinite graphs),
  223. dependence analysis and bounds on piecewise step-polynomials.")
  224. (license lgpl2.1+)))
  225. (define-public cloog
  226. (package
  227. (name "cloog")
  228. (version "0.18.0")
  229. (source
  230. (origin
  231. (method url-fetch)
  232. (uri (list (string-append
  233. "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
  234. version
  235. ".tar.gz")
  236. (string-append %gcc-infrastructure
  237. name "-" version ".tar.gz")))
  238. (sha256
  239. (base32
  240. "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
  241. (file-name (string-append name "-" version ".tar.gz"))))
  242. (build-system gnu-build-system)
  243. (inputs `(("gmp" ,gmp)
  244. ("isl" ,isl)))
  245. (arguments '(#:configure-flags '("--with-isl=system")))
  246. (home-page "http://www.cloog.org/")
  247. (synopsis "A library to generate code for scanning Z-polyhedra")
  248. (description
  249. "CLooG is a free software library to generate code for scanning
  250. Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
  251. reaches each integral point of one or more parameterized polyhedra.
  252. CLooG has been originally written to solve the code generation problem
  253. for optimizing compilers based on the polytope model. Nevertheless it
  254. is used now in various area e.g., to build control automata for
  255. high-level synthesis or to find the best polynomial approximation of a
  256. function. CLooG may help in any situation where scanning polyhedra
  257. matters. While the user has full control on generated code quality,
  258. CLooG is designed to avoid control overhead and to produce a very
  259. effective code.")
  260. (license gpl2+)))
  261. (define-public libelf
  262. (package
  263. (name "libelf")
  264. (version "0.8.13")
  265. (source (origin
  266. (method url-fetch)
  267. (uri (string-append "http://www.mr511.de/software/libelf-"
  268. version ".tar.gz"))
  269. (sha256
  270. (base32
  271. "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
  272. (build-system gnu-build-system)
  273. (arguments '(#:phases (alist-replace
  274. 'configure
  275. (lambda* (#:key outputs #:allow-other-keys)
  276. ;; This old `configure' script doesn't support
  277. ;; variables passed as arguments.
  278. (let ((out (assoc-ref outputs "out")))
  279. (setenv "CONFIG_SHELL" (which "bash"))
  280. (zero?
  281. (system* "./configure"
  282. (string-append "--prefix=" out)))))
  283. %standard-phases)))
  284. (home-page "http://www.mr511.de/software/english.html")
  285. (synopsis "An ELF object file access library")
  286. (description "libelf is a C library to access ELF object files.")
  287. (license lgpl2.0+)))