From 5a9bd5ec27bcde10fc62996968c6d18a5d1d1f9a Mon Sep 17 00:00:00 2001 From: George Singer Date: Tue, 21 Sep 2021 22:57:04 -0500 Subject: [PATCH] Include rr with sources --- monado.nix | 70 +++++++++++++++++++++++++++++---------------- nix/rr/call.nix | 1 + nix/rr/default.nix | 60 ++++++++++++++++++++++++++++++++++++++ nix/rr/unstable.nix | 18 ++++++++++++ 4 files changed, 124 insertions(+), 25 deletions(-) create mode 100644 nix/rr/call.nix create mode 100644 nix/rr/default.nix create mode 100644 nix/rr/unstable.nix diff --git a/monado.nix b/monado.nix index 87ada02d4..7f389bd67 100644 --- a/monado.nix +++ b/monado.nix @@ -11,8 +11,7 @@ , dbus , eigen , ffmpeg -, gst_all_1 # gst-plugins-base -#, gstreamer +, gst_all_1 , hidapi , libGL , libXau @@ -20,8 +19,6 @@ , libXrandr , libffi , libjpeg -# , librealsense -# , libsurvive , libusb1 , libuv , libuvc @@ -41,8 +38,6 @@ # https://gitlab.freedesktop.org/monado/monado/-/blob/master/doc/targets.md#xrt_feature_service-disabled , serviceSupport ? true , callPackage -# , openblas -, rr , writeShellScriptBin , zstd , awscli @@ -50,6 +45,8 @@ }: 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. */ @@ -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 ''; @@ -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 ''; @@ -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 @@ -130,7 +150,7 @@ stdenvDebug.mkDerivation rec { libjpeg libffi # librealsense.dev - see below - libsurvive + libsurvive-dev libusb1 libuv libuvc @@ -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 ''; } diff --git a/nix/rr/call.nix b/nix/rr/call.nix new file mode 100644 index 000000000..339510751 --- /dev/null +++ b/nix/rr/call.nix @@ -0,0 +1 @@ +(import ../../pinned-nixpkgs.nix {}).callPackage ./unstable.nix {} diff --git a/nix/rr/default.nix b/nix/rr/default.nix new file mode 100644 index 000000000..03747c9ea --- /dev/null +++ b/nix/rr/default.nix @@ -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 ' -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; + }; +} + diff --git a/nix/rr/unstable.nix b/nix/rr/unstable.nix new file mode 100644 index 000000000..25a4691a5 --- /dev/null +++ b/nix/rr/unstable.nix @@ -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"; + + }; + })