From: Emil Velikov Date: Sun, 21 Nov 2021 14:50:25 +0000 (+0000) Subject: cmake: drop -rdynamic aka CMP0065 NEW X-Git-Tag: v3.6.0~25^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1b50bca40b0bb78f7250eef176a8a0a1464e2751;p=thirdparty%2Flibarchive.git cmake: drop -rdynamic aka CMP0065 NEW Prior to version 3.3 cmake would always use -rdynamic. That in itself causes all the internal symbols to be exported, increasing the binaries by 5-10% and making it impossible for the compiler to reason, optimise and discard unused code. The -rdynamic is useful in two cases: - having a third party module (say /usr/lib/foo/foobar.so) which is underlinked and depends on symbols from the main binary - apps like irssi, bash and zsh use that - uses the glibc backtrace, which relies on dlopen/dlsym to fetch the symbol data. Unwind is much better solution, since it replies on the DWARF data Our binaries do not use either of these - so drop the -rdynamic. The autotools build doesn't use it either. text data bss dec hex filename 229000 2120 4424 235544 39818 bsdcat -- before 208324 2120 4424 214868 34754 bsdcat -- after 1093939 12128 24176 1130243 113f03 bsdcpio -- before 1059181 12128 24176 1095485 10b73d bsdcpio -- after 1130091 14264 6608 1150963 118ff3 bsdtar -- before 1093690 14264 6608 1114562 1101c2 bsdtar -- after Signed-off-by: Emil Velikov --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a87d6154..ba0a7d5b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ # CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR) +if(POLICY CMP0065) + cmake_policy(SET CMP0065 NEW) #3.4 don't use `-rdynamic` with executables +endif() if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) #3.12.0 `find_package()`` uses ``_ROOT`` variables. endif()