Package: debhelper Tags: patch See also #977596 filed for lintian.
dh_strip already strips the lto sections when stripping static archives, however it doesn't check that the archive has text sections containing the machine code. see https://github.com/rpm-software-management/rpmlint/blob/master/rpmlint/checks/BinariesCheck.py (_check_no_text_in_archive function) for an implementation. You can test this with e.g. xxhash, building with export DEB_CFLAGS_MAINT_APPEND = -flto=auto and export DEB_CFLAGS_MAINT_APPEND = -flto=auto -ffat-lto-objects I think it's better to fail the build, and not having an unusable .a in the package.
* dh_strip: For a static archive, test if any .text sections are non-empty. diff -Nru debhelper-13.3ubuntu1/dh_strip debhelper-13.3ubuntu2/dh_strip --- debhelper-13.3ubuntu1/dh_strip 2020-12-07 04:14:08.000000000 +0100 +++ debhelper-13.3ubuntu2/dh_strip 2020-12-17 15:11:12.000000000 +0100 @@ -394,6 +394,11 @@ '-R', '.gnu.lto_*', '-R', '.gnu.debuglto_*', '-N', '__gnu_lto_slim', '-N', '__gnu_lto_v1', $_); } + # https://github.com/rpm-software-management/rpmlint/blob/master/rpmlint/checks/BinariesCheck.py + # taken from _check_no_text_in_archive function + my $lto_check = "readelf -W --section-headers $_ | sed -n '/^ *\\[[ 0-9]*\]/s/ *\\[[ 0-9]*\\] *//p' | awk 'BEGIN {rv=1} /^NULL/ {next} \$1 ~ /^.(text|data|(preinit|init|fini)_array\$)/ {if (\$5 !~ /^0+\$/) rv=0} END { exit rv}'"; + verbose_print($lto_check); + system($lto_check) == 0 || error("lto-no-text-in-archive: $_"); } if (-d "$tmp/usr/lib/debug/.dwz" and ($use_build_id > 1 or ($dh{DEBUGPACKAGE} and $dh{DEBUGPACKAGE} ne $package))) { my @files = glob_expand(["$tmp/usr/lib/debug/.dwz"], \&glob_expand_error_handler_reject, '*');