gnu: Add arm-none-eabi-gcc-6.
[jackhill/guix/guix.git] / gnu / packages / embedded.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2016 Theodoros Foradis <theodoros.for@openmailbox.org>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages embedded)
21 #:use-module (guix utils)
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix svn-download)
25 #:use-module (guix git-download)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix build-system gnu)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages cross-base)
30 #:use-module (gnu packages flex)
31 #:use-module (gnu packages gcc)
32 #:use-module (gnu packages perl)
33 #:use-module (gnu packages texinfo))
34
35 ;; We must not use the released GCC sources here, because the cross-compiler
36 ;; does not produce working binaries. Instead we take the very same SVN
37 ;; revision from the branch that is used for a release of the "GCC ARM
38 ;; embedded" project on launchpad.
39 ;; See https://launchpadlibrarian.net/218827644/release.txt
40 (define-public gcc-arm-none-eabi-4.9
41 (let ((xgcc (cross-gcc "arm-none-eabi"
42 (cross-binutils "arm-none-eabi")))
43 (revision "1")
44 (svn-revision 227977))
45 (package (inherit xgcc)
46 (version (string-append (package-version xgcc) "-"
47 revision "." (number->string svn-revision)))
48 (source
49 (origin
50 (method svn-fetch)
51 (uri (svn-reference
52 (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
53 (revision svn-revision)))
54 (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
55 (sha256
56 (base32
57 "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
58 (patches (origin-patches (package-source xgcc)))))
59 (native-inputs
60 `(("flex" ,flex)
61 ,@(package-native-inputs xgcc)))
62 (arguments
63 (substitute-keyword-arguments (package-arguments xgcc)
64 ((#:phases phases)
65 `(modify-phases ,phases
66 (add-after 'unpack 'fix-genmultilib
67 (lambda _
68 (substitute* "gcc/genmultilib"
69 (("#!/bin/sh") (string-append "#!" (which "sh"))))
70 #t))))
71 ((#:configure-flags flags)
72 ;; The configure flags are largely identical to the flags used by the
73 ;; "GCC ARM embedded" project.
74 `(append (list "--enable-multilib"
75 "--with-newlib"
76 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
77 "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
78 "--enable-plugins"
79 "--disable-decimal-float"
80 "--disable-libffi"
81 "--disable-libgomp"
82 "--disable-libmudflap"
83 "--disable-libquadmath"
84 "--disable-libssp"
85 "--disable-libstdcxx-pch"
86 "--disable-nls"
87 "--disable-shared"
88 "--disable-threads"
89 "--disable-tls")
90 (delete "--disable-multilib" ,flags)))))
91 (native-search-paths
92 (list (search-path-specification
93 (variable "CROSS_C_INCLUDE_PATH")
94 (files '("arm-none-eabi/include")))
95 (search-path-specification
96 (variable "CROSS_CPLUS_INCLUDE_PATH")
97 (files '("arm-none-eabi/include")))
98 (search-path-specification
99 (variable "CROSS_LIBRARY_PATH")
100 (files '("arm-none-eabi/lib"))))))))
101
102 (define-public gcc-arm-none-eabi-6
103 (package
104 (inherit gcc-arm-none-eabi-4.9)
105 (version (package-version gcc-6))
106 (source (origin (inherit (package-source gcc-6))
107 (patches
108 (append
109 (origin-patches (package-source gcc-6))
110 (search-patches "gcc-6-cross-environment-variables.patch"
111 "gcc-6-arm-none-eabi-multilib.patch")))))))
112
113 (define-public newlib-arm-none-eabi
114 (package
115 (name "newlib")
116 (version "2.4.0")
117 (source (origin
118 (method url-fetch)
119 (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
120 version ".tar.gz"))
121 (sha256
122 (base32
123 "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
124 (build-system gnu-build-system)
125 (arguments
126 `(#:out-of-source? #t
127 ;; The configure flags are identical to the flags used by the "GCC ARM
128 ;; embedded" project.
129 #:configure-flags '("--target=arm-none-eabi"
130 "--enable-newlib-io-long-long"
131 "--enable-newlib-register-fini"
132 "--disable-newlib-supplied-syscalls"
133 "--disable-nls")
134 #:phases
135 (modify-phases %standard-phases
136 (add-after 'unpack 'fix-references-to-/bin/sh
137 (lambda _
138 (substitute* '("libgloss/arm/cpu-init/Makefile.in"
139 "libgloss/arm/Makefile.in"
140 "libgloss/libnosys/Makefile.in"
141 "libgloss/Makefile.in")
142 (("/bin/sh") (which "sh")))
143 #t)))))
144 (native-inputs
145 `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
146 ("xgcc" ,gcc-arm-none-eabi-4.9)
147 ("texinfo" ,texinfo)))
148 (home-page "http://www.sourceware.org/newlib/")
149 (synopsis "C library for use on embedded systems")
150 (description "Newlib is a C library intended for use on embedded
151 systems. It is a conglomeration of several library parts that are easily
152 usable on embedded products.")
153 (license (license:non-copyleft
154 "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
155
156 (define-public newlib-nano-arm-none-eabi
157 (package (inherit newlib-arm-none-eabi)
158 (name "newlib-nano")
159 (arguments
160 (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
161 ;; The configure flags are identical to the flags used by the "GCC ARM
162 ;; embedded" project. They optimize newlib for use on small embedded
163 ;; systems with limited memory.
164 ((#:configure-flags flags)
165 ''("--target=arm-none-eabi"
166 "--enable-multilib"
167 "--disable-newlib-supplied-syscalls"
168 "--enable-newlib-reent-small"
169 "--disable-newlib-fvwrite-in-streamio"
170 "--disable-newlib-fseek-optimization"
171 "--disable-newlib-wide-orient"
172 "--enable-newlib-nano-malloc"
173 "--disable-newlib-unbuf-stream-opt"
174 "--enable-lite-exit"
175 "--enable-newlib-global-atexit"
176 "--enable-newlib-nano-formatted-io"
177 "--disable-nls"))))
178 (synopsis "Newlib variant for small systems with limited memory")))