Skip to content

Commit

Permalink
CMakeLists: Build library with -fvisibility=protected
Browse files Browse the repository at this point in the history
This reduces the number of dynamic relocs by nearly 50%. Unfortunately
doing so causes errors like:
 /usr/bin/ld: CMakeFiles/dbus-asio.dir/src/dbus_auth.cpp.o: relocation R_X86_64_PC32 against protected symbol `_ZN4DBus22AuthenticationProtocol4onOKERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' can not be used when making a shared object

when linking with ld.bfd. Let's use gold instead, which doesn't suffer
from that problem.
  • Loading branch information
philb authored and mikecrowe committed Jul 21, 2021
1 parent d553f8f commit 9f2cb2d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.7.1)

project(dbus-asio VERSION 1.0.0)

set(CMAKE_CXX_VISIBILITY_PRESET protected)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")

set(HEADER_FILES
src/dbus_auth.h
src/dbus.h
Expand Down

0 comments on commit 9f2cb2d

Please sign in to comment.