projects/guix·blob ruby-team · refs

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