From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id C517C3858C55 for ; Thu, 13 Oct 2022 12:05:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C517C3858C55 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E84D51FCF1; Thu, 13 Oct 2022 12:05:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1665662728; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ui+oNfy8VA8mR3c/35Rj2Hu5w45gl5hPNJiP+QDZfsA=; b=kdJPKFMp8gvmlkkHZ++VhiVq9h63I19qiQbh9Ekc09xEH5gWTsi770ySASz3s/oZkY/ysc Mb/jmqAXes+dXBjfkwhkVR5mbPakzE6w65UFc2z0TQI1onGA6mMsUhTeQ9mSmYPbd06Vyh ObowS48/Fo2BtCyXHdWpMtJybjLulEQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1665662728; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ui+oNfy8VA8mR3c/35Rj2Hu5w45gl5hPNJiP+QDZfsA=; b=Mbcjvzqjb2jYoSm7cFQSXqXpXSQMacMxWUKTap9pBbYgWm5qS2qHtuheUO+ygEjuakfo0q OFMEPh/xydAuRpDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B45F6139F3; Thu, 13 Oct 2022 12:05:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RDnXKQj/R2OrdwAAMHmgww (envelope-from ); Thu, 13 Oct 2022 12:05:28 +0000 Message-ID: Date: Thu, 13 Oct 2022 14:05:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] include: Declare getopt function on old GNU libc Content-Language: en-US To: Tsukasa OI , Nick Clifton Cc: binutils@sourceware.org, Mark Wielaard References: <6e4defd8-b02b-9084-afe6-ba22fe75e3d7@irq.a4lg.com> <8ab93d7a617ad480dd786210f46db0e5aa07d1ac.1665655719.git.research_trasio@irq.a4lg.com> From: Tom de Vries In-Reply-To: <8ab93d7a617ad480dd786210f46db0e5aa07d1ac.1665655719.git.research_trasio@irq.a4lg.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/13/22 12:11, Tsukasa OI wrote: > On GNU libc <= 2.25, includes with __need_getopt macro > defined. That is intended to be a part of GNU libc but > actually includes include/getopt.h in this project. > > If HAVE_DECL_GETOPT is defined to 1 and include/getopt.h is included from > GNU libc's , declaration of getopt is suppressed, causing errors > on getopt callers. This issue is possibly hidden so long because there are > not so many true getopt callers in Binutils, GDB and GCC. Still, this issue > needs to be fixed for following components: > > - Binutils: gprofng > (not currently affected due to the configuration script but will be) > - GDB (sim): M32C simulator > - GDB (sim): RL78 simulator > > To avoid not defining proper getopt declaration, we have to check > __need_getopt macro to detect this include path. With this commit, even if > HAVE_DECL_GETOPT is 1, getopt is declared if: > > - The standard C library is GNU libc and > - __need_getopt macro is defined ( includes to > declare getopt function). > I've put this into the gdb try-buildbot, and it fixes the centos regression : https://builder.sourceware.org/buildbot/#/builders/118/builds/17 . I didn't get emails to that effect for some reason, but visual inspection at https://builder.sourceware.org/ of the try build bots at gdb shows all green. Thanks, - Tom > include/ChangeLog: > > * getopt.h: Detect special include path on GNU libc 2.25 or older > to prevent not declaring getopt function when necessary. > --- > include/getopt.h | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/include/getopt.h b/include/getopt.h > index d8103f97483..e941b811ace 100644 > --- a/include/getopt.h > +++ b/include/getopt.h > @@ -104,7 +104,14 @@ struct option > declaration without arguments. If it is 0, we checked and failed > to find the declaration so provide a fully prototyped one. If it > is 1, we found it so don't provide any declaration at all. */ > -#if !HAVE_DECL_GETOPT > +/* On GNU libc <= 2,25, includes with __need_getopt > + macro defined. That is intended to be a part of GNU libc > + but actually includes THIS getopt.h. If HAVE_DECL_GETOPT is > + defined to 1 and this file is included from GNU libc's , > + declaration of getopt is suppressed, causing errors on getopt callers. > + To avoid not defining proper getopt declaration, we have to check > + __need_getopt macro when built with GNU libc to detect this include path. */ > +#if !HAVE_DECL_GETOPT || (defined (__GNU_LIBRARY__) && defined (__need_getopt)) > #if defined (__GNU_LIBRARY__) || defined (HAVE_DECL_GETOPT) > /* Many other libraries have conflicting prototypes for getopt, with > differences in the consts, in unistd.h. To avoid compilation > > base-commit: 927b2f4caf46e5ca49684c9a52a9786425c60fa2