gnu: lightning: Fix build.
[jackhill/guix/guix.git] / gnu / packages / assembly.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
3 ;;; Copyright © 2013, 2015 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
5 ;;; Copyright © 2016, 2020, 2021 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2017–2021 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2019 Guy Fleury Iteriteka <hoonandon@gmail.com>
8 ;;; Copyright © 2019 Andy Tai <atai@atai.org>
9 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
10 ;;; Copyright © 2020 Christine Lemmer-Webber <cwebber@dustycloud.org>
11 ;;; Copyright © 2020 B. Wilson <elaexuotee@wilsonb.com>
12 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
13 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
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 assembly)
31 #:use-module (guix build-system meson)
32 #:use-module (guix build-system cmake)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix download)
35 #:use-module (guix git-download)
36 #:use-module ((guix licenses) #:prefix license:)
37 #:use-module (guix packages)
38 #:use-module (gnu packages)
39 #:use-module (gnu packages admin)
40 #:use-module (gnu packages autotools)
41 #:use-module (gnu packages base)
42 #:use-module (gnu packages bison)
43 #:use-module (gnu packages compression)
44 #:use-module (gnu packages flex)
45 #:use-module (gnu packages gettext)
46 #:use-module (gnu packages image)
47 #:use-module (gnu packages linux)
48 #:use-module (gnu packages man)
49 #:use-module (gnu packages perl)
50 #:use-module (gnu packages pkg-config)
51 #:use-module (gnu packages texinfo)
52 #:use-module (gnu packages python)
53 #:use-module (gnu packages sphinx)
54 #:use-module (gnu packages shells)
55 #:use-module (gnu packages xml)
56 #:use-module ((guix utils)
57 #:select (%current-system cc-for-target)))
58
59 (define-public nasm
60 (package
61 (name "nasm")
62 (version "2.15.05")
63 (source (origin
64 (method url-fetch)
65 (uri (string-append "http://www.nasm.us/pub/nasm/releasebuilds/"
66 version "/nasm-" version ".tar.xz"))
67 (sha256
68 (base32
69 "0gqand86b0r86k3h46dh560lykxmxqqywz5m55kgjfq7q4lngbrw"))))
70 (build-system gnu-build-system)
71 (native-inputs `(("perl" ,perl) ;for doc and test target
72 ("texinfo" ,texinfo)))
73 (arguments
74 `(#:test-target "test"
75 #:phases
76 (modify-phases %standard-phases
77 (add-after 'unpack 'dont-build-ps-pdf-outputs
78 (lambda _
79 (substitute* "doc/Makefile.in"
80 (("html nasmdoc.txt nasmdoc.pdf \\$\\(XZFILES\\)")
81 "html nasmdoc.txt")
82 (("\\$\\(INSTALL_DATA\\) nasmdoc.pdf")
83 "$(INSTALL_DATA)"))))
84 (add-after 'install 'install-info
85 (lambda _
86 (invoke "make" "install_doc"))))))
87 (home-page "https://www.nasm.us/")
88 (synopsis "80x86 and x86-64 assembler")
89 (description
90 "NASM, the Netwide Assembler, is an 80x86 and x86-64 assembler designed
91 for portability and modularity. It supports a range of object file formats,
92 including Linux and *BSD a.out, ELF, COFF, Mach-O, Microsoft 16-bit OBJ,
93 Windows32 and Windows64. It will also output plain binary files. Its syntax
94 is designed to be simple and easy to understand, similar to Intel's but less
95 complex. It supports all currently known x86 architectural extensions, and
96 has strong support for macros.")
97 (license license:bsd-2)))
98
99 (define-public yasm
100 (package
101 (name "yasm")
102 (version "1.3.0")
103 (source (origin
104 (method url-fetch)
105 (uri (string-append
106 "http://www.tortall.net/projects/yasm/releases/yasm-"
107 version ".tar.gz"))
108 (sha256
109 (base32
110 "0gv0slmm0qpq91za3v2v9glff3il594x5xsrbgab7xcmnh0ndkix"))))
111 (build-system gnu-build-system)
112 (arguments
113 '(#:parallel-tests? #f)) ; Some tests fail
114 ; non-deterministically when run in
115 ; parallel
116 (inputs
117 `(("python" ,python-wrapper)
118 ("xmlto" ,xmlto)))
119 (home-page "https://yasm.tortall.net/")
120 (synopsis "Rewrite of the NASM assembler")
121 (description
122 "Yasm is a complete rewrite of the NASM assembler.
123
124 Yasm currently supports the x86 and AMD64 instruction sets, accepts NASM
125 and GAS assembler syntaxes, outputs binary, ELF32, ELF64, 32 and 64-bit
126 Mach-O, RDOFF2, COFF, Win32, and Win64 object formats, and generates source
127 debugging information in STABS, DWARF 2, and CodeView 8 formats.")
128 (license (license:non-copyleft "file://COPYING"
129 "See COPYING in the distribution."))))
130
131 (define-public lightning
132 (package
133 (name "lightning")
134 (version "2.1.3")
135 (source (origin
136 (method url-fetch)
137 (uri (string-append "mirror://gnu/lightning/lightning-"
138 version ".tar.gz"))
139 (sha256
140 (base32
141 "1jgxbq2cm51dzi3zhz38mmgwdcgs328mfl8iviw8dxn6dn36p1gd"))))
142 (build-system gnu-build-system)
143 (native-inputs `(("zlib" ,zlib)))
144 (arguments
145 ;; Some tests fail when run in parallel.
146 `(#:parallel-tests? #f))
147 (synopsis "Library for generating assembly code at runtime")
148 (description
149 "GNU Lightning is a library that generates assembly language code at
150 run-time. Thus, it is useful in creating Just-In-Time compilers. It
151 abstracts over the target CPU by exposing a standardized RISC instruction set
152 to the clients.")
153 (home-page "https://www.gnu.org/software/lightning/")
154 (license license:gpl3+)))
155
156 (define-public simde
157 (package
158 (name "simde")
159 (version "0.7.2")
160 (source
161 (origin
162 (method git-fetch)
163 (uri (git-reference
164 (url "https://github.com/simd-everywhere/simde")
165 (commit (string-append "v" version))))
166 (file-name (git-file-name name version))
167 (sha256
168 (base32 "0xkf21gbkgz6zlxabkmgwvy7py6cdnfqx9aplj90gz25gzrr1mkb"))))
169 (build-system meson-build-system)
170 ;; We really want this for the headers, and the tests require a bundled library.
171 (arguments '(#:configure-flags '("-Dtests=false")))
172 (synopsis "Implementations of SIMD instruction sets for foreign systems")
173 (description "The SIMDe header-only library provides fast, portable
174 implementations of SIMD intrinsics on hardware which doesn't natively support
175 them, such as calling SSE functions on ARM. There is no performance penalty if
176 the hardware supports the native implementation (e.g., SSE/AVX runs at full
177 speed on x86, NEON on ARM, etc.).")
178 (home-page "https://simd-everywhere.github.io/blog/")
179 (license license:expat)))
180
181 (define-public fasm
182 (package
183 (name "fasm")
184 (version "1.73.27")
185 (source
186 (origin
187 (method url-fetch)
188 (uri (string-append "https://flatassembler.net/fasm-"
189 version ".tgz"))
190 (sha256
191 (base32 "1cghiks49ql77b9l4mwrnlk76kai0fm0z22j71kbdlxngwvlh0b8"))))
192 (build-system gnu-build-system)
193 (arguments
194 `(#:tests? #f ; no tests exist
195 #:strip-binaries? #f ; fasm has no sections
196 #:phases
197 (modify-phases %standard-phases
198 (delete 'configure) ; no "configure" script
199 (replace 'build
200 (lambda _
201 (chdir "source/Linux/")
202 (if (string=? ,(%current-system) "x86_64-linux")
203 ;; Use pre-compiled binaries in top-level directory to build
204 ;; fasm.
205 (invoke "../../fasm.x64" "fasm.asm")
206 (invoke "../../fasm" "fasm.asm"))))
207 (replace 'install
208 (lambda _
209 (let ((out (assoc-ref %outputs "out")))
210 (install-file "fasm" (string-append out "/bin")))
211 #t)))))
212 (supported-systems '("x86_64-linux" "i686-linux"))
213 (synopsis "Assembler for x86 processors")
214 (description
215 "@acronym{FASM, the Flat ASseMbler} is an assembler that supports x86 and
216 IA-64 Intel architectures. It does multiple passes to optimize machine code.
217 It has macro abilities and focuses on operating system portability.")
218 (home-page "https://flatassembler.net/")
219 (license license:bsd-2)))
220
221 (define-public dev86
222 (package
223 (name "dev86")
224 (version "0.16.21")
225 (source (origin
226 (method url-fetch)
227 (uri (string-append "http://v3.sk/~lkundrak/dev86/Dev86src-"
228 version ".tar.gz"))
229 (sha256
230 (base32
231 "154dyr2ph4n0kwi8yx0n78j128kw29rk9r9f7s2gddzrdl712jr3"))))
232 (build-system gnu-build-system)
233 (arguments
234 `(#:parallel-build? #f ; They use submakes wrong
235 #:make-flags (list ,(string-append "CC=" (cc-for-target))
236 (string-append "PREFIX="
237 (assoc-ref %outputs "out")))
238 #:system "i686-linux" ; Standalone ld86 had problems otherwise
239 #:tests? #f ; No tests exist
240 #:phases
241 (modify-phases %standard-phases
242 (delete 'configure)
243 (add-before 'install 'mkdir
244 (lambda* (#:key outputs #:allow-other-keys)
245 (let ((out (assoc-ref outputs "out")))
246 (mkdir-p (string-append out "/bin"))
247 (mkdir-p (string-append out "/man/man1"))
248 #t))))))
249 (synopsis "Intel 8086 (primarily 16-bit) assembler, C compiler and
250 linker")
251 (description "This package provides a Intel 8086 (primarily 16-bit)
252 assembler, a C compiler and a linker. The assembler uses Intel syntax
253 (also Intel order of operands).")
254 (home-page "https://github.com/jbruchon/dev86")
255 (supported-systems '("i686-linux" "x86_64-linux"))
256 (license license:gpl2+)))
257
258 (define-public libjit
259 (let ((commit "554c9f5c750daa6e13a6a5cd416873c81c7b8226"))
260 (package
261 (name "libjit")
262 (version "0.1.4")
263 (source (origin
264 (method git-fetch)
265 (uri (git-reference
266 (url "https://git.savannah.gnu.org/r/libjit.git")
267 (commit commit)))
268 (file-name (git-file-name name version))
269 (sha256
270 (base32
271 "0p6wklslkkp3s4aisj3w5a53bagqn5fy4m6088ppd4fcfxgqkrcd"))))
272 (build-system gnu-build-system)
273 (native-inputs
274 `(("autoconf" ,autoconf)
275 ("automake" ,automake)
276 ("bison" ,bison)
277 ("flex" ,flex)
278 ("help2man" ,help2man)
279 ("gettext" ,gettext-minimal)
280 ("libtool" ,libtool)
281 ("makeinfo" ,texinfo)
282 ("pkg-config" ,pkg-config)))
283 (home-page "https://www.gnu.org/software/libjit/")
284 (synopsis "Just-In-Time compilation library")
285 (description
286 "GNU libjit is a library that provides generic Just-In-Time compiler
287 functionality independent of any particular bytecode, language, or
288 runtime")
289 (license license:lgpl2.1+))))
290
291 (define-public rgbds
292 (package
293 (name "rgbds")
294 (version "0.4.2")
295 (source (origin
296 (method git-fetch)
297 (uri (git-reference
298 (url "https://github.com/gbdev/rgbds")
299 (commit (string-append "v" version))))
300 (file-name (git-file-name name version))
301 (sha256
302 (base32
303 "0lygj7jzjlq4w0mkiir7ycysrd1p1akyvzrppjcchja05mi8wy9p"))))
304 (build-system gnu-build-system)
305 (arguments
306 `(#:phases
307 (modify-phases %standard-phases
308 (delete 'configure)
309 (add-after 'unpack 'patch-pkg-config
310 (lambda _
311 (substitute* "Makefile"
312 (("pkg-config")
313 (or (which "pkg-config")
314 (string-append ,(%current-target-system)
315 "-pkg-config"))))
316 #t))
317 (replace 'check
318 (lambda _
319 (with-directory-excursion "test/asm"
320 (invoke "./test.sh"))
321 (with-directory-excursion "test/link"
322 (invoke "./test.sh")))))
323 #:make-flags `(,(string-append "CC=" ,(cc-for-target))
324 ,(string-append "PREFIX="
325 (assoc-ref %outputs "out")))))
326 (native-inputs
327 `(("bison" ,bison)
328 ("flex" ,flex)
329 ("pkg-config" ,pkg-config)
330 ("util-linux" ,util-linux)))
331 (inputs
332 `(("libpng" ,libpng)))
333 (home-page "https://github.com/gbdev/rgbds")
334 (synopsis "Rednex Game Boy Development System")
335 (description
336 "RGBDS (Rednex Game Boy Development System) is an assembler/linker
337 package for the Game Boy and Game Boy Color. It consists of:
338 @itemize @bullet
339 @item rgbasm (assembler)
340 @item rgblink (linker)
341 @item rgbfix (checksum/header fixer)
342 @item rgbgfx (PNG-to-Game Boy graphics converter)
343 @end itemize")
344 (license license:expat)))
345
346 (define-public wla-dx
347 (package
348 (name "wla-dx")
349 (version "9.12")
350 (source (origin
351 (method git-fetch)
352 (uri (git-reference
353 (url "https://github.com/vhelin/wla-dx")
354 (commit (string-append "v" version))))
355 (file-name (git-file-name name version))
356 (sha256
357 (base32
358 "1wlbqv2rgk9q6m9an1mi0i29250zl8lw7zipki2bbi9mczpyczli"))))
359 (build-system cmake-build-system)
360 (native-inputs
361 `(("sphinx" ,python-sphinx))) ; to generate man pages
362 (arguments
363 `(#:tests? #f)) ; no tests
364 (home-page "https://github.com/vhelin/wla-dx")
365 (synopsis "Assemblers for various processors")
366 (description "WLA DX is a set of tools to assemble assembly files to
367 object or library files (@code{wla-ARCH}) and link them together (@code{wlalink}).
368 Supported architectures are:
369
370 @itemize @bullet
371 @item z80
372 @item gb (z80-gb)
373 @item 6502
374 @item 65c02
375 @item 6510
376 @item 65816
377 @item 6800
378 @item 6801
379 @item 6809
380 @item 8008
381 @item 8080
382 @item huc6280
383 @item spc700
384 @end itemize")
385 (license license:gpl2)))
386
387 (define-public xa
388 (package
389 (name "xa")
390 (version "2.3.11")
391 (source (origin
392 (method url-fetch)
393 (uri (string-append "https://www.floodgap.com/retrotech/xa"
394 "/dists/xa-" version ".tar.gz"))
395 (sha256
396 (base32
397 "0b81r7mvzqxgnbbmhixcnrf9nc72v1nqaw19k67221g3k561dwij"))))
398 (build-system gnu-build-system)
399 (arguments
400 `(#:tests? #f ; TODO: custom test harness, not sure how it works
401 #:phases
402 (modify-phases %standard-phases
403 (delete 'configure)) ; no "configure" script
404 #:make-flags (list (string-append "DESTDIR=" (assoc-ref %outputs "out")))))
405 (native-inputs `(("perl" ,perl)))
406 (home-page "https://www.floodgap.com/retrotech/xa/")
407 (synopsis "Two-pass portable cross-assembler")
408 (description
409 "xa is a high-speed, two-pass portable cross-assembler.
410 It understands mnemonics and generates code for NMOS 6502s (such
411 as 6502A, 6504, 6507, 6510, 7501, 8500, 8501, 8502 ...),
412 CMOS 6502s (65C02 and Rockwell R65C02) and the 65816.")
413 (license license:gpl2)))
414
415 (define-public armips
416 (package
417 (name "armips")
418 (version "0.11.0")
419 (source
420 (origin
421 (method git-fetch)
422 (uri (git-reference
423 (url "https://github.com/Kingcom/armips")
424 (commit (string-append "v" version))))
425 (file-name (git-file-name name version))
426 (sha256
427 (base32 "1c4dhjkvynqn9xm2vcvwzymk7yg8h25alnawkz4z1dnn1z1k3r9g"))))
428 (build-system cmake-build-system)
429 (arguments
430 `(#:phases
431 (modify-phases %standard-phases
432 (replace 'check
433 (lambda* (#:key inputs #:allow-other-keys)
434 (invoke "./armipstests" "../source/Tests")))
435 (replace 'install
436 (lambda* (#:key outputs #:allow-other-keys)
437 (install-file "armips" (string-append (assoc-ref outputs "out")
438 "/bin"))
439 #t)))))
440 (home-page "https://github.com/Kingcom/armips")
441 (synopsis "Assembler for various ARM and MIPS platforms")
442 (description
443 "armips is an assembler with full support for the MIPS R3000, MIPS R4000,
444 Allegrex and RSP instruction sets, partial support for the EmotionEngine
445 instruction set, as well as complete support for the ARM7 and ARM9 instruction
446 sets, both THUMB and ARM mode.")
447 (license license:expat)))
448
449 (define-public intel-xed
450 (package
451 (name "intel-xed")
452 (version "12.0.1")
453 (source
454 (origin
455 (method git-fetch)
456 (uri (git-reference
457 (url "https://github.com/intelxed/xed")
458 (commit version)))
459 (sha256 (base32 "07zfff8zf29c2n0wal87hiqfq3cwcjn80zz78mz0nyjfj09nd39f"))
460 (file-name (git-file-name name version))
461 (patches (search-patches "intel-xed-fix-nondeterminism.patch"))))
462 (build-system gnu-build-system)
463 (native-inputs
464 `(("python" ,python-wrapper)
465 ("tcsh" ,tcsh)
466 ;; As of the time of writing this comment, mbuild does not exist in the
467 ;; Python Package Index and seems to only be used by intel-xed, so we
468 ;; opt to include it here instead of packaging separately. Note also
469 ;; that the git repository contains no version tags, so we directly
470 ;; reference the "version" variable from setup.py instead.
471 ("mbuild"
472 ,(let ((name "mbuild")
473 (version "0.2496"))
474 (origin
475 (method git-fetch)
476 (uri (git-reference
477 (url "https://github.com/intelxed/mbuild")
478 (commit "3de3f0d753c11dbe634bec611d4cc13f74768e4f")))
479 (sha256
480 (base32
481 "0z8hdhpmk8y5c9429p2yns9daswnffbprni9czkq3vij8f58lkg4"))
482 (file-name (git-file-name name version)))))))
483 (outputs '("out" "lib"))
484 (arguments
485 `(#:phases
486 ;; Upstream uses the custom Python build tool `mbuild', so we munge
487 ;; gnu-build-system to fit. The build process for this package is
488 ;; documented at https://intelxed.github.io/build-manual/.
489 (let* ((build-dir "build")
490 (kit-dir "kit"))
491 (modify-phases %standard-phases
492 (delete 'configure)
493 (replace 'build
494 (lambda* (#:key inputs #:allow-other-keys)
495 (let ((mbuild (assoc-ref inputs "mbuild")))
496 (setenv "PYTHONPATH" mbuild)
497 (invoke "./mfile.py"
498 (string-append "--build-dir=" build-dir)
499 (string-append "--install-dir=" kit-dir)
500 "examples"
501 "doc"
502 "install"))))
503 (replace 'check
504 (lambda _
505 ;; Skip broken test group `tests/tests-avx512pf'.
506 (invoke "tests/run-cmd.py"
507 (string-append "--build-dir=" kit-dir "/bin")
508 "--tests" "tests/tests-base"
509 "--tests" "tests/tests-avx512"
510 "--tests" "tests/tests-cet"
511 "--tests" "tests/tests-via"
512 "--tests" "tests/tests-syntax"
513 "--tests" "tests/tests-xop")))
514 (replace 'install
515 (lambda* (#:key outputs #:allow-other-keys)
516 (let* ((out (assoc-ref outputs "out"))
517 (lib (assoc-ref outputs "lib")))
518 (copy-recursively (string-append kit-dir "/bin")
519 (string-append out "/bin"))
520 (copy-recursively (string-append kit-dir "/include")
521 (string-append lib "/include"))
522 (copy-recursively (string-append kit-dir "/lib")
523 (string-append lib "/lib")))))))))
524 (home-page "https://intelxed.github.io/")
525 (synopsis "Encoder and decoder for x86 (IA32 and Intel64) instructions")
526 (description "The Intel X86 Encoder Decoder (XED) is a software library and
527 for encoding and decoding X86 (IA32 and Intel64) instructions. The decoder
528 takes sequences of 1-15 bytes along with machine mode information and produces
529 a data structure describing the opcode, operands, and flags. The encoder takes
530 a similar data structure and produces a sequence of 1 to 15 bytes. Disassembly
531 is essentially a printing pass on the data structure.
532
533 The library and development files are under the @code{lib} output, with a
534 family of command line utility wrappers in the default output. Each of the cli
535 tools is named like @code{xed*}. Documentation for the cli tools is sparse, so
536 this is a case where ``the code is the documentation.''")
537 (license license:asl2.0)))