root: enable `clad` for automatic differentiation in ROOT

Clad is a clang plugin that can be used in Cling to create gradients of
C++ functions.

It is included in ROOT via `ExternalProject_Add`:

https://github.com/root-project/root/blob/master/interpreter/cling/tools/plugins/clad/CMakeLists.txt

Clad is used for example in RooFit to create analytical gradients of
likelihoods.

+24 -1
+24 -1
pkgs/applications/science/misc/root/default.nix
··· 1 { stdenv 2 , lib 3 , callPackage 4 , fetchurl 5 , fetchpatch 6 , makeWrapper ··· 66 src = fetchurl { 67 url = "https://root.cern.ch/download/root_v${version}.source.tar.gz"; 68 hash = "sha256-MA237RtnjtL7ljXKZ1khoZRcfCED2oQAM7STCR9VcAw="; 69 }; 70 71 nativeBuildInputs = [ makeWrapper cmake pkg-config git ]; ··· 131 substituteInPlace cmake/modules/SearchInstalledSoftware.cmake \ 132 --replace 'set(lcgpackages ' '#set(lcgpackages ' 133 134 substituteInPlace interpreter/llvm-project/clang/tools/driver/CMakeLists.txt \ 135 --replace 'add_clang_symlink(''${link} clang)' "" 136 ··· 155 "-DCMAKE_INSTALL_LIBDIR=lib" 156 "-DCMAKE_INSTALL_INCLUDEDIR=include" 157 "-Dbuiltin_llvm=OFF" 158 - "-Dclad=OFF" 159 "-Dfail-on-missing=ON" 160 "-Dfitsio=OFF" 161 "-Dgnuinstall=ON"
··· 1 { stdenv 2 , lib 3 , callPackage 4 + , fetchgit 5 , fetchurl 6 , fetchpatch 7 , makeWrapper ··· 67 src = fetchurl { 68 url = "https://root.cern.ch/download/root_v${version}.source.tar.gz"; 69 hash = "sha256-MA237RtnjtL7ljXKZ1khoZRcfCED2oQAM7STCR9VcAw="; 70 + }; 71 + 72 + clad_src = fetchgit { 73 + url = "https://github.com/vgvassilev/clad"; 74 + rev = "refs/tags/v1.4"; # Make sure that this is the same tag as in the ROOT build files! 75 + hash = "sha256-OI9PaS7kQ/ewD5Soe3gG5FZdlR6qG6Y3mfHwi5dj1sI="; 76 }; 77 78 nativeBuildInputs = [ makeWrapper cmake pkg-config git ]; ··· 138 substituteInPlace cmake/modules/SearchInstalledSoftware.cmake \ 139 --replace 'set(lcgpackages ' '#set(lcgpackages ' 140 141 + # We have to bypass the connection check, because it would disable clad. 142 + # This should probably be fixed upstream with a flag to disable the 143 + # connectivity check! 144 + substituteInPlace CMakeLists.txt \ 145 + --replace 'if(NO_CONNECTION)' 'if(FALSE)' 146 + substituteInPlace interpreter/cling/tools/plugins/CMakeLists.txt \ 147 + --replace 'if(NOT DEFINED NO_CONNECTION OR NOT NO_CONNECTION)' 'if(TRUE)' 148 + # Make sure that clad is not downloaded when building 149 + substituteInPlace interpreter/cling/tools/plugins/clad/CMakeLists.txt \ 150 + --replace 'UPDATE_COMMAND ""' 'SOURCE_DIR ${clad_src} DOWNLOAD_COMMAND "" UPDATE_COMMAND ""' 151 + # Make sure that clad is finding the right llvm version 152 + substituteInPlace interpreter/cling/tools/plugins/clad/CMakeLists.txt \ 153 + --replace '-DLLVM_DIR=''${LLVM_BINARY_DIR}' '-DLLVM_DIR=${llvm_13.dev}/lib/cmake/llvm' 154 + # Fix that will also be upstream in ROOT 6.32. TODO: remove it when updating to 6.32 155 + substituteInPlace interpreter/cling/tools/plugins/clad/CMakeLists.txt \ 156 + --replace 'set(_CLAD_LIBRARY_PATH ''${clad_install_dir}/plugins/lib)' 'set(_CLAD_LIBRARY_PATH ''${CMAKE_CURRENT_BINARY_DIR}/clad-prefix/src/clad-build/lib''${LLVM_LIBDIR_SUFFIX})' 157 + 158 substituteInPlace interpreter/llvm-project/clang/tools/driver/CMakeLists.txt \ 159 --replace 'add_clang_symlink(''${link} clang)' "" 160 ··· 179 "-DCMAKE_INSTALL_LIBDIR=lib" 180 "-DCMAKE_INSTALL_INCLUDEDIR=include" 181 "-Dbuiltin_llvm=OFF" 182 "-Dfail-on-missing=ON" 183 "-Dfitsio=OFF" 184 "-Dgnuinstall=ON"