diff --git a/bin/estrip b/bin/estrip index 3ac6a1692..2d9d50922 100755 --- a/bin/estrip +++ b/bin/estrip @@ -15,8 +15,8 @@ exp_tf() { eval ${var}_${flag}=$(tf has ${flag} ${!var}) done } -exp_tf FEATURES compressdebug installsources nostrip splitdebug xattr -exp_tf PORTAGE_RESTRICT binchecks installsources splitdebug strip +exp_tf FEATURES compressdebug dedupdebug installsources nostrip splitdebug xattr +exp_tf PORTAGE_RESTRICT binchecks dedupdebug installsources splitdebug strip if ! ___eapi_has_prefix_variables; then EPREFIX= ED=${D} @@ -201,6 +201,10 @@ fi [[ ${debugedit} ]] && debugedit_found=true || debugedit_found=false debugedit_warned=false +dwz=$(type -P dwz) +[[ ${dwz} ]] && dwz_found=true || dwz_found=false +dwz_warned=false + __multijob_init # Setup ${T} filesystem layout that we care about. @@ -248,6 +252,32 @@ __try_symlink() { die "failed to create symlink '${name}'" } +# Usage: dedup_elf_debug +dedup_elf_debug() { + ${FEATURES_dedupdebug} || return 0 + ${PORTAGE_RESTRICT_dedupdebug} && return 0 + + debug-print-function "${FUNCNAME}" "$@" + + if ! ${dwz_found} ; then + if ! ${dwz_warned} ; then + dwz_warned=true + ewarn "FEATURES=dedupdebug is enabled but the dwz binary could not be" + ewarn "found. This feature will not work unless dwz is installed!" + fi + return 0 + fi + + local src=$1 # File to dedup debug symbols + local inode_dedupdebug=$2 # Temp path for hard link tracking + + # We already dedupdebug-ed this inode. + [[ -L ${inode_dedupdebug} ]] && return 0 + + "${dwz}" -- "${src}" + touch "${inode_dedupdebug}" +} + # Usage: save_elf_debug [splitdebug] save_elf_debug() { ${FEATURES_splitdebug} || return 0 @@ -355,6 +385,7 @@ process_elf() { xt_data=$(dump_xattrs "${x}") fi save_elf_sources "${x}" + dedup_elf_debug "${x}" "${inode_link}_dedupdebug" fi if ${strip_this} ; then diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py index c81bf54a8..3b366f39c 100644 --- a/lib/_emerge/EbuildPhase.py +++ b/lib/_emerge/EbuildPhase.py @@ -67,6 +67,7 @@ class EbuildPhase(CompositeTask): _features_display = ( "ccache", "compressdebug", + "dedupdebug", "distcc", "fakeroot", "installsources", diff --git a/lib/portage/const.py b/lib/portage/const.py index 1f468a1ab..2154213b7 100644 --- a/lib/portage/const.py +++ b/lib/portage/const.py @@ -176,6 +176,7 @@ SUPPORTED_FEATURES = frozenset( "compressdebug", "compress-index", "config-protect-if-modified", + "dedupdebug", "digest", "distcc", "distlocks",