cling: 1.0 -> 1.2

thomasjm 22c7d6a3 1c3ece86

+94 -61
+54
pkgs/by-name/cl/cling/fix-new-parser.patch
··· 1 + From cd4d1d8c4963620a6a84834948845df81fbbd70b Mon Sep 17 00:00:00 2001 2 + From: Jonas Hahnfeld <jonas.hahnfeld@cern.ch> 3 + Date: Tue, 17 Dec 2024 14:54:18 +0100 4 + Subject: [PATCH] Use single Parser for LookupHelper 5 + 6 + It is the only construction of a temporary parser, and it seems not 7 + necessary (anymore). 8 + --- 9 + include/cling/Interpreter/LookupHelper.h | 2 +- 10 + lib/Interpreter/Interpreter.cpp | 11 ++++------- 11 + 2 files changed, 5 insertions(+), 8 deletions(-) 12 + 13 + diff --git a/include/cling/Interpreter/LookupHelper.h b/include/cling/Interpreter/LookupHelper.h 14 + index 6e6e281470..cd79b2a65c 100644 15 + --- a/include/cling/Interpreter/LookupHelper.h 16 + +++ b/include/cling/Interpreter/LookupHelper.h 17 + @@ -56,7 +56,7 @@ namespace cling { 18 + WithDiagnostics 19 + }; 20 + private: 21 + - std::unique_ptr<clang::Parser> m_Parser; 22 + + clang::Parser* m_Parser; 23 + Interpreter* m_Interpreter; // we do not own. 24 + std::array<const clang::Type*, kNumCachedStrings> m_StringTy = {{}}; 25 + /// A map containing the hash of the lookup buffer. This allows us to avoid 26 + diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp 27 + index 13c8409cc5..f04695439b 100644 28 + --- a/lib/Interpreter/Interpreter.cpp 29 + +++ b/lib/Interpreter/Interpreter.cpp 30 + @@ -265,13 +265,6 @@ namespace cling { 31 + } 32 + 33 + Sema& SemaRef = getSema(); 34 + - Preprocessor& PP = SemaRef.getPreprocessor(); 35 + - 36 + - m_LookupHelper.reset(new LookupHelper(new Parser(PP, SemaRef, 37 + - /*SkipFunctionBodies*/false, 38 + - /*isTemp*/true), this)); 39 + - if (!m_LookupHelper) 40 + - return; 41 + 42 + if (!isInSyntaxOnlyMode() && !m_Opts.CompilerOpts.CUDADevice) { 43 + m_Executor.reset(new IncrementalExecutor(SemaRef.Diags, *getCI(), 44 + @@ -317,6 +310,10 @@ namespace cling { 45 + return; 46 + } 47 + 48 + + m_LookupHelper.reset(new LookupHelper(m_IncrParser->getParser(), this)); 49 + + if (!m_LookupHelper) 50 + + return; 51 + + 52 + // When not using C++ modules, we now have a PCH and we can safely setup 53 + // our callbacks without fearing that they get overwritten by clang code. 54 + // The modules setup is handled above.
-13
pkgs/by-name/cl/cling/no-clang-cpp.patch
··· 1 - diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt 2 - index 590d708d83..340ae529d4 100644 3 - --- a/tools/driver/CMakeLists.txt 4 - +++ b/tools/driver/CMakeLists.txt 5 - @@ -63,7 +63,7 @@ endif() 6 - add_dependencies(clang clang-resource-headers) 7 - 8 - if(NOT CLANG_LINKS_TO_CREATE) 9 - - set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp) 10 - + set(CLANG_LINKS_TO_CREATE clang++ clang-cl) 11 - endif() 12 - 13 - foreach(link ${CLANG_LINKS_TO_CREATE})
+40 -48
pkgs/by-name/cl/cling/package.nix
··· 5 5 git, 6 6 lib, 7 7 libffi, 8 - llvmPackages_13, 8 + llvmPackages_18, 9 9 makeWrapper, 10 10 ncurses, 11 11 python3, 12 12 zlib, 13 13 14 - # *NOT* from LLVM 13! 14 + # *NOT* from LLVM 18! 15 15 # The compiler used to compile Cling may affect the runtime include and lib 16 16 # directories it expects to be run with. Cling builds against (a fork of) Clang, 17 17 # so we prefer to use Clang as the compiler as well for consistency. ··· 34 34 let 35 35 stdenv = clangStdenv; 36 36 37 - # The patched clang lives in the LLVM megarepo 38 - clangSrc = fetchFromGitHub { 37 + version = "1.2"; 38 + 39 + clingSrc = fetchFromGitHub { 39 40 owner = "root-project"; 40 - repo = "llvm-project"; 41 - # cling-llvm13 branch 42 - rev = "3610201fbe0352a63efb5cb45f4ea4987702c735"; 43 - sha256 = "sha256-Cb7BvV7yobG+mkaYe7zD2KcnPvm8/vmVATNWssklXyk="; 44 - sparseCheckout = [ "clang" ]; 41 + repo = "cling"; 42 + rev = "v${version}"; 43 + sha256 = "sha256-ay9FXANJmB/+AdnCR4WOKHuPm6P88wLqoOgiKJwJ8JM="; 45 44 }; 46 45 47 - llvm = llvmPackages_13.llvm.override { enableSharedLibraries = false; }; 48 - 49 - unwrapped = stdenv.mkDerivation rec { 46 + unwrapped = stdenv.mkDerivation { 50 47 pname = "cling-unwrapped"; 51 - version = "1.0"; 52 - 53 - src = "${clangSrc}/clang"; 48 + inherit version; 54 49 55 - clingSrc = fetchFromGitHub { 50 + src = fetchFromGitHub { 56 51 owner = "root-project"; 57 - repo = "cling"; 58 - rev = "v${version}"; 59 - sha256 = "sha256-Ye8EINzt+dyNvUIRydACXzb/xEPLm0YSkz08Xxw3xp4="; 52 + repo = "llvm-project"; 53 + rev = "cling-llvm18-20250721-01"; 54 + sha256 = "sha256-JGteapyujU5w81DsfPQfTq76cYHgk5PbAFbdYfYIDo4="; 60 55 }; 61 56 62 - prePatch = '' 63 - echo "add_llvm_external_project(cling)" >> tools/CMakeLists.txt 57 + preConfigure = '' 58 + cp -r ${clingSrc} cling-source 64 59 65 - cp -r $clingSrc tools/cling 66 - chmod -R a+w tools/cling 67 - ''; 60 + # Patch a bug in version 1.2 by backporting a fix. See 61 + # https://github.com/root-project/cling/issues/556 62 + chmod -R u+w cling-source 63 + pushd cling-source 64 + patch -p1 < ${./fix-new-parser.patch} 65 + popd 68 66 69 - patches = [ 70 - ./no-clang-cpp.patch 71 - ]; 67 + cd llvm 68 + ''; 72 69 73 70 nativeBuildInputs = [ 74 71 python3 ··· 84 81 strictDeps = true; 85 82 86 83 cmakeFlags = [ 87 - "-DLLVM_BINARY_DIR=${llvm.out}" 88 - "-DLLVM_CONFIG=${llvm.dev}/bin/llvm-config" 89 - "-DLLVM_LIBRARY_DIR=${llvm.lib}/lib" 90 - "-DLLVM_MAIN_INCLUDE_DIR=${llvm.dev}/include" 91 - "-DLLVM_TABLEGEN_EXE=${llvm.out}/bin/llvm-tblgen" 92 - "-DLLVM_TOOLS_BINARY_DIR=${llvm.out}/bin" 93 - "-DLLVM_BUILD_TOOLS=Off" 94 - "-DLLVM_TOOL_CLING_BUILD=ON" 95 - 84 + "-DLLVM_EXTERNAL_PROJECTS=cling" 85 + "-DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling-source" 86 + "-DLLVM_ENABLE_PROJECTS=clang" 96 87 "-DLLVM_TARGETS_TO_BUILD=host;NVPTX" 88 + "-DLLVM_INCLUDE_TESTS=OFF" 97 89 "-DLLVM_ENABLE_RTTI=ON" 98 - 99 - # Setting -DCLING_INCLUDE_TESTS=ON causes the cling/tools targets to be built; 100 - # see cling/tools/CMakeLists.txt 101 - "-DCLING_INCLUDE_TESTS=ON" 102 - "-DCLANG-TOOLS=OFF" 90 + ] 91 + ++ lib.optionals (!debug) [ 92 + "-DCMAKE_BUILD_TYPE=Release" 103 93 ] 104 94 ++ lib.optionals debug [ 105 95 "-DCMAKE_BUILD_TYPE=Debug" ··· 111 101 112 102 CPPFLAGS = if useLLVMLibcxx then [ "-stdlib=libc++" ] else [ ]; 113 103 114 - postInstall = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 104 + postInstall = '' 115 105 mkdir -p $out/share/Jupyter 116 - cp -r /build/clang/tools/cling/tools/Jupyter/kernel $out/share/Jupyter 106 + cp -r ../../cling-source/tools/Jupyter/kernel $out/share/Jupyter 117 107 ''; 108 + 109 + buildTargets = [ "cling" ]; 118 110 119 111 dontStrip = debug; 120 112 ··· 147 139 "-nostdinc++" 148 140 149 141 "-resource-dir" 150 - "${llvm.lib}/lib" 142 + "${llvmPackages_18.llvm.lib}/lib" 151 143 152 144 "-isystem" 153 - "${lib.getLib unwrapped}/lib/clang/${llvmPackages_13.clang.version}/include" 145 + "${lib.getLib unwrapped}/lib/clang/18/include" 154 146 ] 155 147 ++ lib.optionals useLLVMLibcxx [ 156 148 "-I" 157 - "${lib.getDev llvmPackages_13.libcxx}/include/c++/v1" 149 + "${lib.getDev llvmPackages_18.libcxx}/include/c++/v1" 158 150 "-L" 159 - "${llvmPackages_13.libcxx}/lib" 151 + "${llvmPackages_18.libcxx}/lib" 160 152 "-l" 161 - "${llvmPackages_13.libcxx}/lib/libc++${stdenv.hostPlatform.extensions.sharedLibrary}" 153 + "${llvmPackages_18.libcxx}/lib/libc++${stdenv.hostPlatform.extensions.sharedLibrary}" 162 154 ] 163 155 ++ lib.optionals (!useLLVMLibcxx) [ 164 156 "-I"