From 42f590e75dff3c13cd2f2826432913c83782a0c4 Mon Sep 17 00:00:00 2001 From: Philippe Gras Date: Tue, 20 Jul 2021 11:17:29 +0200 Subject: [PATCH] Adds -Bsymbolic linker option for libCling.so in order get the symbols resolved internally This is expected to solve conflicts when interfacing with other software using LLVM, like Julia. See https://github.com/JuliaHEP/ROOT.jl/issues/17#issuecomment-882719292 --- interpreter/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index 63bbef98f8b4f..31064d1e85fc9 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -495,9 +495,18 @@ if (builtin_cling) set(CLING_CXXFLAGS " ${LLVM_DEFS} -fno-strict-aliasing -Wwrite-strings -Wno-shadow -Wno-unused-parameter -Wno-deprecated-declarations") endif() + # Requires the linker to resolve the symbol internally and prevents + # conflicts when linked with another software using also LLVM like in + # the problem reported for Julia in + # https://github.com/JuliaHEP/ROOT.jl/issues/17#issuecomment-882719292 + # Only needed for Linux: Mac uses linker namespaces and Windows explicit export/import + if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-Bsymbolic") + endif() + # Set the flags in the parent scope for the rest of the cling-based libraries in ROOT. set(CLING_CXXFLAGS ${CLING_CXXFLAGS} PARENT_SCOPE) - + string(APPEND CMAKE_CXX_FLAGS ${CLING_CXXFLAGS}) if (LLVM_ENABLE_PIC AND NOT MSVC) # FIXME: LLVM_ENABLE_PIC is ON by default, however not propagated to cling.