From 38e344659980dded622322d42a7742c0e50107f8 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 30 Jul 2018 19:55:51 +0800 Subject: [PATCH] cmake: always prefer local symbols Fixes: http://tracker.ceph.com/issues/25154 Signed-off-by: Kefu Chai --- src/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ec08911948411..07f11dc17ccf7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -414,6 +414,20 @@ target_link_libraries(ceph-common ${ceph_common_deps}) set_target_properties(ceph-common PROPERTIES SOVERSION 0 INSTALL_RPATH "") +if(NOT APPLE) + # Apple uses Mach-O, not ELF. so this option does not apply to APPLE. + # + # prefer the local symbol definitions when binding references to global + # symbols. otherwise we could reference the symbols defined by the application + # with the same name, instead of using the one defined in libceph-common. + # in other words, we require libceph-common to use local symbols, even if redefined + # in application". + set_property( + TARGET ceph-common + APPEND APPEND_STRING + PROPERTY LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions") +endif() + install(TARGETS ceph-common DESTINATION ${CMAKE_INSTALL_PKGLIBDIR}) if(${WITH_LTTNG}) -- 2.39.5