From aa9a1956653d3cd3c218b87f7ecc4807cc12454d Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 2 Jan 2019 06:02:31 -0700 Subject: [PATCH] CMake: Stop CMake from adding -rdynamic by default --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5d8274d8c..5793c47c26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,13 @@ if(WIN32) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() +# CMake will often pass -rdynamic when linking executables as a convenience for +# projects that might forget when to use ENABLE_EXPORTS. This is preposterous, +# since it prevents the linker from removing symbols unneeded by the executable +# and stops us from identifying cases where ENABLE_EXPORTS is needed. +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + # As long as we're figuring out compiler flags, figure out the flags for # turning C++ exception support on and off if(MSVC)