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 D2CDB3938C30 for ; Fri, 1 May 2020 14:26:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D2CDB3938C30 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.220.254]) by mx2.suse.de (Postfix) with ESMTP id D93A2AE72 for ; Fri, 1 May 2020 14:26:20 +0000 (UTC) Date: Fri, 1 May 2020 16:26:19 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Compile compile-ifunc.c with -Wno-attribute-alias Message-ID: <20200501142617.GA31389@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=-27.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2020 14:26:24 -0000 Hi, Consider the following test-case: ... $ cat 1.c typedef int (*final_t) (int arg); int final (int arg) { return arg + 1; } final_t gnu_ifunc (void) { return final; } int gnu_ifunc_alias (int) __attribute__ ((ifunc ("gnu_ifunc"))); int main (void) { return gnu_ifunc_alias (10); } ... with result: ... $ gcc 1.c $ ./a.out; echo $? 11 ... The test-case uses the ifunc attribute, but there's another solution using %gnu_indirect_function. Consider 2.c and 3.c: ... $ cat 2.c typedef int (*final_t) (int arg); int final (int arg) { return arg + 1; } asm (".type gnu_ifunc, %gnu_indirect_function"); final_t gnu_ifunc (void) { return final; } $ cat 3.c extern int gnu_ifunc (int); int main (void) { return gnu_ifunc (10); } ... However, it can be inconvenient to have seperate files for the incompatible decls of gnu_ifunc, so we can use this in a single file like this: ... $ cat 4.c typedef int (*final_t) (int arg); int final (int arg) { return arg + 1; } asm (".type gnu_ifunc, %gnu_indirect_function"); final_t gnu_ifunc (void) { return final; } extern int gnu_ifunc_alias (int arg) __attribute__ ((alias ("gnu_ifunc"))); int main (void) { return gnu_ifunc_alias (10); } ... This alias trick works ok at -O0, but not at -O2: ... $ gcc 4.c $ ./a.out; echo $? 11 $ gcc 4.c $ ./a.out; echo $? 176 ... and produces a warning with gcc-8 and later: ... $ gcc-8 4.c 4.c:7:12: warning: 'gnu_ifunc_alias' alias between functions of incompatible \ types 'int(int)' and 'int (*(void))(int)' [-Wattribute-alias] extern int gnu_ifunc_alias (int arg) __attribute__ ((alias ("gnu_ifunc"))); ^~~~~~~~~~~~~~~ 4.c:5:9: note: aliased declaration here final_t gnu_ifunc (void) ^~~~~~~~~ ... The warning is correct, but the mismatch is intentional. The last variant (%gnu_indirect_function + alias) is used in gdb.compile/compile-ifunc.c, so we run into the warning with recent gcc. Fix the warning by compiling with -Wno-attribute-alias. Tested the test-case on x86_64-linux with gcc-10, and observed I no longer see the warning: ... Running src/gdb/testsuite/gdb.compile/compile-ifunc.exp ... === gdb Summary === nr of untested testcases 1 ... Any comments? Thanks, - Tom [gdb/testsuite] Compile compile-ifunc.c with -Wno-attribute-alias gdb/testsuite/ChangeLog: 2020-05-01 Tom de Vries * gdb.compile/compile-ifunc.exp: Use -Wno-attribute-alias. --- gdb/testsuite/gdb.compile/compile-ifunc.exp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.compile/compile-ifunc.exp b/gdb/testsuite/gdb.compile/compile-ifunc.exp index ff81e2f87aa..4b482b8245c 100644 --- a/gdb/testsuite/gdb.compile/compile-ifunc.exp +++ b/gdb/testsuite/gdb.compile/compile-ifunc.exp @@ -19,9 +19,12 @@ if {[skip_ifunc_tests]} { standard_testfile +set flags additional_flags=-Wno-attribute-alias + with_test_prefix "nodebug" { - if { [prepare_for_testing "failed to prepare" "$testfile-nodebug" $srcfile {}] } { + if { [prepare_for_testing "failed to prepare" "$testfile-nodebug" \ + $srcfile $flags] } { return -1 } @@ -51,7 +54,8 @@ with_test_prefix "nodebug" { with_test_prefix "debug" { - if { [prepare_for_testing "failed to prepare" "$testfile-debug" $srcfile] } { + if { [prepare_for_testing "failed to prepare" "$testfile-debug" \ + $srcfile "debug $flags"] } { return -1 }