Skip to content

Commit 06ad668

Browse files
devajithvsvgvassilev
authored andcommitted
Skip backend pass registration when built as static library
When clad is built with CLAD_BUILD_STATIC_ONLY=ON, only static archives are produced (libcladDifferentiator.a, libcladPlugin.a) and no clad.so In ROOT, when using clad, dladdr is resolved to libCling.so and then registered as an LLVM pass plugin. In LLVM20 this is ignored. In LLVM22 this errors out with: ``` error: unable to load plugin 'libCling.so': 'Plugin entry point not found in 'libCling.so'. Is this a legacy plugin?' ``` causing all rootcling dictionary generation steps to fail.
1 parent 5e8e74e commit 06ad668

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

tools/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ set(CLAD_PLUGIN_SRC
1010

1111
llvm_add_library(cladPlugin STATIC ${CLAD_PLUGIN_SRC})
1212

13+
if (CLAD_BUILD_STATIC_ONLY)
14+
target_compile_definitions(cladPlugin PRIVATE CLAD_BUILD_STATIC_ONLY)
15+
endif()
16+
1317
set(link_libs cladDifferentiator)
1418

1519
if (NOT CLAD_BUILD_STATIC_ONLY)

tools/ClangPlugin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ void InitTimers();
143143
// resolved from any symbol we own. Cleaner than iterating
144144
// CI.getFrontendOpts().Plugins (which depends on how clang was
145145
// invoked) and keeps the lookup inside this DSO.
146-
#ifdef _WIN32
146+
#ifdef CLAD_BUILD_STATIC_ONLY
147+
// Skip registration entirely if clad is statically linked
148+
#elif _WIN32
147149
HMODULE hm = nullptr;
148150
if (GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
149151
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,

0 commit comments

Comments
 (0)