Skip to content

Commit db22551

Browse files
committed
[core] Fix libCling linking with -Bsymbolic
The code was in interpreter/CMakeLists.txt, but the definition of libCling is in core/metacling. After moving, symbols are correctly resolved by the linker and not anymore during dynamic loading. Fixes #19889
1 parent 12c37e4 commit db22551

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

core/metacling/src/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ if(APPLE)
225225
target_link_libraries(Cling PUBLIC -Wl,-w -Wl,-bind_at_load -Wl,-undefined,dynamic_lookup)
226226
elseif(NOT MSVC)
227227
target_link_libraries(Cling PUBLIC -Wl,--unresolved-symbols=ignore-in-object-files)
228+
# Require the linker to resolve the symbol internally and prevent
229+
# conflicts when linked with another software using also LLVM like in
230+
# the problem reported for Julia in
231+
# https://github.com/JuliaHEP/ROOT.jl/issues/17#issuecomment-882719292
232+
# and by ALICE in https://github.com/root-project/root/issues/19889
233+
# Only needed for Linux: Mac uses linker namespaces and Windows explicit export/import
234+
target_link_libraries(Cling PUBLIC -Wl,-Bsymbolic)
228235
endif()
229236

230237
if (CMAKE_SYSTEM_NAME MATCHES FreeBSD)

interpreter/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,8 @@ else()
130130
set(CMAKE_C_VISIBILITY_PRESET hidden)
131131
endif()
132132
if (NOT MSVC AND NOT APPLE)
133-
# Requires the linker to resolve the symbol internally and prevents
134-
# conflicts when linked with another software using also LLVM like in
135-
# the problem reported for Julia in
136-
# https://github.com/JuliaHEP/ROOT.jl/issues/17#issuecomment-882719292
137-
# Only needed for Linux: Mac uses linker namespaces and Windows explicit export/import
138-
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-Bsymbolic")
133+
# Allow the compiler to optimize knowing that symbols defined in libCling.so
134+
# are not interposed.
139135
ROOT_ADD_CXX_FLAG(CMAKE_CXX_FLAGS "-fno-semantic-interposition")
140136
endif()
141137
set(CMAKE_VISIBILITY_INLINES_HIDDEN "ON")

0 commit comments

Comments
 (0)