Commit b6ace79d authored by Jonas Rembser's avatar Jonas Rembser Committed by Dmitry Kalinkin
Browse files

root: 6.36.04 -> 6.38.00

Also, don't install the `thisroot` scripts, which are meant for using
relocatable ROOT builds that are not installed with a package manager.

The hotfix introduced in NixOS#292446 to work around
root-project/root#14778 can also be removed, since the problem was fixed
upstream with root-project/root#19923
parent 696343a0
Loading
Loading
Loading
Loading
+0 −108
Original line number Diff line number Diff line
From febb61a45a40a76bdbcd320f307dcd8f14cc532b Mon Sep 17 00:00:00 2001
From: Jonas Rembser <jonas.rembser@cern.ch>
Date: Thu, 28 Aug 2025 14:07:01 +0200
Subject: [PATCH] [CMake] Build `rootcint` and `genreflex` as separate targets

This makes the CMake code more robust.

Right now, we use some `install(CODE "execute_process(COMMAND ln -f ...`
solution on unix to install `rootcint` and `genreflex`. This does not
work in all cases, either because of the usage of `\$ENV{DESTDIR}` when
`DESTDIR` is not set, or because hard links are not allowed.

Always copying `rootcling` - already in the build tree - would avoid
that problem, but by copying we risk sidestepping the CMake mechanisms
to set the RPath correctly when installing the copies, which are not
actual targets.

To make makes things simpler and more robust, this commit suggests to
build the `rootcing` and `genreflex` executables as separate targets
from the same source. The cost is very little cost in memory
(`rootcling` is only 31K, so copying two times only increases the size
of ROOTs `bin` directory by 1.5 %) and little in compile time (the extra
compile time is less than a second, not noticable in parallel builds).
---
 main/CMakeLists.txt | 69 +++++++++++++++------------------------------
 1 file changed, 23 insertions(+), 46 deletions(-)

diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt
index 7dfcd98e345..857f0df48d8 100644
--- a/main/CMakeLists.txt
+++ b/main/CMakeLists.txt
@@ -98,50 +98,27 @@ set_source_files_properties(src/rootcling.cxx PROPERTIES
   VISIBILITY_INLINES_HIDDEN "ON"
 )
 
-ROOT_EXECUTABLE(rootcling src/rootcling.cxx LIBRARIES RIO Cling Core Rint)
-
-# rootcling includes the ROOT complex header which would build the complex
-# dictionary with modules. To make sure that rootcling_stage1 builds this
-# dict before we use it, we add a dependency here.
-add_dependencies(rootcling complexDict)
-
-target_include_directories(rootcling PRIVATE
-        ${CMAKE_SOURCE_DIR}/core/metacling/res
-        ${CMAKE_SOURCE_DIR}/core/dictgen/res
-        ${CMAKE_SOURCE_DIR}/io/rootpcm/res)
-set_property(TARGET rootcling PROPERTY ENABLE_EXPORTS 1)
-if(WIN32)
-  set_target_properties(rootcling PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)
-  set_property(TARGET rootcling APPEND_STRING PROPERTY LINK_FLAGS " -STACK:4000000")
-endif()
-
-# Create aliases: rootcint, genreflex.
-if(WIN32)
-  add_custom_command(TARGET rootcling POST_BUILD
-                     COMMAND copy /y rootcling.exe rootcint.exe
-                     COMMAND copy /y rootcling.exe genreflex.exe
-                     WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-else()
-  add_custom_command(TARGET rootcling POST_BUILD
-                     COMMAND ln -f rootcling rootcint
-                     COMMAND ln -f rootcling genreflex
-                     WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-endif()
-set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
-                         "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcint;${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genreflex")
-
-if(CMAKE_HOST_UNIX)
-  install(CODE "execute_process(COMMAND ln -f rootcling rootcint WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})" COMPONENT applications)
-  install(CODE "execute_process(COMMAND ln -f rootcling genreflex WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})" COMPONENT applications)
-else()
-  if(MSVC)
-    install(PROGRAMS  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcling.exe DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications)
-    install(PROGRAMS  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcint.exe DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications)
-    install(PROGRAMS  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genreflex.exe DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications)
-  else()
-    install(PROGRAMS  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcint
-                      ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genreflex
-                      ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rlibmap
-                      DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications)
+set(rootcling_exe_names rootcling genreflex rootcint)
+
+foreach(exe_name IN LISTS rootcling_exe_names)
+  ROOT_EXECUTABLE(${exe_name} src/rootcling.cxx LIBRARIES RIO Cling Core Rint)
+
+  # rootcling includes the ROOT complex header which would build the complex
+  # dictionary with modules. To make sure that rootcling_stage1 builds this
+  # dict before we use it, we add a dependency here.
+  add_dependencies(${exe_name} complexDict)
+
+  target_include_directories(${exe_name} PRIVATE
+          ${CMAKE_SOURCE_DIR}/core/metacling/res
+          ${CMAKE_SOURCE_DIR}/core/dictgen/res
+          ${CMAKE_SOURCE_DIR}/io/rootpcm/res)
+  set_property(TARGET ${exe_name} PROPERTY ENABLE_EXPORTS 1)
+  if(WIN32)
+    set_target_properties(${exe_name} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)
+    set_property(TARGET ${exe_name} APPEND_STRING PROPERTY LINK_FLAGS " -STACK:4000000")
   endif()
-endif()
+endforeach()
+
+# To inherit the dependencies from rootcling
+add_dependencies(genreflex rootcling)
+add_dependencies(rootcint rootcint)
-- 
2.50.1
+5 −5
Original line number Diff line number Diff line
@@ -5,19 +5,19 @@
  apple-sdk,
  cmake,
  git,
  llvm_18,
  llvm_20,
  pkg-config,
  python3,
}:

stdenv.mkDerivation rec {
  pname = "clang-root";
  version = "18-20250506-01";
  version = "20-20250925-01";

  src = fetchgit {
    url = "https://github.com/root-project/llvm-project";
    rev = "refs/tags/ROOT-llvm${version}";
    hash = "sha256-8tviNWNmvIJhxF4j9Z7zMnjltTX0Ka2fN9HIgLfNAco=";
    hash = "sha256-qEoQVv/Aw9gqKSNa8ZJGqPzwXvH1yXiSOkvrUWeXI+g=";
  };

  nativeBuildInputs = [
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
    git
  ];
  buildInputs = [
    llvm_18
    llvm_20
    python3
  ];

@@ -46,7 +46,7 @@ stdenv.mkDerivation rec {
    "-DC_INCLUDE_DIRS=${lib.getDev stdenv.cc.libc}/include"
    "-DLLVM_INCLUDE_TESTS=OFF"
    "-DLLVM_LINK_LLVM_DYLIB=OFF"
    "-DLLVM_MAIN_SRC_DIR=${llvm_18.src}"
    "-DLLVM_MAIN_SRC_DIR=${llvm_20.src}"
  ]
  ++ (
    if stdenv.hostPlatform.isDarwin then
+6 −30
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
  lib,
  callPackage,
  fetchFromGitHub,
  fetchpatch,
  fetchurl,
  makeWrapper,
  writeText,
@@ -23,7 +22,7 @@
  libGL,
  libxcrypt,
  libxml2,
  llvm_18,
  llvm_20,
  lsof,
  lz4,
  xorg,
@@ -52,7 +51,7 @@

stdenv.mkDerivation (finalAttrs: {
  pname = "root";
  version = "6.36.04";
  version = "6.38.00";

  passthru = {
    tests = import ./tests { inherit callPackage; };
@@ -60,7 +59,7 @@ stdenv.mkDerivation (finalAttrs: {

  src = fetchurl {
    url = "https://root.cern.ch/download/root_v${finalAttrs.version}.source.tar.gz";
    hash = "sha256-zGNn2PVjxtSco0wJ0LU8sPQaUo22+GrxEf12dEzaRZY=";
    hash = "sha256-pEKUIsRg+DLN5RSlgN0gKx08luiRnCQ2PD1C+M9azNw=";
  };

  clad_src = fetchFromGitHub {
@@ -68,8 +67,8 @@ stdenv.mkDerivation (finalAttrs: {
    repo = "clad";
    # Make sure that this is the same tag as in the ROOT build files!
    # https://github.com/root-project/root/blob/master/interpreter/cling/tools/plugins/clad/CMakeLists.txt#L76
    rev = "refs/tags/v1.9";
    hash = "sha256-TKCRAfwdTp/uDH7rk9EE4z2hwqBybklHhhYH6hQFYpg=";
    rev = "refs/tags/v2.0";
    hash = "sha256-Oj7gGSvnGuYdggonPWjrwPn/06cD+ig3eefRh7xaiPs=";
  };

  # ROOT requires a patched version of clang
@@ -98,7 +97,7 @@ stdenv.mkDerivation (finalAttrs: {
    libtiff
    libxcrypt
    libxml2
    llvm_18
    llvm_20
    lz4
    openssl
    patchRcPathCsh
@@ -123,22 +122,6 @@ stdenv.mkDerivation (finalAttrs: {
    xorg.libXext
  ];

  patches = [
    # Backport that can be removed once ROOT is updated to 6.38.00
    (fetchpatch {
      url = "https://github.com/root-project/root/commit/8f21acb893977bc651a4c4fe5c4fa020a48d31de.patch";
      hash = "sha256-xo3BbaJRyW4Wy2eVuX1bY3FFH7Jm3vN2ZojMsVNIK2I=";
    })
    # Revert because it introduces usage of the xcrun executable from xcode:
    (fetchpatch {
      url = "https://github.com/root-project/root/commit/6bd0dbad38bb524491c5109bc408942246db8b50.patch";
      hash = "sha256-D7LZWJnGF9DtKcM8EF3KILU81cqTcZolW+HMe3fmXTw=";
      revert = true;
    })
    # Will also be integrated to ROOT 6.38.00
    ./Build-rootcint-and-genreflex-as-separate-targets.patch
  ];

  preConfigure = ''
    for path in builtins/*; do
      if [[ "$path" != "builtins/openui5" ]] && [[ "$path" != "builtins/rendercore" ]]; then
@@ -172,7 +155,6 @@ stdenv.mkDerivation (finalAttrs: {
    "-Dfitsio=OFF"
    "-Dmathmore=ON"
    "-Dsqlite=OFF"
    "-Dtmva-pymva=OFF"
    "-Dvdt=OFF"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
@@ -233,12 +215,6 @@ stdenv.mkDerivation (finalAttrs: {
    }"
  '';

  # workaround for
  # https://github.com/root-project/root/issues/14778
  env.NIX_LDFLAGS = lib.optionalString (
    !stdenv.hostPlatform.isDarwin
  ) "--version-script,${writeText "version.map" "ROOT { global: *; };"}";

  # To use the debug information on the fly (without installation)
  # add the outPath of root.debug into NIX_DEBUG_INFO_DIRS (in PATH-like format)
  # and make sure that gdb from Nixpkgs can be found in PATH.