From 2a66b88d0138f6555723b074e88a012db8437875 Mon Sep 17 00:00:00 2001 From: Jonathan Hamilton Date: Mon, 14 Aug 2017 14:09:32 -0700 Subject: [PATCH] Fix OPROFILE linux build with -Wl,--as-needed The opagent library was (incorrectly) marked as a dependency for "Core" instead of "Common". When linked with --as-needed, any symbols the linker can tell are not used are discarded. As the link is done in command-line order, and the Core library (and dependencies) are processed before Common, it would link in Core, then opagent, but as at that point no opagent symbols are used the whole opagent library would be discarded. Moving the opagent library to be a dependency of Common fixes this, as after the Common library is linked, there *are* opagent symbols used. --- Source/Core/Common/CMakeLists.txt | 4 ++++ Source/Core/Core/CMakeLists.txt | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 4f5c01e6a6..7d2950d570 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -119,6 +119,10 @@ endif() add_dolphin_library(common "${SRCS}" "${LIBS}") +if(OPROFILE_FOUND) + target_link_libraries(common PRIVATE ${OPROFILE_LIBRARIES}) +endif() + if(UNIX) # Posix networking code needs to be fixed for Windows add_executable(traversal_server TraversalServer.cpp) diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 04dbcf5848..8beb9e0506 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -345,10 +345,6 @@ if(TARGET Hidapi::Hidapi) add_definitions(-DHAVE_HIDAPI=1) endif() -if(OPROFILE_FOUND) - set(LIBS ${LIBS} ${OPROFILE_LIBRARIES}) -endif() - if(GDBSTUB) set(SRCS ${SRCS} PowerPC/GDBStub.cpp) endif()