about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorTom McLaughlin <tom@codedown.io>2024-04-08 21:37:04 -0700
committerGitHub <noreply@github.com>2024-04-09 06:37:04 +0200
commit886dd8d2fa8f38955d5df2871455716651a34a0f (patch)
tree4db76d9ce9bd22201526e20570377e01ed568a56 /pkgs
parent0dca19054c663a0cf3b471be3c3079acfd623924 (diff)
cling: 0.9 -> 1.0 (#284865)
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/interpreters/cling/default.nix62
-rw-r--r--pkgs/development/interpreters/cling/fix-llvm-dylib-usage.patch24
-rw-r--r--pkgs/development/interpreters/cling/fix-llvm-include.patch27
3 files changed, 29 insertions, 84 deletions
diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix
index ed204c8863f67..08909063ce46f 100644
--- a/pkgs/development/interpreters/cling/default.nix
+++ b/pkgs/development/interpreters/cling/default.nix
@@ -4,7 +4,7 @@
 , git
 , lib
 , libffi
-, llvmPackages_9
+, llvmPackages_13
 , makeWrapper
 , ncurses
 , python3
@@ -34,46 +34,40 @@
 let
   stdenv = clangStdenv;
 
-  # The LLVM 9 headers have a couple bugs we need to patch
-  fixedLlvmDev = runCommand "llvm-dev-${llvmPackages_9.llvm.version}" { buildInputs = [git]; } ''
-    mkdir $out
-    cp -r ${llvmPackages_9.llvm.dev}/include $out
-    cd $out
-    chmod -R u+w include
-    git apply ${./fix-llvm-include.patch}
-  '';
+  # The patched clang lives in the LLVM megarepo
+  clangSrc = fetchFromGitHub {
+    owner = "root-project";
+    repo = "llvm-project";
+    # cling-llvm13 branch
+    rev = "3610201fbe0352a63efb5cb45f4ea4987702c735";
+    sha256 = "sha256-Cb7BvV7yobG+mkaYe7zD2KcnPvm8/vmVATNWssklXyk=";
+    sparseCheckout = ["clang"];
+  };
 
   unwrapped = stdenv.mkDerivation rec {
     pname = "cling-unwrapped";
-    version = "0.9";
+    version = "1.0";
 
-    src = fetchgit {
-      url = "http://root.cern/git/clang.git";
-      rev = "cling-v0.9";
-      sha256 = "sha256-ft1NUIclSiZ9lN3Z3DJCWA0U9q/K1M0TKkZr+PjsFYk=";
-    };
+    src = "${clangSrc}/clang";
 
     clingSrc = fetchFromGitHub {
       owner = "root-project";
       repo = "cling";
-      rev = "v0.9";
-      sha256 = "0wx3fi19wfjcph5kclf8108i436y79ddwakrcf0lgxnnxhdjyd29";
+      rev = "v1.0";
+      sha256 = "sha256-Ye8EINzt+dyNvUIRydACXzb/xEPLm0YSkz08Xxw3xp4=";
     };
 
     prePatch = ''
       echo "add_llvm_external_project(cling)" >> tools/CMakeLists.txt
 
-      cp -r $clingSrc ./tools/cling
-      chmod -R a+w ./tools/cling
+      cp -r $clingSrc tools/cling
+      chmod -R a+w tools/cling
     '';
 
     patches = [
       ./no-clang-cpp.patch
 
-      # https://github.com/root-project/root/commit/286d96b12aad8688b9d8e4b3b5df843dcfb716a8
-      ./fix-llvm-dylib-usage.patch
-
-      ./force-install-cling-targets.patch
+      # ./force-install-cling-targets.patch
     ];
 
     nativeBuildInputs = [ python3 git cmake ];
@@ -82,12 +76,12 @@ let
     strictDeps = true;
 
     cmakeFlags = [
-      "-DLLVM_BINARY_DIR=${llvmPackages_9.llvm.out}"
-      "-DLLVM_CONFIG=${llvmPackages_9.llvm.dev}/bin/llvm-config"
-      "-DLLVM_LIBRARY_DIR=${llvmPackages_9.llvm.lib}/lib"
-      "-DLLVM_MAIN_INCLUDE_DIR=${fixedLlvmDev}/include"
-      "-DLLVM_TABLEGEN_EXE=${llvmPackages_9.llvm.out}/bin/llvm-tblgen"
-      "-DLLVM_TOOLS_BINARY_DIR=${llvmPackages_9.llvm.out}/bin"
+      "-DLLVM_BINARY_DIR=${llvmPackages_13.llvm.out}"
+      "-DLLVM_CONFIG=${llvmPackages_13.llvm.dev}/bin/llvm-config"
+      "-DLLVM_LIBRARY_DIR=${llvmPackages_13.llvm.lib}/lib"
+      "-DLLVM_MAIN_INCLUDE_DIR=${llvmPackages_13.llvm.dev}/include"
+      "-DLLVM_TABLEGEN_EXE=${llvmPackages_13.llvm.out}/bin/llvm-tblgen"
+      "-DLLVM_TOOLS_BINARY_DIR=${llvmPackages_13.llvm.out}/bin"
       "-DLLVM_BUILD_TOOLS=Off"
       "-DLLVM_TOOL_CLING_BUILD=ON"
 
@@ -126,9 +120,9 @@ let
 
   # Runtime flags for the C++ standard library
   cxxFlags = if useLLVMLibcxx then [
-    "-I" "${lib.getDev llvmPackages_9.libcxx}/include/c++/v1"
-    "-L" "${llvmPackages_9.libcxx}/lib"
-    "-l" "${llvmPackages_9.libcxx}/lib/libc++.so"
+    "-I" "${lib.getDev llvmPackages_13.libcxx}/include/c++/v1"
+    "-L" "${llvmPackages_13.libcxx}/lib"
+    "-l" "${llvmPackages_13.libcxx}/lib/libc++.so"
   ] else [
     "-I" "${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}"
     "-I" "${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}/x86_64-unknown-linux-gnu"
@@ -149,7 +143,9 @@ let
     "-nostdinc"
     "-nostdinc++"
 
-    "-isystem" "${lib.getLib unwrapped}/lib/clang/9.0.1/include"
+    "-resource-dir" "${llvmPackages_13.llvm.lib}/lib"
+
+    "-isystem" "${lib.getLib unwrapped}/lib/clang/${llvmPackages_13.clang.version}/include"
   ]
   ++ cxxFlags
   ++ [
diff --git a/pkgs/development/interpreters/cling/fix-llvm-dylib-usage.patch b/pkgs/development/interpreters/cling/fix-llvm-dylib-usage.patch
deleted file mode 100644
index df1fba6b43869..0000000000000
--- a/pkgs/development/interpreters/cling/fix-llvm-dylib-usage.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/tools/cling/tools/driver/CMakeLists.txt b/tools/cling/tools/driver/CMakeLists.txt
---- a/tools/cling/tools/driver/CMakeLists.txt
-+++ b/tools/cling/tools/driver/CMakeLists.txt
-@@ -9,10 +9,10 @@
- # Keep symbols for JIT resolution
- set(LLVM_NO_DEAD_STRIP 1)
-
-+set(LLVM_LINK_COMPONENTS support)
-+
- if(BUILD_SHARED_LIBS)
-   set(LIBS
--    LLVMSupport
--
-     clangFrontendTool
-
-     clingInterpreter
-@@ -25,8 +25,6 @@ if(BUILD_SHARED_LIBS)
-   )
- else()
-   set(LIBS
--    LLVMSupport
--
-     clangASTMatchers
-     clangFrontendTool
diff --git a/pkgs/development/interpreters/cling/fix-llvm-include.patch b/pkgs/development/interpreters/cling/fix-llvm-include.patch
deleted file mode 100644
index 801965d02d3a2..0000000000000
--- a/pkgs/development/interpreters/cling/fix-llvm-include.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-diff --git a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
-index 16202d8..3afdac3 100644
---- a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
-+++ b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
-@@ -220,7 +220,7 @@ public:
-   Error removeModule(VModuleKey K) {
-     auto I = ModuleMap.find(K);
-     assert(I != ModuleMap.end() && "VModuleKey K not valid here");
--    auto EDM = std::move(I.second);
-+    auto EDM = std::move(I->second);
-     ModuleMap.erase(I);
-     return EDM->removeModuleFromBaseLayer(BaseLayer);
-   }
-diff --git a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
-index d9535ce..4c688c3 100644
---- a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
-+++ b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
-@@ -472,7 +472,9 @@ private:
- 
-   // NB!  `LinkedObjects` needs to be destroyed before `NotifyFreed` because
-   // `~ConcreteLinkedObject` calls `NotifyFreed`
-+protected:
-   std::map<VModuleKey, std::unique_ptr<LinkedObject>> LinkedObjects;
-+private:
-   bool ProcessAllSections = false;
- };
-