projects/guix·blob javascript-team · refs

492 lines · 20.4 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2012, 2013, 2015 Ludovic Courtès <[email protected]>
3;;; Copyright © 2014 Mark H Weaver <[email protected]>
4;;; Copyright © 2015, 2018 Andreas Enge <[email protected]>
5;;; Copyright © 2016, 2020 Nicolas Goaziou <[email protected]>
6;;; Copyright © 2016, 2020 Jan (janneke) Nieuwenhuizen <[email protected]>
7;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <[email protected]>
8;;; Copyright © 2018 Eric Bavier <[email protected]>
9;;; Copyright © 2018, 2019, 2021, 2023, 2024 Efraim Flashner <[email protected]>
10;;; Copyright © 2021 Vinicius Monego <[email protected]>
11;;; Copyright © 2022, 2024 Maxim Cournoyer <[email protected]>
12;;; Copyright © 2023, 2025 Janneke Nieuwenhuizen <[email protected]>
13;;; Copyright © 2023 Sharlatan Hellseher <[email protected]>
14;;;
15;;; This file is part of GNU Guix.
16;;;
17;;; GNU Guix is free software; you can redistribute it and/or modify it
18;;; under the terms of the GNU General Public License as published by
19;;; the Free Software Foundation; either version 3 of the License, or (at
20;;; your option) any later version.
21;;;
22;;; GNU Guix is distributed in the hope that it will be useful, but
23;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25;;; GNU General Public License for more details.
26;;;
27;;; You should have received a copy of the GNU General Public License
28;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29
30(define-module (gnu packages multiprecision)
31 #:use-module (guix licenses)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages bison)
35 #:use-module (gnu packages compiler-tools)
36 #:use-module (gnu packages m4)
37 #:use-module (gnu packages gcc)
38 #:use-module (gnu packages texinfo)
39 #:use-module (guix download)
40 #:use-module (guix gexp)
41 #:use-module (guix git-download)
42 #:use-module (guix packages)
43 #:use-module (guix utils)
44 #:use-module (guix build-system gnu))
45
46(define-public gmp
47 (package
48 (name "gmp")
49 (version "6.3.0")
50 (source (origin
51 (method url-fetch)
52 (uri
53 (string-append "mirror://gnu/gmp/gmp-"
54 version ".tar.xz"))
55 (sha256
56 (base32
57 "1648ad1mr7c1r8lkkqshrv1jfjgfdb30plsadxhni7mq041bihm3"))
58 (patches (search-patches "gmp-faulty-test.patch"))))
59 (build-system gnu-build-system)
60 (native-inputs (list m4))
61 (outputs '("out" "debug"))
62 (arguments
63 (list
64 #:parallel-tests? #f ; mpz/reuse fails otherwise
65 #:configure-flags
66 #~(list
67 ;; Build a "fat binary", with routines for several sub-architectures.
68 "--enable-fat"
69 "--enable-cxx"
70 #$@(cond
71 ((target-mingw?)
72 ;; Static and shared cannot be built in one go: they produce
73 ;; different headers. We need shared.
74 '("--disable-static"
75 "--enable-shared"))
76 ((target-x32?)
77 `("ABI=x32"))
78 (else '())))))
79 (synopsis "Multiple-precision arithmetic library")
80 (description
81 "The @acronym{GMP, the GNU Multiple Precision Arithmetic} library performs
82arbitrary-precision arithmetic on signed integers, rational numbers and floating
83point numbers. The precision is only limited by the available memory.
84The library is highly optimized, with a design focus on execution speed.
85It is aimed at use in, for example, cryptography and computational algebra.")
86 (license lgpl3+)
87 (home-page "https://gmplib.org/")))
88
89(define-public gmp-6.0
90 ;; We keep this one around to bootstrap GCC, to work around a compilation
91 ;; issue on ARM. See
92 ;; <https://gmplib.org/list-archives/gmp-bugs/2015-December/003848.html>.
93 (package
94 (inherit gmp)
95 (version "6.0.0a")
96 (source (origin
97 (method url-fetch)
98 (uri (string-append "mirror://gnu/gmp/gmp-"
99 version ".tar.xz"))
100 (sha256
101 (base32
102 "0r5pp27cy7ch3dg5v0rsny8bib1zfvrza6027g2mp5f6v8pd6mli"))
103 (patches (search-patches "gmp-arm-asm-nothumb.patch"
104 "gmp-faulty-test.patch"))))))
105
106(define-public mpfr
107 (package
108 (name "mpfr")
109 (version "4.2.2")
110 (source (origin
111 (method url-fetch)
112 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
113 ".tar.xz"))
114 (sha256 (base32
115 "00ffqs0sssb81bx007d0k2wc7hsyxy4yiqil6xbais7p7qwa0yxn"))))
116 (arguments
117 (list
118 #:phases (if (system-hurd?)
119 #~(modify-phases %standard-phases
120 (add-after 'unpack 'skip-tests
121 (lambda _
122 (substitute*
123 "tests/tsprintf.c"
124 (("(^| )main *\\(.*" all)
125 (string-append all "{\n exit (77);//"))))))
126 #~%standard-phases)))
127 (build-system gnu-build-system)
128 (outputs '("out" "debug"))
129 (propagated-inputs (list gmp)) ; <mpfr.h> refers to <gmp.h>
130 (synopsis "C library for arbitrary-precision floating-point arithmetic")
131 (description
132 "GNU@tie{}@acronym{MPFR, Multiple Precision Floating-Point Reliably} is a C
133library for performing multiple-precision, floating-point computations with
134correct rounding.")
135 (license lgpl3+)
136 (home-page "https://www.mpfr.org/")))
137
138(define-public mpc
139 (package
140 (name "mpc")
141 (version "1.3.1")
142 (source (origin
143 (method url-fetch)
144 (uri (string-append
145 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
146 (sha256
147 (base32
148 "1f2rqz0hdrrhx4y1i5f8pv6yv08a876k1dqcm9s2p26gyn928r5b"))))
149 (build-system gnu-build-system)
150 (outputs '("out" "debug"))
151 (propagated-inputs (list gmp ; <mpc.h> refers to both
152 mpfr))
153 (synopsis "C library for arbitrary-precision complex arithmetic")
154 (description
155 "GNU@tie{}@acronym{MPC, Multiple Precision Complex library} is a C library
156for performing arithmetic on complex numbers. It supports arbitrarily high
157precision and correctly rounds the results.")
158 (license lgpl3+)
159 (home-page "https://www.multiprecision.org/mpc/")))
160
161(define-public mpfi
162 ;; The last release, 1.5.4, lacks source files such as div_ext.c and others
163 ;; (see: https://gitlab.inria.fr/mpfi/mpfi/-/issues/21721). Use the latest
164 ;; commit until a new release is made.
165 (let ((commit "b9825348f1e723ab0988105599b34f1f9cd5ff3e")
166 (revision "1"))
167 (package
168 (name "mpfi")
169 (version (git-version "1.5.4" revision commit))
170 (source (origin
171 (method git-fetch)
172 (uri (git-reference
173 (url "https://gitlab.inria.fr/mpfi/mpfi")
174 (commit commit)))
175 (file-name (git-file-name name version))
176 (sha256
177 (base32
178 "141pa2ym1azka25bwkx2w1mf6wdcn155ncc45dr5bj5dycw2hj0m"))))
179 (build-system gnu-build-system)
180 (arguments
181 (list #:configure-flags
182 #~(list
183 "CFLAGS=-g -O -Wno-error=incompatible-pointer-types"
184 "--enable-static=no")
185 #:phases #~(modify-phases %standard-phases
186 (add-after 'unpack 'chdir
187 (lambda _
188 (chdir "mpfi")))
189 (add-after 'unpack 'disable-problematic-tests
190 (lambda _
191 ;; XXX: The tdiv_ext and trec_sqrt tests
192 ;; segfaults (not reported upstream; accounts on
193 ;; their gitlab apparently require to be
194 ;; manually created).
195 (setenv "XFAIL_TESTS" "tdiv_ext trec_sqrt"))))))
196 (native-inputs (list automake autoconf libtool texinfo))
197 (propagated-inputs
198 (list gmp mpfr)) ;<mpfi.h> refers to both
199 (home-page "https://gitlab.inria.fr/mpfi/mpfi")
200 (synopsis "C library for arbitrary-precision interval arithmetic")
201 (description
202 "@acronym{MPFI, Multiple Precision Floating-point Interval} is a portable C
203library for arbitrary-precision interval arithmetic, with intervals represented
204using MPFR reliable floating-point numbers. It's based on the @acronym{GMP, GNU
205Multiple Precision Arithmetic} and GNU@tie{}@acronym{MPFR, Multiple Precision
206Floating-Point Reliably} libraries.
207
208The purpose of arbitrary-precision interval arithmetic is to get results that
209are both guaranteed, thanks to interval computation, and accurate, thanks to
210multiple-precision arithmetic.")
211 (license lgpl2.1+))))
212
213(define-public irram
214 (package
215 (name "irram")
216 (version "2013_01")
217 (source
218 (origin
219 (method url-fetch)
220 (uri (string-append "http://irram.uni-trier.de/irram-files/iRRAM_"
221 version ".tar.bz2"))
222 (sha256
223 (base32 "1cdmvb4hsa161rfdjqyhd9sb3fcr43p3a6nsj7cb4kn9f94qmjpj"))))
224 (build-system gnu-build-system)
225 (propagated-inputs (list gmp ; <mpfi.h> refers to both
226 mpfr))
227 (arguments
228 `(#:parallel-build? #f))
229 (synopsis "C++ package for real arithmetic based on the Real-RAM concept")
230 (description
231 "@dfn{iRRAM} is a C++ package for error-free real arithmetic based on
232the concept of a Real-RAM. Its capabilities range from ordinary arithmetic
233over trigonometric functions to linear algebra and differential
234equations. A program using iRRAM is coded in ordinary C++, but may use a
235special class that behaves like real numbers without any
236error. Additionally, iRRAM uses the concept of multi-valued functions.")
237 (license lgpl2.0+)
238 (home-page "http://irram.uni-trier.de/")))
239
240(define-public qd
241 (package
242 (name "qd")
243 (version "2.3.24")
244 (source
245 (origin
246 (method url-fetch)
247 (uri (string-append "https://crd-legacy.lbl.gov/~dhbailey/mpdist/qd-"
248 version ".tar.gz"))
249 (sha256
250 (base32 "0f0fwsyh23p5zfyrj6n16q7b56g213fnhdc8dbl22r3fz1rnqyx4"))))
251 (build-system gnu-build-system)
252 (native-inputs (list automake autoconf gfortran))
253 (arguments
254 (list
255 #:configure-flags
256 #~(list "--disable-enable_fma" ;weird :/
257 "--disable-static"
258 "--enable-shared"
259 #$@(if (target-aarch64?)
260 ;; XXX: The qd_test test fails numerical
261 ;; accuracy checks for 'dd_real::exp()' on
262 ;; aarch64 with GCC 5.4 at -O2. Disabling
263 ;; expensive optimizations lets it pass.
264 '("CXXFLAGS=-O3 -fno-expensive-optimizations")
265 '("CXXFLAGS=-O3")))))
266 (home-page "https://www.davidhbailey.com/dhbsoftware/")
267 (synopsis "Double-double and quad-double library")
268 (description "This package supports both a double-double
269datatype (approx. 32 decimal digits) and a quad-double datatype (approx. 64
270decimal digits). The computational library is written in C++. Both C++ and
271Fortran-90 high-level language interfaces are provided to permit one to
272convert an existing C++ or Fortran-90 program to use the library with only
273minor changes to the source code. In most cases only a few type statements
274and (for Fortran-90 programs) read/write statements need to be changed. PSLQ
275and numerical quadrature programs are included.")
276 (license bsd-3)))
277
278(define-public cln
279 (package
280 (name "cln")
281 (version "1.3.6")
282 (source
283 (origin
284 (method url-fetch)
285 (uri (string-append "https://www.ginac.de/CLN/cln-"
286 version ".tar.bz2"))
287 (sha256
288 (base32 "0jlq9l4hphk7qqlgqj9ihjp4m3rwjbhk6q4v00lsbgbri07574pl"))))
289 (build-system gnu-build-system)
290 (arguments
291 `(#:configure-flags (list "--disable-static")))
292 (inputs
293 (list gmp))
294 (home-page "https://www.ginac.de/CLN/")
295 (synopsis "Library for arbitrary precision computations")
296 (description "CLN is a C++ library for efficient computations with all
297kinds of numbers in arbitrary precision. It provides a rich set of number
298classes and elementary, logical and transcendental functions.")
299 (license gpl2+)))
300
301(define-public tomsfastmath
302 (package
303 (name "tomsfastmath")
304 (version "0.13.1")
305 (synopsis "Large integer arithmetic library")
306 (source (origin
307 (method url-fetch)
308 (uri (string-append "https://github.com/libtom/tomsfastmath/"
309 "releases/download/v" version "/"
310 "tfm-" version ".tar.xz"))
311 (sha256
312 (base32
313 "0f0pmiaskh89sp0q933pafxb914shpaj5ad8sb5rzk1wv8d7mja7"))))
314 (build-system gnu-build-system)
315 (native-inputs
316 (list libtool))
317 (arguments
318 `(#:make-flags (list "-f" "makefile.shared"
319 (string-append "LIBPATH=" %output "/lib")
320 (string-append "INCPATH=" %output "/include")
321 "GROUP=root" "USER=root"
322 "CC=gcc")
323 #:phases
324 (modify-phases %standard-phases
325 (delete 'configure) ; no configuration
326 (replace 'check
327 (lambda* (#:key make-flags #:allow-other-keys)
328 (apply invoke "make"
329 "stest" "test_standalone"
330 make-flags)
331 (invoke "./stest")
332 (invoke "./test")))
333 (add-before 'install 'install-nogroup
334 (lambda _
335 ;; Let permissions inherit from the current process.
336 (substitute* "makefile.shared"
337 (("-g \\$\\(GROUP\\) -o \\$\\(USER\\)") ""))
338 #t))
339 (add-after 'install 'install-doc
340 (lambda* (#:key outputs #:allow-other-keys)
341 (let ((docdir (string-append (assoc-ref outputs "out")
342 "/share/doc/tomsfastmath")))
343 (install-file "doc/tfm.pdf" docdir)
344 #t)))
345 (add-after 'install 'install-pc
346 (lambda* (#:key outputs #:allow-other-keys)
347 (let* ((out (assoc-ref outputs "out"))
348 (pc-dir (string-append out "/lib/pkgconfig")))
349 (call-with-output-file "tomsfastmath.pc"
350 (lambda (port)
351 (format port "~
352Name: TomsFastMath
353Description: ~a
354Version: ~a
355Libs: -L~a/lib -ltfm~%"
356 ,synopsis ,version out)))
357 (install-file "tomsfastmath.pc" pc-dir)
358 #t))))))
359 (home-page "https://www.libtom.net/TomsFastMath/")
360 (description "TomsFastMath is a large integer library written in portable
361ISO C. It is a port of LibTomMath with optional support for inline assembler
362multiplies.")
363 (license public-domain)))
364
365(define-public libtomcrypt
366 (package
367 (name "libtomcrypt")
368 (version "1.18.2")
369 (outputs '("out" "static"))
370 (source
371 (origin
372 (method url-fetch)
373 (uri (string-append "https://github.com/libtom/libtomcrypt"
374 "/releases/download/v" version
375 "/crypt-" version ".tar.xz"))
376 (sha256
377 (base32
378 "113vfrgapyv72lalhd3nkw7jnks8az0gcb5wqn9hj19nhcxlrbcn"))
379 (modules '((guix build utils)))
380 (snippet
381 '(begin
382 ;; Patch CVE-2019-17362
383 ;; https://github.com/libtom/libtomcrypt/commit/25c26a3b7a9ad8192ccc923e15cf62bf0108ef94
384 (substitute* "src/pk/asn1/der/utf8/der_decode_utf8_string.c"
385 (("z > 4") "z == 1 || z > 4"))
386 #t))))
387 (build-system gnu-build-system)
388 (arguments
389 `(#:phases
390 (modify-phases %standard-phases
391 (delete 'configure) ; no configure
392 (add-after 'unpack 'prepare-build
393 (lambda _
394 ;; We want the shared library by default so force it to be the
395 ;; default makefile target.
396 (delete-file "makefile")
397 (symlink "makefile.shared" "makefile")
398 ;; We link to libtommath, so we need to add it to the pc file
399 (substitute* "libtomcrypt.pc.in"
400 (("-ltomcrypt") "-ltomcrypt -ltommath"))
401 #t))
402 (add-after 'build 'build-static
403 (lambda* (#:key make-flags #:allow-other-keys)
404 (apply invoke "make" "-f" "makefile.unix" make-flags)))
405 (replace 'check
406 (lambda* (#:key test-target make-flags #:allow-other-keys)
407 (apply invoke "make" "-f" "makefile.unix" test-target make-flags)
408 (invoke "./test")))
409 (add-after 'install 'install-static-library
410 (lambda* (#:key outputs #:allow-other-keys)
411 (let ((out (assoc-ref outputs "out"))
412 (static (assoc-ref outputs "static")))
413 (mkdir-p (string-append static "/lib"))
414 (mkdir-p (string-append static "/include"))
415 (rename-file (string-append out "/lib/libtomcrypt.a")
416 (string-append static "/lib/libtomcrypt.a"))
417 (copy-recursively (string-append out "/include")
418 (string-append static "/include"))
419 #t))))
420 #:test-target "test"
421 #:make-flags
422 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
423 "CFLAGS += -DLTM_DESC -DUSE_LTM"
424 (string-append "EXTRALIBS="
425 (search-input-file %build-inputs
426 "/lib/libtommath.so"))
427 (string-append "CC=" ,(cc-for-target)))))
428 (native-inputs
429 (list libtool))
430 (inputs
431 (list libtommath))
432 (home-page "https://www.libtom.net/LibTomCrypt/")
433 (synopsis "Cryptographic toolkit")
434 (description "LibTomCrypt is a fairly comprehensive, modular and portable
435cryptographic toolkit that provides developers with a vast array of well known
436published block ciphers, one-way hash functions, chaining modes, pseudo-random
437number generators, public key cryptography and a plethora of other routines.")
438 (properties `((lint-hidden-cve . ("CVE-2019-17362"))))
439 (license unlicense)))
440
441(define-public libtommath
442 (package
443 (name "libtommath")
444 (version "1.3.0")
445 (outputs '("out" "static"))
446 (source
447 (origin
448 (method url-fetch)
449 (uri (string-append "https://github.com/libtom/libtommath/releases/"
450 "download/v" version "/ltm-" version ".tar.xz"))
451 (sha256
452 (base32
453 "024xzb66abhla7kjks07ga05id9lq007cq3kxc41769m6kcp4qi9"))))
454 (build-system gnu-build-system)
455 (arguments
456 '(#:phases
457 (modify-phases %standard-phases
458 (delete 'configure) ; no configure
459 (add-after 'unpack 'prepare-build
460 (lambda _
461 ;; We want the shared library by default so force it to be the
462 ;; default makefile target.
463 (delete-file "makefile")
464 (symlink "makefile.shared" "makefile")))
465 (add-after 'install 'remove-static-library
466 (lambda* (#:key outputs #:allow-other-keys)
467 (delete-file (string-append (assoc-ref outputs "out")
468 "/lib/libtommath.a"))))
469 (replace 'check
470 (lambda* (#:key tests? test-target make-flags #:allow-other-keys)
471 (when tests?
472 (apply invoke "make" test-target make-flags)
473 (invoke "sh" "test"))))
474 (add-after 'install 'install-static-library
475 (lambda* (#:key outputs #:allow-other-keys)
476 (invoke "make" "-f" "makefile.unix" "install"
477 (string-append "PREFIX=" (assoc-ref outputs "static"))
478 (string-append "CC=" (which "gcc"))))))
479 #:test-target "test"
480 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
481 "CC=gcc")))
482 (native-inputs
483 (list libtool))
484 (home-page "https://www.libtom.net/LibTomMath/")
485 (synopsis "Portable number theoretic multiple-precision integer library")
486 (description "LibTomMath is a portable number theoretic multiple-precision
487integer library written entirely in C. It's designed to provide an API that is
488simple to work with that provides fairly efficient routines that build out of
489the box without configuration.")
490 (properties `((upstream-name . "ltm")
491 (lint-hidden-cve . ("CVE-2023-36328"))))
492 (license unlicense)))