1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rocmUpdateScript,
6 pkg-config,
7 texinfo,
8 bison,
9 flex,
10 glibc,
11 zlib,
12 zstd,
13 gmp,
14 mpfr,
15 ncurses,
16 expat,
17 rocdbgapi,
18 perl,
19 python3,
20 babeltrace,
21 sourceHighlight,
22}:
23
24stdenv.mkDerivation (finalAttrs: {
25 pname = "rocgdb";
26 version = "6.3.3";
27
28 src = fetchFromGitHub {
29 owner = "ROCm";
30 repo = "ROCgdb";
31 rev = "rocm-${finalAttrs.version}";
32 hash = "sha256-Z+uk+ViLXgk5hXrIhVHRY0Kly7mktYms7M3o9Tmxv8s=";
33 };
34
35 nativeBuildInputs = [
36 pkg-config
37 texinfo # For makeinfo
38 bison
39 flex
40 perl # used in mkinstalldirs script during installPhase
41 python3
42 ];
43
44 buildInputs = [
45 zlib
46 zstd
47 gmp
48 mpfr
49 ncurses
50 expat
51 rocdbgapi
52 python3
53 babeltrace
54 sourceHighlight
55 ];
56
57 configureFlags = [
58 # Ensure we build the amdgpu target
59 "--enable-targets=${stdenv.targetPlatform.config},amdgcn-amd-amdhsa"
60 "--with-amd-dbgapi=yes"
61
62 "--with-iconv-path=${glibc.bin}"
63 "--enable-tui"
64 "--with-babeltrace=${babeltrace}"
65 "--with-python=python3"
66 "--with-system-zlib"
67 "--with-system-zstd"
68 "--enable-64-bit-bfd"
69 "--with-gmp=${gmp.dev}"
70 "--with-mpfr=${mpfr.dev}"
71 "--with-expat=${expat}"
72
73 # So the installed binary is called "rocgdb" instead on plain "gdb"
74 "--program-prefix=roc"
75
76 # Disable building many components not used or incompatible with the amdgcn target
77 "--disable-sim"
78 "--disable-gdbserver"
79 "--disable-ld"
80 "--disable-gas"
81 "--disable-gdbserver"
82 "--disable-gdbtk"
83 "--disable-gprofng"
84 "--disable-shared"
85 ];
86
87 postPatch = ''
88 for file in *; do
89 if [ -f "$file" ]; then
90 patchShebangs "$file"
91 fi
92 done
93 '';
94
95 # The source directory for ROCgdb (based on upstream GDB) contains multiple project
96 # of GNU’s toolchain (binutils and onther), we only need to install the GDB part.
97 installPhase = ''
98 make install-gdb
99 '';
100
101 env.CFLAGS = "-Wno-switch -Wno-format-nonliteral -I${zstd.dev}/include -I${zlib.dev}/include -I${expat.dev}/include -I${ncurses.dev}/include";
102 env.CXXFLAGS = finalAttrs.env.CFLAGS;
103
104 passthru.updateScript = rocmUpdateScript {
105 name = finalAttrs.pname;
106 inherit (finalAttrs.src) owner;
107 inherit (finalAttrs.src) repo;
108 };
109
110 meta = with lib; {
111 description = "ROCm source-level debugger for Linux, based on GDB";
112 homepage = "https://github.com/ROCm/ROCgdb";
113 license = licenses.gpl3Plus;
114 teams = [ teams.rocm ];
115 platforms = platforms.linux;
116 };
117})