Skip to content

Commit

Permalink
Include rr with sources
Browse files Browse the repository at this point in the history
  • Loading branch information
georgewsinger committed Sep 22, 2021
1 parent bdce920 commit 5a9bd5e
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 25 deletions.
70 changes: 45 additions & 25 deletions monado.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
, dbus
, eigen
, ffmpeg
, gst_all_1 # gst-plugins-base
#, gstreamer
, gst_all_1
, hidapi
, libGL
, libXau
, libXdmcp
, libXrandr
, libffi
, libjpeg
# , librealsense
# , libsurvive
, libusb1
, libuv
, libuvc
Expand All @@ -41,15 +38,15 @@
# https://gitlab.freedesktop.org/monado/monado/-/blob/master/doc/targets.md#xrt_feature_service-disabled
, serviceSupport ? true
, callPackage
# , openblas
, rr
, writeShellScriptBin
, zstd
, awscli
, libbsd
}:
let

rr = callPackage ./nix/rr/unstable.nix {};

/* Modify a stdenv so that it produces debug builds; that is,
binaries have debug info, and compiler optimisations are
disabled. */
Expand All @@ -62,14 +59,18 @@ keepDebugInfo = stdenv: stdenv //
};
stdenvDebug = keepDebugInfo stdenv;

# openblas-dev = openblas.override { stdenv = stdenvDebug; };
openblas-dev = callPackage ./openblas.nix { stdenv = stdenvDebug; };
libsurvive = callPackage ./libsurvive.nix { stdenv = stdenvDebug; openblas = openblas-dev; };
libsurvive-dev = libsurvive.overrideAttrs (oldAttrs: rec {

NIX_CFLAGS_COMPILE = toString (oldAttrs.NIX_CFLAGS_COMPILE or "") + " -ffile-prefix-map=/build/source/build/redist=. -ffile-prefix-map=/build/source/src=./result/srcs/libsurvive/src -ffile-prefix-map=/build/source/build/src=./result/srcs/libsurvive -ffile-prefix-map=/build/source/redist=redist -ffile-prefix-map=/build/source/build/src=./result/srcs/libsurvive/src -ffile-prefix-map=/build/source/build/src=. -ffile-prefix-map=/build/source/redist=./result/srcs/libsurvive/redist -ffile-prefix-map=/build/source/include/libsurvive=result/srcs/libsurvive/include/libsurvive";

});

rrSources = writeShellScriptBin "rr_sources" ''
# :<>s/openblas/*/g
RR_LOG=all:debug ./result/bin/rr sources \
--substitute=libopenblas.so.0.1.0=$PWD/result/srcs/openblas/src \
--substitute=$(basename $(readlink ${openblas-dev}/lib/libopenblas.so))=$PWD/result/srcs/openblas/src \
--substitute=$(basename $(readlink ${libsurvive-dev}/lib/libsurvive.so))=$PWD/result/srcs/libsurvive/src \
./rr/latest-trace \
> sources.txt 2>&1
'';
Expand All @@ -79,11 +80,17 @@ pernoscoSubmit = writeShellScriptBin "pernosco_submit" ''
-x \
upload \
--title $2 \
--substitute=libopenblas.so.0.1.0=$PWD/result/srcs/openblas/src \
--substitute=$(basename $(readlink ${openblas-dev}/lib/libopenblas.so))=$PWD/result/srcs/openblas/src \
--substitute=$(basename $(readlink ${libsurvive-dev}/lib/libsurvive.so))=$PWD/result/srcs/libsurvive/src \
$1 ./. \
$PWD \
$PWD/xrt \
$PWD/external \
$PWD/result/srcs \
$PWD/result/srcs/openblas/src \
${openblas-dev} \
$PWD/result/srcs/libsurvive/src \
${libsurvive-dev} \
> pernosco.txt 2>&1
'';

Expand All @@ -93,16 +100,29 @@ stdenvDebug.mkDerivation rec {
pname = "monado";
version = "21.0.0";

# src = fetchFromGitLab {
# domain = "gitlab.freedesktop.org";
# owner = pname;
# repo = pname;
# rev = "v${version}";
# sha256 = "07zxs96i3prjqww1f68496cl2xxqaidx32lpfyy0pn5am4c297zc";
# };

src = ./.;

NIX_CFLAGS_COMPILE = ''-ffile-prefix-map=/build/monado/build/src/xrt/targets/service=.
-ffile-prefix-map=/build/monado/src=./src
-ffile-prefix-map=/build/monado/build/src/xrt/auxiliary=.
-ffile-prefix-map=/build/monado/build/src/xrt/ipc=.
-ffile-prefix-map=/build/monado/build/src/xrt/targets/common=.
-ffile-prefix-map=/build/monado/build/src/xrt/state_trackers/gui=.
-ffile-prefix-map=/build/monado/build/src/xrt/auxiliary=.
-ffile-prefix-map=/build/monado/build/src/xrt/state_trackers/prober=.
-ffile-prefix-map=/build/monado/build/src/xrt/compositor=.
-ffile-prefix-map=/build/monado/build/src/xrt/auxiliary=.
-ffile-prefix-map=/build/monado/build/src/xrt/compositor=.
-ffile-prefix-map=/build/monado/build/src/xrt/targets/common=.
-ffile-prefix-map=/build/monado/build/src/xrt/drivers=.
-ffile-prefix-map=/build/monado/build/src/xrt/auxiliary=.
-ffile-prefix-map=/build/monado/build/src/xrt/auxiliary=.
-ffile-prefix-map=/build/monado/build/src/xrt/drivers=.
-ffile-prefix-map=/build/monado/build/src/xrt/auxiliary=.
-ffile-prefix-map=/build/monado/build/src/xrt/auxiliary/bindings=.
-ffile-prefix-map=/build/monado/build/src/xrt/auxiliary=.
'';

nativeBuildInputs = [
cmake
doxygen
Expand Down Expand Up @@ -130,7 +150,7 @@ stdenvDebug.mkDerivation rec {
libjpeg
libffi
# librealsense.dev - see below
libsurvive
libsurvive-dev
libusb1
libuv
libuvc
Expand Down Expand Up @@ -174,17 +194,17 @@ stdenvDebug.mkDerivation rec {

fixupPhase = ''
mkdir -p $out/srcs
ln -s ${openblas-dev.src} $out/srcs/openblas
cp -r ${openblas-dev.src} $out/srcs/openblas
cp -r ${libsurvive-dev.src} $out/srcs/libsurvive
ln -s ${rr}/bin/rr $out/bin/rr
ln -s ${rrSources}/bin/rr_sources $out/bin/rr_sources
ln -s ${pernoscoSubmit}/bin/pernosco_submit $out/bin/pernosco_submit
echo "_RR_TRACE_DIR=./rr nixGLIntel ${rr}/bin/rr record -i SIGUSR1 ./result/bin/monado-service" >> $out/bin/rr_record
chmod +x $out/bin/rr_record
echo "_RR_TRACE_DIR=./rr ${rr}/bin/rr record -i SIGUSR1 ./result/bin/monado-service" >> $out/bin/monado_rr_record
chmod +x $out/bin/monado_rr_record
echo "_RR_TRACE_DIR=./rr ${rr}/bin/rr -M replay \"\$@\"" >> $out/bin/monado_rr_replay
chmod +x $out/bin/monado_rr_replay
echo "_RR_TRACE_DIR=./rr ${rr}/bin/rr -M replay \"\$@\"" >> $out/bin/rr_replay
chmod +x $out/bin/rr_replay
'';
}
1 change: 1 addition & 0 deletions nix/rr/call.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(import ../../pinned-nixpkgs.nix {}).callPackage ./unstable.nix {}
60 changes: 60 additions & 0 deletions nix/rr/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{ lib, gcc9Stdenv, fetchFromGitHub, cmake, libpfm, zlib, pkg-config, python3Packages, which, procps, gdb, capnproto }:

gcc9Stdenv.mkDerivation rec {
version = "5.4.0";
pname = "rr";

src = fetchFromGitHub {
owner = "mozilla";
repo = "rr";
rev = version;
sha256 = "1sfldgkkmsdyaqa28i5agcykc63gwm3zjihd64g86i852w8al2w6";
};

postPatch = ''
substituteInPlace src/Command.cc --replace '_BSD_SOURCE' '_DEFAULT_SOURCE'
sed '7i#include <math.h>' -i src/Scheduler.cc
patchShebangs .
'';

# TODO: remove this preConfigure hook after 5.2.0 since it is fixed upstream
# see https://github.com/mozilla/rr/issues/2269
preConfigure = ''substituteInPlace CMakeLists.txt --replace "std=c++11" "std=c++14"'';

nativeBuildInputs = [ cmake pkg-config which ];
buildInputs = [
libpfm zlib python3Packages.python python3Packages.pexpect procps gdb capnproto
];
propagatedBuildInputs = [ gdb ]; # needs GDB to replay programs at runtime
cmakeFlags = [
"-DCMAKE_C_FLAGS_RELEASE:STRING="
"-DCMAKE_CXX_FLAGS_RELEASE:STRING="
"-Ddisable32bit=ON"
];

# we turn on additional warnings due to hardening
NIX_CFLAGS_COMPILE = "-Wno-error";

hardeningDisable = [ "fortify" ];

# FIXME
#doCheck = true;

preCheck = "export HOME=$TMPDIR";

meta = {
homepage = "https://rr-project.org/";
description = "Records nondeterministic executions and debugs them deterministically";
longDescription = ''
rr aspires to be your primary debugging tool, replacing -- well,
enhancing -- gdb. You record a failure once, then debug the
recording, deterministically, as many times as you want. Every
time the same execution is replayed.
'';

license = with lib.licenses; [ mit bsd2 ];
maintainers = with lib.maintainers; [ pierron thoughtpolice ];
platforms = lib.platforms.x86;
};
}

18 changes: 18 additions & 0 deletions nix/rr/unstable.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ callPackage, fetchFromGitHub }:

let
rr = callPackage ./. {};
in

rr.overrideAttrs (old: {
version = "unstable-2020-10-10";

src = fetchFromGitHub {
owner = "mozilla";
repo = "rr";

rev = "1817b9d440a2725eeae7ffff2764f6a102989042";
sha256 = "0m9pxhr539zarfx8kxkxa6k8xari05ylcbmrvkdbgshd5786rxpz";

};
})

0 comments on commit 5a9bd5e

Please sign in to comment.