Skip to content

Commit 0836c20

Browse files
committed
[testing][temp] Re-enable clad for testing
We also need to update `CLANG_CMAKE_DIR` after the changes in: llvm/llvm-project@88b77073 We also need to add a patch to clad to get this building.
1 parent 45543a0 commit 0836c20

5 files changed

Lines changed: 69 additions & 11 deletions

File tree

.github/workflows/root-ci-config/buildconfig/global.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ builtin_zstd=OFF
2828
ccache=ON
2929
cefweb=OFF
3030
check_connection=OFF
31-
clad=OFF
31+
clad=ON
3232
clingtest=OFF
3333
cocoa=OFF
3434
coverage=OFF

cmake/modules/RootBuildOptions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ ROOT_BUILD_OPTION(builtin_zstd OFF "Build included libzstd, or use system libzst
112112
ROOT_BUILD_OPTION(ccache OFF "Enable ccache usage for speeding up builds")
113113
ROOT_BUILD_OPTION(cefweb OFF "Enable support for CEF (Chromium Embedded Framework) web-based display")
114114
ROOT_BUILD_OPTION(check_connection ON "Fail the configuration step if there is no internet connection, but it's required for the build")
115-
ROOT_BUILD_OPTION(clad OFF "Build clad, the cling automatic differentiation plugin (requires network, or existing source directory indicated with -DCLAD_SOURCE_DIR=<clad_src_path>)")
115+
ROOT_BUILD_OPTION(clad ON "Build clad, the cling automatic differentiation plugin (requires network, or existing source directory indicated with -DCLAD_SOURCE_DIR=<clad_src_path>)")
116116
ROOT_BUILD_OPTION(cocoa OFF "Use native Cocoa/Quartz graphics backend (MacOS X only)")
117117
ROOT_BUILD_OPTION(coverage OFF "Enable compile flags for coverage testing")
118118
ROOT_BUILD_OPTION(cuda OFF "Enable support for CUDA (requires CUDA toolkit >= 7.5)")

interpreter/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ if (builtin_clang)
437437
${CMAKE_CURRENT_SOURCE_DIR}/llvm-project/clang/include
438438
${CLANG_BINARY_DIR}/include
439439
CACHE STRING "Clang include directories.")
440-
set(CLANG_CMAKE_DIR "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang/")
440+
set(CLANG_CMAKE_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang/")
441441
else()
442442
find_package(Clang REQUIRED CONFIG)
443443
message(STATUS "Found Clang ${CLANG_PACKAGE_VERSION} in ${CLANG_CMAKE_DIR}")

interpreter/cling/tools/plugins/clad/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ if (DEFINED CLAD_SOURCE_DIR)
7474
list(APPEND _clad_extra_settings SOURCE_DIR ${CLAD_SOURCE_DIR})
7575
else()
7676
list(APPEND _clad_extra_settings GIT_REPOSITORY https://github.com/vgvassilev/clad.git)
77-
list(APPEND _clad_extra_settings GIT_TAG v2.3)
77+
list(APPEND _clad_extra_settings GIT_TAG 5b0fbe0)
7878
endif()
7979

8080
## list(APPEND _clad_patches_list "patch1.patch" "patch2.patch")
81-
#list(APPEND _clad_patches_list "")
82-
#set(_clad_patch_command
83-
# ${CMAKE_COMMAND} -E copy_directory
84-
# ${CMAKE_SOURCE_DIR}/interpreter/cling/tools/plugins/clad/patches <SOURCE_DIR>
85-
# && git checkout -q <SOURCE_DIR>
86-
# && git apply --ignore-space-change --ignore-whitespace ${_clad_patches_list}
87-
# )
81+
list(APPEND _clad_patches_list "0001-Revert-DSO-self-resolution-for-backend-pass-registra.patch")
82+
set(_clad_patch_command
83+
${CMAKE_COMMAND} -E copy_directory
84+
${CMAKE_SOURCE_DIR}/interpreter/cling/tools/plugins/clad/patches <SOURCE_DIR>
85+
&& git checkout -q <SOURCE_DIR>
86+
&& git apply --ignore-space-change --ignore-whitespace ${_clad_patches_list}
87+
)
8888

8989
ExternalProject_Add(
9090
clad
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
From ccb2dbe67648d8a24306c82136c5457817fcf562 Mon Sep 17 00:00:00 2001
2+
From: Devajith Valaparambil Sreeramaswamy
3+
<devajith.valaparambil.sreeramaswamy@cern.ch>
4+
Date: Thu, 25 Jun 2026 09:27:15 +0200
5+
Subject: [PATCH] Revert DSO self-resolution for backend pass registration
6+
7+
When clad is built via CLAD_BUILD_STATIC_ONLY=ON, no clad.so is generated
8+
dladdr is resolved to libCling.so and then registered as an LLVM pass plugin.
9+
10+
In LLVM20 this is ignored. In LLVM22 this errors out with:
11+
12+
```
13+
error: unable to load plugin 'libCling.so':
14+
'Plugin entry point not found in 'libCling.so'. Is this a legacy plugin?'
15+
```
16+
17+
causing all rootcling dictionary generation steps to fail.
18+
19+
Temporarily revert this.
20+
---
21+
tools/ClangPlugin.cpp | 21 ---------------------
22+
1 file changed, 21 deletions(-)
23+
24+
diff --git a/tools/ClangPlugin.cpp b/tools/ClangPlugin.cpp
25+
index 52d171fd..6302cafc 100644
26+
--- a/tools/ClangPlugin.cpp
27+
+++ b/tools/ClangPlugin.cpp
28+
@@ -139,27 +139,6 @@ void InitTimers();
29+
if (WantTiming || getenv("CLAD_ENABLE_TIMING"))
30+
InitTimers();
31+
32+
- // Register clad as a backend pass via the path of clad.so itself,
33+
- // resolved from any symbol we own. Cleaner than iterating
34+
- // CI.getFrontendOpts().Plugins (which depends on how clang was
35+
- // invoked) and keeps the lookup inside this DSO.
36+
-#ifdef _WIN32
37+
- HMODULE hm = nullptr;
38+
- if (GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
39+
- GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
40+
- reinterpret_cast<LPCSTR>(&InitTimers), &hm) &&
41+
- hm) {
42+
- char buf[MAX_PATH];
43+
- if (DWORD n = GetModuleFileNameA(hm, buf, MAX_PATH);
44+
- n > 0 && n < MAX_PATH)
45+
- CGOpts.PassPlugins.emplace_back(buf);
46+
- }
47+
-#else
48+
- if (Dl_info info;
49+
- dladdr(reinterpret_cast<void*>(&InitTimers), &info) && info.dli_fname)
50+
- CGOpts.PassPlugins.emplace_back(info.dli_fname);
51+
-#endif
52+
-
53+
// Add define for __CLAD__, so that CladFunction::CladFunction()
54+
// doesn't throw an error.
55+
auto predefines = m_CI.getPreprocessor().getPredefines();
56+
--
57+
2.43.0
58+

0 commit comments

Comments
 (0)