1{ lib, stdenv, fetchFromGitHub, fetchpatch
2, cmake, pkg-config, which, makeWrapper
3, libpfm, zlib, python3Packages, procps, gdb, capnproto
4}:
5
6stdenv.mkDerivation rec {
7 version = "5.7.0";
8 pname = "rr";
9
10 src = fetchFromGitHub {
11 owner = "mozilla";
12 repo = "rr";
13 rev = version;
14 hash = "sha256-n1Jbhr77bI0AXncY/RquNVSwwnnAXt31RmKtAa1/oHg=";
15 };
16
17 patches = [ ];
18
19 postPatch = ''
20 substituteInPlace src/Command.cc --replace '_BSD_SOURCE' '_DEFAULT_SOURCE'
21 sed '7i#include <math.h>' -i src/Scheduler.cc
22 sed '1i#include <ctime>' -i src/test-monitor/test-monitor.cc
23 patchShebangs .
24 '';
25
26 # With LTO enabled, linking fails with the following message:
27 #
28 # src/AddressSpace.cc:1666: undefined reference to `rr_syscall_addr'
29 # ld.bfd: bin/rr: hidden symbol `rr_syscall_addr' isn't defined
30 # ld.bfd: final link failed: bad value
31 # collect2: error: ld returned 1 exit status
32 #
33 # See also https://github.com/NixOS/nixpkgs/pull/110846
34 preConfigure = ''substituteInPlace CMakeLists.txt --replace "-flto" ""'';
35
36 nativeBuildInputs = [ cmake pkg-config which makeWrapper ];
37 buildInputs = [
38 libpfm zlib python3Packages.python python3Packages.pexpect procps gdb capnproto
39 ];
40 cmakeFlags = [
41 "-Ddisable32bit=ON"
42 ];
43
44 # we turn on additional warnings due to hardening
45 env.NIX_CFLAGS_COMPILE = "-Wno-error";
46
47 hardeningDisable = [ "fortify" ];
48
49 # FIXME
50 doCheck = false;
51
52 preCheck = "export HOME=$TMPDIR";
53
54 # needs GDB to replay programs at runtime
55 preFixup = ''
56 wrapProgram "$out/bin/rr" \
57 --prefix PATH ":" "${lib.makeBinPath [
58 gdb
59 ]}";
60 '';
61
62 meta = {
63 homepage = "https://rr-project.org/";
64 description = "Records nondeterministic executions and debugs them deterministically";
65 longDescription = ''
66 rr aspires to be your primary debugging tool, replacing -- well,
67 enhancing -- gdb. You record a failure once, then debug the
68 recording, deterministically, as many times as you want. Every
69 time the same execution is replayed.
70 '';
71
72 license = with lib.licenses; [ mit bsd2 ];
73 maintainers = with lib.maintainers; [ pierron thoughtpolice ];
74 platforms = [ "i686-linux" "x86_64-linux" "aarch64-linux" ];
75 };
76}