root icon indicating copy to clipboard operation
root copied to clipboard

[cling] Missing find_dependency zstd::libzstd_shared in exported targets

Open ferdymercury opened this issue 1 month ago • 4 comments

Check duplicate issues.

  • [ ] Checked for duplicates

Description

With system-LLVM and external patched-Clang and cling builds:

ldd /opt/cling/install/lib/libcling.so

shows

libzstd.so.1 => /usr/lib/x86_64-linux-gnu/libzstd.so.1 (0x00007946a073d000)

but

grep -r zstd /opt/cling/install/lib/cmake/cling/*.cmake

returns nothing.

When building ROOT with external Cling/Clang/LLVM, there is an error during the configure step:

cmake -DCling_DIR=/opt/cling/install -Dbuiltin_llvm=OFF -Dbuiltin_clang=OFF -Dbuiltin_cling=OFF -Dbuiltin_civetweb=ON -DClang_DIR=/opt/cernclang/install/lib/cmake/clang /opt/root_src2/

CMake Error at cmake/modules/RootMacros.cmake:1548 (target_link_libraries):
  Target "rootcling_stage1" links to:

    zstd::libzstd_shared

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  core/rootcling_stage1/CMakeLists.txt:31 (ROOT_EXECUTABLE)


CMake Error at cmake/modules/RootMacros.cmake:1050 (target_link_libraries):
  Target "Cling" links to:

    zstd::libzstd_shared

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  core/metacling/src/CMakeLists.txt:126 (ROOT_LINKER_LIBRARY)

The naive hotfix solution is

diff --git a/core/metacling/src/CMakeLists.txt b/core/metacling/src/CMakeLists.txt
index f7d91833b7e..94009a65984 100644
--- a/core/metacling/src/CMakeLists.txt
+++ b/core/metacling/src/CMakeLists.txt
@@ -123,6 +123,7 @@ if (clad)
   endif()
 endif()
 
+find_package(zstd)
 ROOT_LINKER_LIBRARY(Cling
         $<TARGET_OBJECTS:ClingUtils>
         $<TARGET_OBJECTS:Dictgen>
diff --git a/core/rootcling_stage1/CMakeLists.txt b/core/rootcling_stage1/CMakeLists.txt
index 4e441dddc20..66f1afee5fa 100644
--- a/core/rootcling_stage1/CMakeLists.txt
+++ b/core/rootcling_stage1/CMakeLists.txt
@@ -28,6 +28,7 @@ else()
   link_directories("${LLVM_LIBRARY_DIR}")
 endif()
 
+find_package(zstd)
 ROOT_EXECUTABLE(rootcling_stage1 src/rootcling_stage1.cxx
                               $<TARGET_OBJECTS:Clib>
                               $<TARGET_OBJECTS:ClingUtils>
diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt
index 8f6b06bd51e..74cf39c096e 100644

but the proper one would be to have this dealt by FindDependency when exporting CMake targets at Cling install step.

Reproducer

On Ubu26 or Debian, build first patched clang from ROOT with builtin_llvm=OFF on /opt, then cling also on /opt/ pointing to that patched clang. Finally ROOT with all builtin_cling/clang/llvm set to OFF, you will get a configure error during CMake step.

cmake -DCling_DIR=/opt/cling/install -Dbuiltin_llvm=OFF -Dbuiltin_clang=OFF -Dbuiltin_cling=OFF -Dbuiltin_civetweb=ON -DClang_DIR=/opt/cernclang/install/lib/cmake/clang /opt/root_src2/

ROOT version

ROOT v6.41.01
Built for linuxx8664gcc on Oct 12 2026, 11:49:32
From heads/master@v6-39-01-4297-g14a58f74211
With c++ (Ubuntu 15.2.0-16ubuntu1) 15.2.0 std201703
Binary directory: /opt/root_bld/bin

Installation method

Source

Operating system

Ubu26.04

Additional context

See also: https://github.com/root-project/root/pull/23579/files https://github.com/root-project/root/pull/23695

ferdymercury avatar Oct 12 '26 20:10 ferdymercury

Maybe or maybe not related: https://github.com/root-project/root/pull/23612

pcanal avatar Oct 12 '26 21:10 pcanal

2. Maybe or maybe not related: #23612

So that means "maybe related"? 😆

guitargeek avatar Oct 13 '26 21:10 guitargeek

3. So that means "maybe related"? 😆

Or randomly chosen? 🤡

dpiparo avatar Oct 16 '26 13:10 dpiparo

"Hi @hageboeck, are you currently working on a fix for this, or would you mind if I investigated and opened a PR to add find_dependency(zstd)?"

Ayush-CS-89112521 avatar Oct 31 '26 22:10 Ayush-CS-89112521