From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 43E033858D29 for ; Mon, 22 Mar 2021 04:51:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 43E033858D29 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5658AAC1F; Mon, 22 Mar 2021 04:51:06 +0000 (UTC) Date: Mon, 22 Mar 2021 05:51:04 +0100 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org Subject: [committed] Make smaller-than.sh match dwz heuristic Message-ID: <20210322045103.GA13271@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2021 04:51:08 -0000 Hi, As reported in PR27603, when using clang-11 we run into: ... Running testsuite/dwz.tests/dwz-tests.exp ... + exec=start-gold + cp start-gold 1 + dwz 1 + smaller-than.sh 1 start-gold FAIL: testsuite/dwz.tests/pr24747.sh ... The files are the same size: ... $ ls -l start-gold tmp.pr24747.sh/1 -rwxr-xr-x 1 vries users 2024 Mar 18 11:58 start-gold -rwxr-xr-x 1 vries users 2024 Mar 18 11:58 tmp.pr24747.sh/1 ... but not the same: ... $ diff -q start-gold tmp.pr24747.sh/1 Files start-gold and tmp.pr24747.sh/1 differ ... The .debug_info size is smaller, by 6 bytes: ... [Nr] Name Type Address Off Size ES Flg Lk Inf Al -[ 6] .debug_info PROGBITS 00000000 0001cd 000040 00 0 0 1 +[ 6] .debug_info PROGBITS 00000000 0001cd 00003a 00 0 0 1 ... The size reduction in the .debug_info section happens not to result in a smaller file because subsequent sections .note.gnu.gold-version and .symtab have a bigger-than-one align. We could try to fix this by adapting the heuristic to not compress if the eventual file size is equal. Instead, fix this by making the smaller-than.sh test match the heuristic, which only looks at the size of some .debug sections. Committed to trunk. Thanks, - Tom Make smaller-than.sh match dwz heuristic 2021-03-22 Tom de Vries * testsuite/scripts/smaller-than.sh: Calculate size as sum of .debug sections. --- testsuite/scripts/smaller-than.sh | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/testsuite/scripts/smaller-than.sh b/testsuite/scripts/smaller-than.sh index b3672a5..ab06e3a 100755 --- a/testsuite/scripts/smaller-than.sh +++ b/testsuite/scripts/smaller-than.sh @@ -1,10 +1,40 @@ -#!/bin/sh +#!/bin/bash f1=$1 f2=$2 -s1=$(ls -l $f1 | awk '{print $5}') -s2=$(ls -l $f2 | awk '{print $5}') +section_size () +{ + local f="$1" + local section="$2" + + local s + s=$(readelf -S -W $f \ + | grep "\.debug_$section" \ + | sed 's/.*\.debug_//' \ + | awk '{print $5}') + + # Convert hex to decimal. + s=$(printf "%d" $((16#$s))) + + echo $s +} + +size () +{ + local f="$1" + + local total=0 + local section + for section in info abbrev str macro types; do + total=$(($total + $(section_size $f $section))) + done + + echo $total +} + +s1=$(size $f1) +s2=$(size $f2) if [ $s1 -ge $s2 ]; then exit 1