projects/guix·blob javascript-team · refs

402 lines · 15.6 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014, 2015, 2019, 2020, 2023 Ludovic Courtès <[email protected]>
3;;; Copyright © 2015 Mark H Weaver <[email protected]>
4;;; Copyright © 2015, 2016, 2019, 2021, 2023, 2026 Efraim Flashner <[email protected]>
5;;; Copyright © 2020 Marius Bakke <[email protected]>
6;;; Copyright © 2020 Vincent Legoll <[email protected]>
7;;; Copyright © 2020, 2021, 2024 Janneke Nieuwenhuizen <[email protected]>
8;;; Copyright © 2020, 2021 Maxim Cournoyer <[email protected]>
9;;; Copyright © 2025 Zheng Junjie <[email protected]>
10;;; Copyright © 2025 Andreas Enge <[email protected]>
11;;; Copyright © 2026 David Elsing <[email protected]>
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 gdb)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages bash)
31 #:use-module (gnu packages bison)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages cross-base)
34 #:use-module (gnu packages dejagnu)
35 #:use-module (gnu packages compiler-tools)
36 #:use-module (gnu packages guile)
37 #:use-module (gnu packages hurd)
38 #:use-module (gnu packages llvm)
39 #:use-module (gnu packages multiprecision)
40 #:use-module (gnu packages ncurses)
41 #:use-module (gnu packages pciutils)
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages pretty-print)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages readline)
47 #:use-module (gnu packages rocm)
48 #:use-module (gnu packages texinfo)
49 #:use-module (gnu packages xml)
50 #:use-module (guix download)
51 #:use-module (guix gexp)
52 #:use-module (guix git-download)
53 #:use-module ((guix licenses) #:prefix license:)
54 #:use-module (guix packages)
55 #:use-module (guix utils)
56 #:use-module (guix build-system cmake)
57 #:use-module (guix build-system gnu)
58 #:use-module ((guix build utils) #:select (alist-replace))
59 #:use-module (srfi srfi-1))
60
61
62(define (gdb-python-config pkg-config)
63 "Return a script to satisfy gdb to enable python support."
64 ;; based on https://www.sourceware.org/gdb/wiki/CrossCompilingWithPythonSupport
65 (program-file "gdb-python-config"
66 #~(begin
67 (use-modules (ice-9 match))
68 (let ((pkg-config #$pkg-config))
69 (match (command-line)
70 ((_ _ "--includes")
71 (execlp pkg-config pkg-config
72 "python3-embed" "--cflags"))
73 ((_ _ "--ldflags")
74 (execlp pkg-config pkg-config
75 "python3-embed" "--libs"))
76 ((_ _ "--exec-prefix")
77 (execlp pkg-config pkg-config
78 "python3-embed" "--variable=exec_prefix"))
79 (_ (exit 1)))))))
80
81(define-public gdb-17
82 (package
83 (name "gdb")
84 (version "17.2")
85 (source (origin
86 (method url-fetch)
87 (uri (string-append "mirror://gnu/gdb/gdb-"
88 version ".tar.xz"))
89 (sha256
90 (base32
91 "1312lccryan1jfkjwkbw9mpxgyfnmlr8dj4lbkxx3cz4f86nq0qw"))))
92 (build-system gnu-build-system)
93 (outputs '("out" "debug"))
94 (arguments
95 (list
96 #:tests? #f ;FIXME: 217 unexpected failures
97 #:out-of-source? #t
98 #:modules `((srfi srfi-1)
99 ,@%default-gnu-modules)
100 #:configure-flags
101 #~(list
102 #$@(if (this-package-input "zlib")
103 '("--with-system-zlib")
104 '())
105 #$@(if (and (this-package-input "python-wrapper")
106 (%current-target-system))
107 #~((string-append "--with-python="
108 #+(gdb-python-config (pkg-config-for-target))))
109 #~())
110 #$@(if (target-hurd64?)
111 #~("--enable-targets=i586-pc-gnu,x86_64-pc-gnu")
112 #~()))
113 #:phases #~(modify-phases %standard-phases
114 ;; The following phase only applies to gdb@12, which
115 ;; inherits from this package. Remove it when removing
116 ;; gdb@12.
117 #$@(if (target-aarch64?)
118 #~((add-after 'unpack 'patch-aarch64
119 (lambda _
120 (substitute* "sim/aarch64/cpustate.h"
121 (("aarch64_get_CPSR_bits \\(sim_cpu \\*, uint32_t\\)")
122 "aarch64_get_CPSR_bits (sim_cpu *, FlagMask)")))))
123 #~())
124 #$@(if (%current-target-system)
125 #~((add-after 'unpack 'enable-guile
126 (lambda* (#:key native-inputs #:allow-other-keys)
127 (setenv "ac_cv_guild_program_name" (which "guild"))
128 (setenv "ac_cv_path_pkg_config_prog_path"
129 (which #$(pkg-config-for-target))))))
130 #~())
131 (add-after 'unpack 'patch-paths
132 (lambda* (#:key inputs #:allow-other-keys)
133 (let ((sh (string-append (assoc-ref inputs "bash")
134 "/bin/sh")))
135 (substitute* '("gdb/ser-pipe.c"
136 "gdbsupport/pathstuff.cc")
137 (("\"/bin/sh\"")
138 (format #f "~s" sh))))))
139 (add-after 'configure 'post-configure
140 (lambda _
141 (for-each patch-makefile-SHELL
142 (find-files "." "Makefile\\.in"))))
143 (add-after 'install 'remove-libs-already-in-binutils
144 (lambda* (#:key native-inputs inputs outputs
145 #:allow-other-keys)
146 ;; Like Binutils, GDB installs libbfd, libopcodes, etc.
147 ;; However, this leads to collisions when both are
148 ;; installed, and really is none of its business,
149 ;; conceptually. So remove them.
150 (let* ((binutils (or (assoc-ref inputs "binutils")
151 (assoc-ref native-inputs "binutils")))
152 (out (assoc-ref outputs "out"))
153 (files1 (with-directory-excursion binutils
154 (append (find-files "lib")
155 (find-files "include"))))
156 (files2 (with-directory-excursion out
157 (append (find-files "lib")
158 (find-files "include"))))
159 (common (lset-intersection string=?
160 files1 files2)))
161 (with-directory-excursion out
162 (for-each delete-file common))))))))
163 (inputs
164 `(("bash" ,bash)
165 ("expat" ,expat)
166 ("mpfr" ,mpfr)
167 ("gmp" ,gmp)
168 ("readline" ,readline)
169 ("ncurses" ,ncurses)
170 ("guile" ,guile-3.0)
171 ("python-wrapper" ,python-wrapper)
172 ("source-highlight" ,source-highlight)
173 ("zlib" ,zlib)
174
175 ;; Allow use of XML-formatted syscall information. This enables 'catch
176 ;; syscall' and similar commands.
177 ("libxml2" ,libxml2)
178
179 ;; The Hurd needs -lshouldbeinlibc.
180 ,@(if (target-hurd?)
181 `(("hurd" ,hurd))
182 '())))
183 (native-inputs
184 `(("texinfo" ,texinfo)
185 ("dejagnu" ,dejagnu)
186 ("pkg-config" ,pkg-config)
187 ,@(if (%current-target-system)
188 `(("guile" ,guile-3.0))
189 '())
190 ,@(if (target-hurd?)
191 ;; When cross-compiling from x86_64-linux, make sure to use a
192 ;; 32-bit MiG because we assume target i586-pc-gnu.
193 `(("mig" ,(if (%current-target-system)
194 (cross-mig (%current-target-system))
195 mig)))
196 '())))
197 ;; TODO: Add support for the GDB_DEBUG_FILE_DIRECTORY environment
198 ;; variable in GDB itself instead of relying on some glue code in
199 ;; the Guix-provided .gdbinit file.
200 (native-search-paths (list (search-path-specification
201 (variable "GDB_DEBUG_FILE_DIRECTORY")
202 (files '("lib/debug")))))
203 (home-page "https://www.gnu.org/software/gdb/")
204 (synopsis "The GNU debugger")
205 (description
206 "GDB is the GNU debugger. With it, you can monitor what a program is
207doing while it runs or what it was doing just before a crash. It allows you
208to specify the runtime conditions, to define breakpoints, and to change how
209the program is running to try to fix bugs. It can be used to debug programs
210written in C, C++, Ada, Objective-C, Pascal and more.")
211 (license license:gpl3+)))
212
213(define-public gdb/pinned
214 ;; This is the fixed version that packages depend on. Update it rarely
215 ;; enough to avoid massive rebuilds.
216 (package
217 (inherit gdb-17)
218 (version "17.1")
219 (source (origin
220 (method url-fetch)
221 (uri (string-append "mirror://gnu/gdb/gdb-"
222 version ".tar.xz"))
223 (sha256
224 (base32
225 "0xnqqv3j463r5rnfmblj3zwhf0l0lyy4bp1zaid8zxn9fignz68l"))))
226 ;; XXX: Remove this when updating gdb/pinned
227 (inputs
228 (modify-inputs inputs
229 (delete "zlib")))
230 (properties `((hidden? . #t)))))
231
232(define-public gdb-15
233 (package
234 (inherit gdb-17)
235 (version "15.2")
236 (source (origin
237 (method url-fetch)
238 (uri (string-append "mirror://gnu/gdb/gdb-"
239 version ".tar.xz"))
240 (patches (search-patches "gdb-hurd64.patch"))
241 (sha256
242 (base32
243 "0k9i8mizg4hby020k53kqmc835pajh9c8d5klv5s1ddm6p6hqdc3"))))))
244
245(define-public gdb-16
246 (package
247 (inherit gdb-17)
248 (version "16.3")
249 (source (origin
250 (method url-fetch)
251 (uri (string-append "mirror://gnu/gdb/gdb-"
252 version ".tar.xz"))
253 (patches (search-patches "gdb-16-hurd64.patch"))
254 (sha256
255 (base32
256 "1i940b04404xr44xc66c4r4nk091czqz7zzrmhbpk64aaaax1z5w"))))))
257
258(define-public gdb
259 ;; The "default" version.
260 gdb-17)
261
262(define-public gdb-multiarch
263 (package/inherit gdb
264 (name "gdb-multiarch")
265 (arguments
266 (substitute-keyword-arguments arguments
267 ((#:configure-flags flags '())
268 #~(cons* "--enable-targets=all"
269 "--enable-multilib"
270 "--enable-interwork"
271 "--enable-languages=c,c++"
272 "--disable-nls"
273 #$flags))))
274 (synopsis "The GNU debugger (with all architectures enabled)")))
275
276(define-public gdb-minimal
277 (package/inherit gdb
278 (name "gdb-minimal")
279 (inputs (fold alist-delete (package-inputs gdb)
280 '("libxml2" "ncurses" "python-wrapper" "source-highlight")))))
281
282(define-public gdb-minimal-15
283 (package/inherit gdb-15
284 (name "gdb-minimal")
285 (inputs (fold alist-delete (package-inputs gdb-15)
286 '("libxml2" "ncurses" "python-wrapper" "source-highlight")))))
287
288(define-public avr-gdb
289 (package/inherit gdb-15
290 (name "avr-gdb")
291 (arguments
292 (substitute-keyword-arguments arguments
293 ((#:configure-flags flags '())
294 #~(cons* "--target=avr"
295 "--disable-nls"
296 "--enable-languages=c,c++"
297 "--with-system-readline"
298 "--enable-source-highlight"
299 #$flags))))
300 (synopsis "The GNU Debugger for AVR")
301 (description
302 "GDB is the GNU debugger. With it, you can monitor what a program is
303doing while it runs or what it was doing just before a crash. It allows you
304to specify the runtime conditions, to define breakpoints, and to change how
305the program is running to try to fix bugs.
306
307This variant of GDB can be used to debug programs written for the AVR
308microcontroller architecture.")))
309
310;; This must match '%rocm-version' in the following files:
311;; - rocm.scm
312;; - rocm-libs.scm
313;; - rocm-tools.scm
314(define %rocm-gdb-version "7.1.1")
315
316(define-public rocdbgapi
317 (package
318 (name "rocdbgapi")
319 (version %rocm-gdb-version)
320 (source
321 (origin
322 (method git-fetch)
323 (uri (git-reference
324 (url (string-append "https://github.com/ROCm/rocdbgapi"))
325 (commit (string-append "rocm-" version))))
326 (file-name (git-file-name name version))
327 (sha256
328 (base32
329 "1lq7xkfpzy9iyvp4zgqsqzvxrm5h00nq74pr999dp106zhj1j1j7"))))
330 (build-system cmake-build-system)
331 (arguments
332 (list
333 #:tests? #f ; no tests
334 #:build-type "Release"
335 #:phases
336 #~(modify-phases %standard-phases
337 (add-after 'unpack 'set-pci.ids-path
338 (lambda _
339 (substitute* "CMakeLists.txt"
340 (("/usr/share/hwdata")
341 (string-append
342 #$(this-package-native-input "hwdata")
343 "/share/hwdata"))))))))
344 (inputs
345 (list rocm-comgr
346 rocr-runtime))
347 (native-inputs
348 (list hwdata
349 rocm-cmake))
350 (synopsis "AMD Debugger API")
351 (description "The AMD Debugger API is a library that provides all
352the support necessary for a debugger and other tools to perform low
353level control of the execution and inspection of execution state of
354AMD's commercially available GPU architectures.")
355 (home-page "https://github.com/ROCm/ROCdbgapi")
356 (license license:expat)))
357
358(define-public rocgdb
359 (package
360 (inherit gdb)
361 (name "rocgdb")
362 (version %rocm-gdb-version)
363 (source
364 (origin
365 (method git-fetch)
366 (uri (git-reference
367 (url (string-append "https://github.com/ROCm/rocgdb"))
368 (commit (string-append "rocm-" version))))
369 (file-name (git-file-name name version))
370 (sha256
371 (base32
372 "1msxz5xnm6fl2p9hzjnkaayd8x3dc0dp34ff60asr8mgxwxlcd9c"))))
373 (inputs
374 (modify-inputs inputs
375 (prepend rocdbgapi)))
376 (native-inputs
377 (modify-inputs native-inputs
378 (prepend bison flex perl)))
379 (arguments
380 (substitute-keyword-arguments arguments
381 ((#:configure-flags _ '())
382 ''("--program-prefix=roc"
383 "--disable-binutils"
384 "--disable-gprofng"
385 "--disable-gprof"
386 "--enable-tui"
387 "--enable-64-bit-bfd"
388 "--enable-targets=x86_64-linux-gnu,amdgcn-amd-amdhsa"
389 "--with-system-readline"
390 "--with-expat"
391 "--with-system-zlib"
392 "--with-lzma"
393 "--disable-gdbtk"
394 "--disable-ld"
395 "--disable-gas"
396 "--disable-gdbserver"
397 "--disable-sim"))))
398 (synopsis "ROCm source-level debugger for Linux based on GDB")
399 (description "The AMD ROCm Debugger (ROCgdb) is the AMD
400source-level debugger for Linux, based on the GNU Debugger (GDB).")
401 (home-page "https://github.com/ROCm/ROCgdb")
402 (license license:gpl3+)))