From e510e767e4861be955cefdc7187ddd875d1e6a9e Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Wed, 2 Sep 2020 11:21:09 +0200 Subject: Strip binaries more aggressively (#41039) * Strip binaries more aggressively We are currently stripping only debug symbols, but there are also other symbols that can be stripped without affecting debuggability or anything else. We were stripping the binaries in corefx that way in the past, but some time ago we have unified the stripping between the former three repos and started to strip just the debugging symbols. This change strips all unneeded symbols, which results in significant reduction of the binaries sizes. For example, libcoreclr.so went down from 8732272 to 7027024 or libSystem.Security.Cryptography.Native.OpenSsl.so went down from 163376 to 120952. * Fix FreeBSD * Fix FreeBSD and OSX We use nm command to extract g_dacTable symbol value from libcoreclr for the DAC purposes. On OSX, there are no dynamic symbols, on FreeBSD, the stripping strips all regular symbols and leaves dynamic ones only. So the nm needs to get a -D argument for non OSX. --- eng/native/functions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'eng/native/functions.cmake') diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index 1bdcf1ddd38..420b7d1a88f 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -323,7 +323,7 @@ function(strip_symbols targetName outputFilename) POST_BUILD VERBATIM COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file} - COMMAND ${CMAKE_OBJCOPY} --strip-debug ${strip_source_file} + COMMAND ${CMAKE_OBJCOPY} --strip-unneeded ${strip_source_file} COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file} COMMENT "Stripping symbols from ${strip_source_file} into file ${strip_destination_file}" ) -- cgit v1.2.3