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