tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
cling: 1.0 -> 1.2
thomasjm
4 months ago
22c7d6a3
1c3ece86
+94
-61
3 changed files
expand all
collapse all
unified
split
pkgs
by-name
cl
cling
fix-new-parser.patch
no-clang-cpp.patch
package.nix
+54
pkgs/by-name/cl/cling/fix-new-parser.patch
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
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})
···
0
0
0
0
0
0
0
0
0
0
0
0
0
+40
-48
pkgs/by-name/cl/cling/package.nix
···
5
git,
6
lib,
7
libffi,
8
-
llvmPackages_13,
9
makeWrapper,
10
ncurses,
11
python3,
12
zlib,
13
14
-
# *NOT* from LLVM 13!
15
# The compiler used to compile Cling may affect the runtime include and lib
16
# directories it expects to be run with. Cling builds against (a fork of) Clang,
17
# so we prefer to use Clang as the compiler as well for consistency.
···
34
let
35
stdenv = clangStdenv;
36
37
-
# The patched clang lives in the LLVM megarepo
38
-
clangSrc = fetchFromGitHub {
0
39
owner = "root-project";
40
-
repo = "llvm-project";
41
-
# cling-llvm13 branch
42
-
rev = "3610201fbe0352a63efb5cb45f4ea4987702c735";
43
-
sha256 = "sha256-Cb7BvV7yobG+mkaYe7zD2KcnPvm8/vmVATNWssklXyk=";
44
-
sparseCheckout = [ "clang" ];
45
};
46
47
-
llvm = llvmPackages_13.llvm.override { enableSharedLibraries = false; };
48
-
49
-
unwrapped = stdenv.mkDerivation rec {
50
pname = "cling-unwrapped";
51
-
version = "1.0";
52
-
53
-
src = "${clangSrc}/clang";
54
55
-
clingSrc = fetchFromGitHub {
56
owner = "root-project";
57
-
repo = "cling";
58
-
rev = "v${version}";
59
-
sha256 = "sha256-Ye8EINzt+dyNvUIRydACXzb/xEPLm0YSkz08Xxw3xp4=";
60
};
61
62
-
prePatch = ''
63
-
echo "add_llvm_external_project(cling)" >> tools/CMakeLists.txt
64
65
-
cp -r $clingSrc tools/cling
66
-
chmod -R a+w tools/cling
67
-
'';
0
0
0
68
69
-
patches = [
70
-
./no-clang-cpp.patch
71
-
];
72
73
nativeBuildInputs = [
74
python3
···
84
strictDeps = true;
85
86
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
-
96
"-DLLVM_TARGETS_TO_BUILD=host;NVPTX"
0
97
"-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"
103
]
104
++ lib.optionals debug [
105
"-DCMAKE_BUILD_TYPE=Debug"
···
111
112
CPPFLAGS = if useLLVMLibcxx then [ "-stdlib=libc++" ] else [ ];
113
114
-
postInstall = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
115
mkdir -p $out/share/Jupyter
116
-
cp -r /build/clang/tools/cling/tools/Jupyter/kernel $out/share/Jupyter
117
'';
0
0
118
119
dontStrip = debug;
120
···
147
"-nostdinc++"
148
149
"-resource-dir"
150
-
"${llvm.lib}/lib"
151
152
"-isystem"
153
-
"${lib.getLib unwrapped}/lib/clang/${llvmPackages_13.clang.version}/include"
154
]
155
++ lib.optionals useLLVMLibcxx [
156
"-I"
157
-
"${lib.getDev llvmPackages_13.libcxx}/include/c++/v1"
158
"-L"
159
-
"${llvmPackages_13.libcxx}/lib"
160
"-l"
161
-
"${llvmPackages_13.libcxx}/lib/libc++${stdenv.hostPlatform.extensions.sharedLibrary}"
162
]
163
++ lib.optionals (!useLLVMLibcxx) [
164
"-I"
···
5
git,
6
lib,
7
libffi,
8
+
llvmPackages_18,
9
makeWrapper,
10
ncurses,
11
python3,
12
zlib,
13
14
+
# *NOT* from LLVM 18!
15
# The compiler used to compile Cling may affect the runtime include and lib
16
# directories it expects to be run with. Cling builds against (a fork of) Clang,
17
# so we prefer to use Clang as the compiler as well for consistency.
···
34
let
35
stdenv = clangStdenv;
36
37
+
version = "1.2";
38
+
39
+
clingSrc = fetchFromGitHub {
40
owner = "root-project";
41
+
repo = "cling";
42
+
rev = "v${version}";
43
+
sha256 = "sha256-ay9FXANJmB/+AdnCR4WOKHuPm6P88wLqoOgiKJwJ8JM=";
0
0
44
};
45
46
+
unwrapped = stdenv.mkDerivation {
0
0
47
pname = "cling-unwrapped";
48
+
inherit version;
0
0
49
50
+
src = fetchFromGitHub {
51
owner = "root-project";
52
+
repo = "llvm-project";
53
+
rev = "cling-llvm18-20250721-01";
54
+
sha256 = "sha256-JGteapyujU5w81DsfPQfTq76cYHgk5PbAFbdYfYIDo4=";
55
};
56
57
+
preConfigure = ''
58
+
cp -r ${clingSrc} cling-source
59
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
66
67
+
cd llvm
68
+
'';
0
69
70
nativeBuildInputs = [
71
python3
···
81
strictDeps = true;
82
83
cmakeFlags = [
84
+
"-DLLVM_EXTERNAL_PROJECTS=cling"
85
+
"-DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling-source"
86
+
"-DLLVM_ENABLE_PROJECTS=clang"
0
0
0
0
0
0
87
"-DLLVM_TARGETS_TO_BUILD=host;NVPTX"
88
+
"-DLLVM_INCLUDE_TESTS=OFF"
89
"-DLLVM_ENABLE_RTTI=ON"
90
+
]
91
+
++ lib.optionals (!debug) [
92
+
"-DCMAKE_BUILD_TYPE=Release"
0
0
93
]
94
++ lib.optionals debug [
95
"-DCMAKE_BUILD_TYPE=Debug"
···
101
102
CPPFLAGS = if useLLVMLibcxx then [ "-stdlib=libc++" ] else [ ];
103
104
+
postInstall = ''
105
mkdir -p $out/share/Jupyter
106
+
cp -r ../../cling-source/tools/Jupyter/kernel $out/share/Jupyter
107
'';
108
+
109
+
buildTargets = [ "cling" ];
110
111
dontStrip = debug;
112
···
139
"-nostdinc++"
140
141
"-resource-dir"
142
+
"${llvmPackages_18.llvm.lib}/lib"
143
144
"-isystem"
145
+
"${lib.getLib unwrapped}/lib/clang/18/include"
146
]
147
++ lib.optionals useLLVMLibcxx [
148
"-I"
149
+
"${lib.getDev llvmPackages_18.libcxx}/include/c++/v1"
150
"-L"
151
+
"${llvmPackages_18.libcxx}/lib"
152
"-l"
153
+
"${llvmPackages_18.libcxx}/lib/libc++${stdenv.hostPlatform.extensions.sharedLibrary}"
154
]
155
++ lib.optionals (!useLLVMLibcxx) [
156
"-I"