projects/guix·blob kernel-updates · refs

274 lines · 11.8 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2012, 2013, 2014, 2020, 2021 Ludovic Courtès <[email protected]>
3;;; Copyright © 2014 Federico Beffa <[email protected]>
4;;; Copyright © 2015, 2019 Ricardo Wurmus <[email protected]>
5;;; Copyright © 2016, 2017, 2020, 2021 Efraim Flashner <[email protected]>
6;;; Copyright © 2016, 2017 Ben Woodcroft <[email protected]>
7;;; Copyright © 2017, 2019, 2020, 2022 Marius Bakke <[email protected]>
8;;; Copyright © 2018 Tobias Geerinckx-Rice <[email protected]>
9;;; Copyright © 2019, 2021, 2025 Maxim Cournoyer <[email protected]>
10;;; Copyright © 2020 John Doe <[email protected]>
11;;; Copyright © 2024 Janneke Nieuwenhuizen <[email protected]>
12;;; Copyright © 2024 Sharlatan Hellseher <[email protected]>
13;;;
14;;; This file is part of GNU Guix.
15;;;
16;;; GNU Guix is free software; you can redistribute it and/or modify it
17;;; under the terms of the GNU General Public License as published by
18;;; the Free Software Foundation; either version 3 of the License, or (at
19;;; your option) any later version.
20;;;
21;;; GNU Guix is distributed in the hope that it will be useful, but
22;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;;; GNU General Public License for more details.
25;;;
26;;; You should have received a copy of the GNU General Public License
27;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29(define-module (gnu packages libffi)
30 #:use-module (gnu packages)
31 #:use-module (guix licenses)
32 #:use-module (guix packages)
33 #:use-module (guix gexp)
34 #:use-module (guix download)
35 #:use-module (guix git-download)
36 #:use-module (guix utils)
37 #:use-module (gnu packages check)
38 #:use-module (gnu packages crypto)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages python-build)
42 #:use-module (gnu packages python-xyz)
43 #:use-module (gnu packages ruby-check)
44 #:use-module (gnu packages ruby-xyz)
45 #:use-module (gnu packages sphinx)
46 #:use-module (guix build-system gnu)
47 #:use-module (guix build-system pyproject)
48 #:use-module (guix build-system ruby))
49
50(define-public libffi
51 (package
52 (name "libffi")
53 (version "3.4.6")
54 (source (origin
55 (method url-fetch)
56 (uri
57 (string-append "https://github.com/libffi/libffi/releases"
58 "/download/v" version "/"
59 name "-" version ".tar.gz"))
60 (sha256
61 (base32
62 "0kjsi51phx1pskjhhwa9y5fxdazzxgrl0m421sjsfqy84ggskpmh"))))
63 (build-system gnu-build-system)
64 (arguments
65 `(;; Prevent the build system from passing -march and -mtune to the
66 ;; compiler. See "ax_cc_maxopt.m4" and "ax_gcc_archflag.m4".
67 #:configure-flags '("--enable-portable-binary"
68 "--without-gcc-arch")))
69 (outputs '("out" "debug"))
70 (synopsis "Foreign function call interface library")
71 (description
72 "The libffi library provides a portable, high level programming interface
73to various calling conventions. This allows a programmer to call any
74function specified by a call interface description at run-time.
75
76FFI stands for Foreign Function Interface. A foreign function interface is
77the popular name for the interface that allows code written in one language
78to call code written in another language. The libffi library really only
79provides the lowest, machine dependent layer of a fully featured foreign
80function interface. A layer must exist above libffi that handles type
81conversions for values passed between the two languages.")
82 (home-page "https://www.sourceware.org/libffi/")
83 (properties `((release-monitoring-url . ,home-page)))
84
85 ;; See <https://github.com/atgreen/libffi/blob/master/LICENSE>.
86 (license expat)))
87
88;; Provide a variant without static trampolines as some packages
89;; (particularly GHC < 9) cannot handle them. See
90;; <https://github.com/libffi/libffi/pull/647> for a discussion.
91(define-public libffi-sans-static-trampolines
92 (hidden-package
93 (package/inherit libffi
94 (arguments
95 (substitute-keyword-arguments arguments
96 ((#:configure-flags flags #~'())
97 #~(append #$flags '("--disable-exec-static-tramp"))))))))
98
99(define-public libffi-next
100 (package
101 (inherit libffi)
102 (name "libffi")
103 (version "3.8.0")
104 (source (origin
105 (method url-fetch)
106 (uri
107 (string-append "https://github.com/libffi/libffi/releases"
108 "/download/v" version "/"
109 name "-" version ".tar.gz"))
110 (sha256
111 (base32
112 "1d0d1i1z835d54xppn4n6h7mbcibzz9wlbjriw1hmsvil7cy58vx"))))))
113
114(define-public python-cffi
115 (package
116 (name "python-cffi")
117 (version "1.17.1")
118 (source
119 (origin
120 (method url-fetch)
121 (uri (pypi-uri "cffi" version))
122 (sha256
123 (base32 "0918qn4yfjfgcy7i4imfy9q1cvl3svmm06anakflig1jdh0wcf8w"))))
124 (build-system pyproject-build-system)
125 (arguments
126 (list
127 #:test-flags
128 #~(list "src/c/" "testing/"
129 ;; Disable tests that fail (harmlessly) with glibc 2.34 and
130 ;; later, see
131 ;; <https://foss.heptapod.net/pypy/cffi/-/issues/528>.
132 "--deselect=testing/cffi0/test_ffi_backend.py::TestFFI::test_dlopen_handle"
133 "--deselect=testing/cffi1/test_re_python.py::test_dlopen_handle"
134 "--ignore=testing/embedding/test_performance.py")
135 #:phases
136 #~(modify-phases %standard-phases
137 (add-after 'unpack 'set-gcc
138 (lambda _
139 ;; XXX The "normal" approach of setting CC and friends does
140 ;; not work here. Is this the correct way of doing things?
141 (substitute* "testing/embedding/test_basic.py"
142 (("c = distutils\\.ccompiler\\.new_compiler\\(\\)")
143 (string-append "c = distutils.ccompiler.new_compiler();"
144 "c.set_executables(compiler='gcc',"
145 "compiler_so='gcc',linker_exe='gcc',"
146 "linker_so='gcc -shared')")))
147 (substitute* "testing/cffi0/test_ownlib.py"
148 (("\"cc testownlib") "\"gcc testownlib"))))
149 (add-before 'check 'patch-paths-of-dynamically-loaded-libraries
150 (lambda* (#:key inputs #:allow-other-keys)
151 ;; Shared libraries should be referred by their absolute path as
152 ;; using find_library or the like with their name fail when the
153 ;; resolved .so object is a linker script rather than an ELF
154 ;; binary (this is a limitation of the ctype library of Python).
155 (let ((libm (search-input-file inputs "lib/libm.so.6"))
156 (libc (search-input-file inputs "lib/libc.so.6")))
157 (substitute* '("testing/cffi0/test_function.py"
158 "testing/cffi0/test_parsing.py"
159 "testing/cffi0/test_unicode_literals.py"
160 "testing/cffi0/test_zdistutils.py"
161 "testing/cffi1/test_recompiler.py")
162 (("lib_m = ['\"]{1}m['\"]{1}")
163 (format #f "lib_m = '~a'" libm)))
164 (substitute* '("testing/cffi0/test_verify.py"
165 "testing/cffi1/test_verify1.py")
166 (("lib_m = \\[['\"]{1}m['\"]{1}\\]")
167 (format #f "lib_m = ['~a']" libm)))
168 (substitute* "src/c/test_c.py"
169 (("find_and_load_library\\(['\"]{1}c['\"]{1}")
170 (format #f "find_and_load_library('~a'" libc)))))))))
171 (native-inputs
172 (list pkg-config
173 python-pytest
174 python-setuptools))
175 (inputs
176 (list libffi))
177 (propagated-inputs ; required at run-time
178 (list python-pycparser))
179 (home-page "https://cffi.readthedocs.io/")
180 (synopsis "Foreign function interface for Python")
181 (description "Foreign Function Interface for Python calling C code.")
182 (license expat)))
183
184(define-public python-cffi-documentation
185 (package
186 (name "python-cffi-documentation")
187 (version (package-version python-cffi))
188 (source (package-source python-cffi))
189 (build-system gnu-build-system)
190 (arguments
191 `(#:tests? #f
192 #:phases (modify-phases %standard-phases
193 (add-after 'unpack 'chdir
194 (lambda _ (chdir "doc") #t))
195 (delete 'configure)
196 (replace 'build
197 (lambda* (#:key (make-flags '()) #:allow-other-keys)
198 (apply invoke "make" "html" make-flags)))
199 (replace 'install
200 (lambda* (#:key outputs #:allow-other-keys)
201 (let ((out (assoc-ref outputs "out")))
202 (copy-recursively "build/html" (string-append out "/html"))
203 #t))))))
204 (native-inputs
205 `(("sphinx-build" ,python-sphinx)))
206 (home-page (package-home-page python-cffi))
207 (synopsis "Documentation for the Python CFFI interface")
208 (description
209 "This package contains HTML documentation for the @code{python-cffi}
210project.")
211 (license (package-license python-cffi))))
212
213(define-public ruby-ffi
214 (package
215 (name "ruby-ffi")
216 (version "1.15.5")
217 (source (origin
218 ;; Pull from git because the RubyGems release bundles LibFFI,
219 ;; and comes with a gemspec that makes it difficult to unbundle.
220 (method git-fetch)
221 (uri (git-reference
222 (url "https://github.com/ffi/ffi")
223 (commit (string-append "v" version))))
224 (file-name (git-file-name name version))
225 (sha256
226 (base32
227 "1qk55s1zwpdjykwkj9l37m71i5n228i7f8bg3ply3ks9py16m7s6"))))
228 (build-system ruby-build-system)
229 (arguments
230 `(#:phases
231 (modify-phases %standard-phases
232 (replace 'replace-git-ls-files
233 (lambda _
234 ;; Do not try to execute git, or include the (un)bundled LibFFI.
235 (substitute* "ffi.gemspec"
236 (("git ls-files -z")
237 "find * -type f -print0 | sort -z")
238 (("lfs \\+?= .*")
239 "lfs = []\n"))
240 (substitute* "Rakefile"
241 (("git .*ls-files -z")
242 "find * -type f -print0 | sort -z")
243 (("LIBFFI_GIT_FILES = .*")
244 "LIBFFI_GIT_FILES = []\n"))))
245 (replace 'build
246 (lambda _
247 ;; Tests depend on the native extensions, so we build it
248 ;; beforehand without going through the gem machinery.
249 (invoke "rake" "compile")
250
251 ;; XXX: Ideally we'd use "rake native gem" here to prevent the
252 ;; install phase from needlessly rebuilding everything, but that
253 ;; requires the bundled LibFFI, and the install phase can not
254 ;; deal with such gems anyway.
255 (invoke "gem" "build" "ffi.gemspec")))
256 (replace 'check
257 (lambda* (#:key tests? #:allow-other-keys)
258 (if tests?
259 (begin
260 (setenv "MAKE" "make")
261 (setenv "CC" "gcc")
262 (invoke "rspec" "spec"))
263 (format #t "test suite not run~%")))))))
264 (native-inputs
265 (list ruby-rake-compiler ruby-rspec ruby-rubygems-tasks))
266 (inputs
267 (list libffi))
268 (synopsis "Ruby foreign function interface library")
269 (description "Ruby-FFI is a Ruby extension for programmatically loading
270dynamic libraries, binding functions within them, and calling those functions
271from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby
272and JRuby.")
273 (home-page "https://wiki.github.com/ffi/ffi")
274 (license bsd-3)))