Skip to content

Commit 6feefe1

Browse files
chrisburrhageboeck
authored andcommitted
[core] Fix LIB_CORE_NAME mismatch when soversion is enabled
On Linux, dl_iterate_phdr reports loaded libraries by their SONAME (e.g. libCore.so.6.38), not their full filename (libCore.so.6.38.02). Commit ff7e631 changed LIB_CORE_NAME from using the SOVERSION-based name to TARGET_FILE_NAME, which gives the full versioned filename. When soversion is enabled, this causes TROOT::GetSharedLibDir() to fail to match the library name reported by the dynamic linker, returning an empty path. This breaks module loading and causes cling to attempt recompiling modules from source at runtime, which fails when external headers (e.g. Vc) are not in cling's include path. Fix by using TARGET_SONAME_FILE_NAME when soversion is enabled on Linux. On macOS, _dyld_get_image_name returns the actual filename, so TARGET_FILE_NAME remains correct there. (cherry picked from commit 82162e3)
1 parent 70f15b9 commit 6feefe1

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

core/base/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,15 @@ if(ROOT_NEED_STDCXXFS)
212212
endif()
213213

214214
# This code about the LIB_CORE_NAME define is important for TROOT::GetSharedLibDir()
215-
set(full_core_filename $<TARGET_FILE_NAME:Core>)
215+
# On Linux, dl_iterate_phdr reports loaded libraries by their SONAME
216+
# (e.g. libCore.so.6.38), not their full filename (libCore.so.6.38.02).
217+
# On macOS, _dyld_get_image_name returns the actual filename.
218+
# LIB_CORE_NAME must match what the dynamic linker reports.
219+
if(soversion AND NOT APPLE)
220+
set(full_core_filename $<TARGET_SONAME_FILE_NAME:Core>)
221+
else()
222+
set(full_core_filename $<TARGET_FILE_NAME:Core>)
223+
endif()
216224

217225
target_compile_options(Core PRIVATE -DLIB_CORE_NAME=${full_core_filename})
218226

0 commit comments

Comments
 (0)