~ruther/guix-exprs

ref: bac96d173db541f345d4009450f9574b4e88ec3e guix-exprs/ruther/packages/embedded.scm -rw-r--r-- 8.2 KiB
bac96d17 — Rutherther feat: add getdns and stubby 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
(define-module (ruther packages embedded)
  #:use-module (guix utils)
  #:use-module (guix gexp)
  #:use-module (guix memoization)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system trivial)
  #:use-module (gnu packages)
  #:use-module (gnu packages embedded)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages cross-base)
  #:use-module (gnu packages texinfo)
  #:use-module (guix build utils)
  #:use-module (gnu packages gcc)

  #:export (make-gcc-arm-none-eabi-12.3.rel1
            make-newlib-nano-arm-none-eabi-12.3.rel1
            arm-none-eabi-nano-toolchain-12.3.rel1))

(define make-gcc-arm-none-eabi-12.3.rel1
  (mlambda ()
    (let ((xgcc (cross-gcc "arm-none-eabi"
                           #:xgcc gcc-12
                           #:xbinutils (cross-binutils "arm-none-eabi"))))
      (package (inherit xgcc)
               (source
                (origin
                  (inherit (package-source xgcc))
                  (method git-fetch)
                  (uri (git-reference
                        (url "git://gcc.gnu.org/git/gcc.git")
                        (commit "0f54a73b998b72f7c8452a63730ec3b16fc47854")))
                  (sha256
                   (base32 "0r6q0m3d8g3k3rkmnqjw8aw5fcnsrmywf4ispdkxmk1al3whk1vk"))))
               (native-inputs
                (modify-inputs (package-native-inputs xgcc)
                  (delete "isl")
                  (prepend flex isl-0.18)))
               (arguments
                (substitute-keyword-arguments (package-arguments xgcc)
                  ((#:phases phases)
                   #~(modify-phases #$phases

                       (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
                         (lambda* (#:key inputs #:allow-other-keys)
                           (let ((gcc (assoc-ref inputs  "gcc")))
                             ;; Remove the default compiler from
                             ;; CPLUS_INCLUDE_PATH to prevent header conflict
                             ;; with the GCC from native-inputs.
                             (setenv "CPLUS_INCLUDE_PATH"
                                     (string-join
                                      (delete (string-append gcc "/include/c++")
                                              (string-split
                                               (getenv "CPLUS_INCLUDE_PATH")
                                               #\:))
                                      ":"))
                             (format #t
                                     "environment variable `CPLUS_INCLUDE_PATH'\
 changed to ~a~%"
                                     (getenv "CPLUS_INCLUDE_PATH")))))))
                  ((#:configure-flags flags)
                   ;; The configure flags are largely identical to the flags
                   ;; used by the "GCC ARM embedded" project.
                   #~(append (list "--disable-libgomp"
                                   "--disable-libmudflap"
                                   "--disable-libquadmath"
                                   "--disable-shared"
                                   "--disable-nls"
                                   "--disable-threads"
                                   "--disable-tls"
                                   "--without-cloog"
                                   "--without-isl"
                                   "--with-newlib"
                                   "--with-headers=yes"
                                   "--enable-checking=release"
                                   "--enable-languages=c,c++"
                                   "--with-gnu-as"
                                   "--with-gnu-ld"
                                   "--with-multilib-list=aprofile,rmprofile")
                             (delete "--disable-multilib" #$flags)))))
               (native-search-paths
                (list (search-path-specification
                       (variable "CROSS_C_INCLUDE_PATH")
                       (files '("arm-none-eabi/include")))
                      (search-path-specification
                       (variable "CROSS_CPLUS_INCLUDE_PATH")
                       (files '("arm-none-eabi/include"
                                "arm-none-eabi/include/c++"
                                "arm-none-eabi/include/c++/arm-none-eabi")))
                      (search-path-specification
                       (variable "CROSS_LIBRARY_PATH")
                       (files '("arm-none-eabi/lib")))))))))

(define make-newlib-nano-arm-none-eabi-12.3.rel1
  (mlambda ()
    (let ((base (make-newlib-nano-arm-none-eabi))
          (commit "4c7d0dfec5793cbf5cf3930b91f930479126d8ce")
          (revision "0"))
      (package
        (inherit base)
        (version (git-version "3.0.0" revision commit))
        (source
         (origin
           (method git-fetch)
           (uri (git-reference
                 (url "http://sourceware.org/git/newlib-cygwin.git")
                 (commit commit)))
           (sha256
            (base32
             "0drs9v8avh4y2h5bs0ixjn9x662jzkkikx8z034wgl41dxmn6786"))))
        (arguments
         (substitute-keyword-arguments (package-arguments base)
           ((#:phases original-phases)
            #~(modify-phases #$original-phases
                (replace 'fix-references-to-/bin/sh
                  (lambda _
                    (substitute* '("libgloss/arm/cpu-init/Makefile.inc"
                                   "libgloss/arm/Makefile.inc"
                                   "libgloss/libnosys/Makefile.inc"
                                   "libgloss/Makefile.in")
                      (("/bin/sh") (which "sh")))
                    #t))))
           ;; The configure flags are identical to the flags used by the "GCC
           ;; ARM embedded" project.
           ((#:configure-flags flags)
            #~(cons* "--enable-newlib-io-c99-formats"
                     "--enable-newlib-retargetable-locking"
                     "--enable-newlib-mb"
                     "--enable-newlib-reent-check-verify"
                     "--enable-newlib-register-fini"
                     #$flags))))
        (native-inputs
         `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
           ("xgcc" ,(make-gcc-arm-none-eabi-12.3.rel1))
           ("texinfo" ,texinfo)))))))

(define make-arm-none-eabi-toolchain
  (mlambda (xgcc newlib)
    "Produce a cross-compiler toolchain package with the compiler XGCC and the
C library variant NEWLIB."
    (let ((newlib-with-xgcc
           (package
             (inherit newlib)
             (native-inputs
              (alist-replace "xgcc" (list xgcc)
                             (package-native-inputs newlib))))))
      (package
        (name (string-append "arm-none-eabi"
                             (if (string=? (package-name newlib-with-xgcc)
                                           "newlib-nano")
                                 "-nano" "")
                             "-toolchain"))
        (version (package-version xgcc))
        (source #f)
        (build-system trivial-build-system)
        (arguments
         '(#:modules ((guix build union))
           #:builder
           (begin
             (use-modules (ice-9 match)
                          (guix build union))
             (match %build-inputs
               (((names . directories) ...)
                (union-build (assoc-ref %outputs "out")
                             directories))))))
        (propagated-inputs
         `(("binutils" ,(cross-binutils "arm-none-eabi"))
           ;; TODO make work with libstdc++...
           ;; ("libstdc++" ,((@@ (gnu packages embedded) make-libstdc++-arm-none-eabi) xgcc newlib-with-xgcc))
           ("gcc" ,xgcc)
           ("newlib" ,newlib-with-xgcc)))
        (synopsis "Complete GCC tool chain for ARM bare metal development")
        (description "This package provides a complete GCC tool chain for ARM
bare metal development.  This includes the GCC arm-none-eabi cross compiler
and newlib (or newlib-nano) as the C library.  The supported programming
languages are C and C++.")
        (home-page (package-home-page xgcc))
        (license (package-license xgcc))))))

(define arm-none-eabi-nano-toolchain-12.3.rel1
  (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-12.3.rel1)
   (make-newlib-nano-arm-none-eabi-12.3.rel1)))
Do not follow this link