From 3ec490b0f47e46918e46d3b85950919cdb598e06 Mon Sep 17 00:00:00 2001 From: Philippe Gras Date: Tue, 20 Jul 2021 11:17:29 +0200 Subject: [PATCH 1/6] 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 8f9b36c07cb23..6c80f3c4b88c1 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -489,9 +489,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. From a80e598d162efa81497867a03897289bf06a5136 Mon Sep 17 00:00:00 2001 From: Philippe Gras Date: Fri, 23 Jul 2021 16:26:53 +0200 Subject: [PATCH 2/6] Grouped flags related to link premption togeher in the interpreter/CMakeLists.txt file --- interpreter/CMakeLists.txt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index 6c80f3c4b88c1..63bbef98f8b4f 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -132,6 +132,12 @@ else() set(CMAKE_C_VISIBILITY_PRESET hidden) endif() if (NOT MSVC AND NOT APPLE) + # 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 + string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-Bsymbolic") ROOT_ADD_CXX_FLAG(CMAKE_CXX_FLAGS "-fno-semantic-interposition") endif() set(CMAKE_VISIBILITY_INLINES_HIDDEN "ON") @@ -489,18 +495,9 @@ 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. From 42f590e75dff3c13cd2f2826432913c83782a0c4 Mon Sep 17 00:00:00 2001 From: Philippe Gras Date: Tue, 20 Jul 2021 11:17:29 +0200 Subject: [PATCH 3/6] 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. From bd1b7b4e3018bab2f756a533aca2284335f27f15 Mon Sep 17 00:00:00 2001 From: Philippe Gras Date: Fri, 23 Jul 2021 16:26:53 +0200 Subject: [PATCH 4/6] Grouped flags related to link premption togeher in the interpreter/CMakeLists.txt file --- interpreter/CMakeLists.txt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index 31064d1e85fc9..63bbef98f8b4f 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -495,18 +495,9 @@ 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. From 5c94911b73597cd2ac608ec952f201ed6011e506 Mon Sep 17 00:00:00 2001 From: Philippe Gras Date: Fri, 23 Jul 2021 10:47:52 +0200 Subject: [PATCH 5/6] Update interpreter/CMakeLists.txt Co-authored-by: Axel Naumann --- interpreter/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index 63bbef98f8b4f..a719a9f1e2167 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -497,7 +497,6 @@ if (builtin_cling) # 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. From 2ee441cdba0dfb9a27a7501144bc5f8932f1b353 Mon Sep 17 00:00:00 2001 From: Philippe Gras Date: Tue, 24 Aug 2021 11:42:21 +0200 Subject: [PATCH 6/6] cosmetics --- interpreter/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index a719a9f1e2167..63bbef98f8b4f 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -497,6 +497,7 @@ if (builtin_cling) # 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.