Skip to content

Add cling 1.2 support #580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/MacOS-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
cling: Off
llvm_enable_projects: "clang"
llvm_targets_to_build: "host"
- name: osx15-arm-clang-clang13-cling
- name: osx15-arm-clang-clang18-cling
os: macos-15
compiler: clang
clang-runtime: '13'
clang-runtime: '18'
cling: On
cling-version: '1.0'
cling-version: '1.2'
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"

Expand Down Expand Up @@ -166,6 +166,7 @@ jobs:
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
else # repl
Expand All @@ -192,9 +193,8 @@ jobs:
-G Ninja \
../llvm
ninja clang -j ${{ env.ncpus }}
ninja LLVMOrcDebugging -j ${{ env.ncpus }}
ninja clingInterpreter -j ${{ env.ncpus }}
# Now build gtest.a and gtest_main for CppInterOp to run its tests.
ninja gtest_main -j ${{ env.ncpus }}
else
# Apply patches
llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]')
Expand Down Expand Up @@ -289,12 +289,12 @@ jobs:
clang-runtime: '16'
cling: Off
cppyy: Off
- name: osx15-arm-clang-clang13-cling-cppyy
- name: osx15-arm-clang-clang18-cling-cppyy
os: macos-15
compiler: clang
clang-runtime: '13'
clang-runtime: '18'
cling: On
cling-version: '1.0'
cling-version: '1.2'
cppyy: On

steps:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
cling: Off
llvm_enable_projects: "clang"
llvm_targets_to_build: "host"
- name: osx13-x86-clang-clang13-cling
- name: osx13-x86-clang-clang18-cling
os: macos-13
compiler: clang
clang-runtime: '13'
clang-runtime: '18'
cling: On
cling-version: '1.0'
cling-version: '1.2'
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"

Expand Down Expand Up @@ -150,6 +150,7 @@ jobs:
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
else # repl
Expand All @@ -176,9 +177,8 @@ jobs:
-G Ninja \
../llvm
ninja clang -j ${{ env.ncpus }}
ninja LLVMOrcDebugging -j ${{ env.ncpus }}
ninja clingInterpreter -j ${{ env.ncpus }}
# Now build gtest.a and gtest_main for CppInterOp to run its tests.
ninja gtest_main -j ${{ env.ncpus }}
else
# Apply patches
llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]')
Expand Down Expand Up @@ -273,12 +273,12 @@ jobs:
clang-runtime: '16'
cling: Off
cppyy: Off
- name: osx13-x86-clang-clang13-cling-cppyy
- name: osx13-x86-clang-clang18-cling-cppyy
os: macos-13
compiler: clang
clang-runtime: '13'
clang-runtime: '18'
cling: On
cling-version: '1.0'
cling-version: '1.2'
cppyy: On

steps:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/Ubuntu-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ jobs:
cling: Off
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"
- name: ubu24-arm-gcc9-clang13-cling
- name: ubu24-arm-gcc9-clang18-cling
os: ubuntu-24.04-arm
compiler: gcc-9
clang-runtime: '13'
clang-runtime: '18'
cling: On
cling-version: '1.0'
cling-version: '1.2'
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"

Expand Down Expand Up @@ -161,6 +161,7 @@ jobs:
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
else # repl
Expand All @@ -187,9 +188,8 @@ jobs:
-G Ninja \
../llvm
ninja clang -j ${{ env.ncpus }}
ninja LLVMOrcDebugging -j ${{ env.ncpus }}
ninja clingInterpreter -j ${{ env.ncpus }}
# Now build gtest.a and gtest_main for CppInterOp to run its tests.
ninja gtest_main -j ${{ env.ncpus }}
else
# Apply patches
llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]')
Expand Down Expand Up @@ -291,13 +291,13 @@ jobs:
clang-runtime: '16'
cling: Off
cppyy: Off
- name: ubu24-arm-gcc9-clang13-cling-cppyy
- name: ubu24-arm-gcc9-clang18-cling-cppyy
os: ubuntu-24.04-arm
compiler: gcc-9
clang-runtime: '13'
clang-runtime: '18'
cling: On
cppyy: On
cling-version: '1.0'
cling-version: '1.2'

steps:
- uses: actions/checkout@v4
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/Ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
cling: Off
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"
- name: ubu24-x86-gcc9-clang13-cling
- name: ubu24-x86-gcc9-clang18-cling
os: ubuntu-24.04
compiler: gcc-9
clang-runtime: '13'
clang-runtime: '18'
cling: On
cling-version: '1.0'
cling-version: '1.2'
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"

Expand Down Expand Up @@ -154,6 +154,7 @@ jobs:
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
else # repl
Expand All @@ -180,9 +181,8 @@ jobs:
-G Ninja \
../llvm
ninja clang -j ${{ env.ncpus }}
ninja LLVMOrcDebugging -j ${{ env.ncpus }}
ninja clingInterpreter -j ${{ env.ncpus }}
# Now build gtest.a and gtest_main for CppInterOp to run its tests.
ninja gtest_main -j ${{ env.ncpus }}
else
# Apply patches
llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]')
Expand Down Expand Up @@ -277,12 +277,12 @@ jobs:
clang-runtime: '16'
cling: Off
cppyy: Off
- name: ubu24-x86-gcc9-clang13-cling-cppyy
- name: ubu24-x86-gcc9-clang18-cling-cppyy
os: ubuntu-24.04
compiler: gcc-9
clang-runtime: '13'
clang-runtime: '18'
cling: On
cling-version: '1.0'
cling-version: '1.2'
cppyy: On

steps:
Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/Windows-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ jobs:
cling: Off
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"
- name: win11-msvc-clang18-cling
os: windows-11-arm
compiler: msvc
clang-runtime: '18'
cling: On
cling-version: '1.2'
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -122,6 +130,7 @@ jobs:
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
$env:PWD_DIR= $PWD.Path
Expand Down Expand Up @@ -154,9 +163,8 @@ jobs:
-DLLVM_ENABLE_LIBXML2=OFF `
..\llvm
cmake --build . --config Release --target clang --parallel ${{ env.ncpus }}
cmake --build . --config Release --target cling --parallel ${{ env.ncpus }}
# Now build gtest.a and gtest_main for CppInterOp to run its tests.
cmake --build . --config Release --target gtest_main --parallel ${{ env.ncpus }}
cmake --build . --config Release --target LLVMOrcDebugging --parallel ${{ env.ncpus }}
cmake --build . --config Release --target clingInterpreter --parallel ${{ env.ncpus }}
}
else
{
Expand Down Expand Up @@ -231,6 +239,13 @@ jobs:
clang-runtime: '20'
cling: Off
cppyy: Off
- name: win11-msvc-clang18-cling
os: windows-11-arm
compiler: msvc
clang-runtime: '18'
cling: On
cling-version: '1.2'
cppyy: Off

steps:
- uses: actions/checkout@v4
Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ jobs:
cling: Off
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"
- name: win2025-msvc-clang18-cling
os: windows-2025
compiler: msvc
clang-runtime: '18'
cling: On
cling-version: '1.2'
llvm_enable_projects: "clang"
llvm_targets_to_build: "host;NVPTX"

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -122,6 +130,7 @@ jobs:
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
$env:PWD_DIR= $PWD.Path
Expand Down Expand Up @@ -154,9 +163,8 @@ jobs:
-DLLVM_ENABLE_LIBXML2=OFF `
..\llvm
cmake --build . --config Release --target clang --parallel ${{ env.ncpus }}
cmake --build . --config Release --target cling --parallel ${{ env.ncpus }}
# Now build gtest.a and gtest_main for CppInterOp to run its tests.
cmake --build . --config Release --target gtest_main --parallel ${{ env.ncpus }}
cmake --build . --config Release --target LLVMOrcDebugging --parallel ${{ env.ncpus }}
cmake --build . --config Release --target clingInterpreter --parallel ${{ env.ncpus }}
}
else
{
Expand Down Expand Up @@ -231,6 +239,13 @@ jobs:
clang-runtime: '20'
cling: Off
cppyy: Off
- name: win2025-msvc-clang18-cling
os: windows-2025
compiler: msvc
clang-runtime: '18'
cling: On
cling-version: '1.2'
cppyy: Off

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ jobs:
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
else # repl
Expand Down Expand Up @@ -311,6 +312,7 @@ jobs:
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
$env:PWD_DIR= $PWD.Path
Expand Down
42 changes: 42 additions & 0 deletions patches/llvm/cling1.2-LookupHelper.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/include/cling/Interpreter/LookupHelper.h b/include/cling/Interpreter/LookupHelper.h
index 6e6e2814..cd79b2a6 100644
--- a/include/cling/Interpreter/LookupHelper.h
+++ b/include/cling/Interpreter/LookupHelper.h
@@ -56,7 +56,7 @@ namespace cling {
WithDiagnostics
};
private:
- std::unique_ptr<clang::Parser> m_Parser;
+ clang::Parser* m_Parser;
Interpreter* m_Interpreter; // we do not own.
std::array<const clang::Type*, kNumCachedStrings> m_StringTy = {{}};
/// A map containing the hash of the lookup buffer. This allows us to avoid
diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp
index 6af90108..89ca360b 100644
--- a/lib/Interpreter/Interpreter.cpp
+++ b/lib/Interpreter/Interpreter.cpp
@@ -265,13 +265,6 @@ namespace cling {
}

Sema& SemaRef = getSema();
- Preprocessor& PP = SemaRef.getPreprocessor();
-
- m_LookupHelper.reset(new LookupHelper(new Parser(PP, SemaRef,
- /*SkipFunctionBodies*/false,
- /*isTemp*/true), this));
- if (!m_LookupHelper)
- return;

if (!isInSyntaxOnlyMode() && !m_Opts.CompilerOpts.CUDADevice) {
m_Executor.reset(new IncrementalExecutor(SemaRef.Diags, *getCI(),
@@ -317,6 +310,10 @@ namespace cling {
return;
}

+ m_LookupHelper.reset(new LookupHelper(m_IncrParser->getParser(), this));
+ if (!m_LookupHelper)
+ return;
+
// When not using C++ modules, we now have a PCH and we can safely setup
// our callbacks without fearing that they get overwritten by clang code.
// The modules setup is handled above.
6 changes: 6 additions & 0 deletions unittests/CppInterOp/DynamicLibraryManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ TEST(DynamicLibraryManagerTest, Sanity) {
#ifdef EMSCRIPTEN
GTEST_SKIP() << "Test fails for Emscipten builds";
#endif

#if CLANG_VERSION_MAJOR == 18 && defined(CPPINTEROP_USE_CLING) && \
defined(_WIN32)
GTEST_SKIP() << "Test fails with Cling on Windows";
#endif

EXPECT_TRUE(Cpp::CreateInterpreter());
EXPECT_FALSE(Cpp::GetFunctionAddress("ret_zero"));

Expand Down
4 changes: 4 additions & 0 deletions unittests/CppInterOp/FunctionReflectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,10 @@ TEST(FunctionReflectionTest, ExistsFunctionTemplate) {
}

TEST(FunctionReflectionTest, InstantiateTemplateFunctionFromString) {
#if CLANG_VERSION_MAJOR == 18 && defined(CPPINTEROP_USE_CLING) && \
defined(_WIN32) && (defined(_M_ARM) || defined(_M_ARM64))
GTEST_SKIP() << "Test fails with Cling on Windows on ARM";
#endif
if (llvm::sys::RunningOnValgrind())
GTEST_SKIP() << "XFAIL due to Valgrind report";
std::vector<const char*> interpreter_args = { "-include", "new" };
Expand Down
Loading
Loading