From 47ee3a029511acff0aa36b9d77c35e257fd20e6b Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 26 Mar 2021 13:37:01 +0100 Subject: [PATCH] When we were doing STATICC we were linking libdw dynamically, still requiring many dependencies. THis switches to libbfd, which should massively reduce the number of required libraries. --- CMakeLists.txt | 7 +++++-- src/Exception.hpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da96669..3c4e9a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ project(Arbutils) add_compile_options(-Wall -Wextra -Werror) # We like new stuff, so set the c++ standard to c++20. set(CMAKE_CXX_STANDARD 20) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) option(WINDOWS "Whether the build target is Windows or not." OFF) option(SHARED "Whether we should build a shared library, instead of a static one." OFF) @@ -49,7 +50,7 @@ endif() set(LINKS) if (NOT WINDOWS AND PRETTYTRACES) - set(LINKS ${LINKS} -ldw) + set(LINKS ${LINKS} -lbfd -ldl) ADD_DEFINITIONS(-DPRETTYTRACES=1) endif() if (SIGNAL_HANDLING) @@ -58,7 +59,9 @@ endif() # If we want to link the C and C++ library statically, link those as well. if (STATICC) - set(LINKS ${LINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread) + message("Linking dependencies statically.") + set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed") + set(LINKS -static-libgcc -static-libstdc++ -Wl,-Bstatic -lm -lstdc++ -lpthread -Wl,-Bdynamic ${LINKS}) endif(STATICC) target_link_libraries(Arbutils ${LINKS}) diff --git a/src/Exception.hpp b/src/Exception.hpp index e007735..1c3c561 100644 --- a/src/Exception.hpp +++ b/src/Exception.hpp @@ -3,7 +3,7 @@ #if !WINDOWS #if PRETTYTRACES -#define BACKWARD_HAS_DW 1 +#define BACKWARD_HAS_BFD 1 #endif #include "../extern/backward.hpp" #endif