From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.CeBiTec.Uni-Bielefeld.DE (smtp.CeBiTec.Uni-Bielefeld.DE [129.70.160.84]) by sourceware.org (Postfix) with ESMTPS id DF2053858D35 for ; Tue, 6 Feb 2024 10:33:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DF2053858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cebitec.uni-bielefeld.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DF2053858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=129.70.160.84 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707215603; cv=none; b=C0MwHCeXdJWT1m6qmR60kUnVILWoMtulpIFB9vphtH/wfdcIBVznRLQ9BSDQ264Y3PfnFapXQDFjXRZwH9CXnbtP9eGU7ne/IWWnUDzwJuxl3mNOkDNfSZvbqU7WSc72e30DaKZfLiPFD2JOUvm4EKk3tMi209SFymbnaplLqOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707215603; c=relaxed/simple; bh=pAXLaw8hhW8B47MzKgnEOF3xjkbimd81VmK3sCjfLn0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=i181E3CP1JQFl4wCjWULGgTUFR7ujhtMKr+es0E5aWmNUpW7SkLfH7KB44/irKeyGQWm2RnzHwNlRbswpG9mzrnnmRovgP2dkS4jY4KpzEkMQMNIzNPrFhFMfUEPMTnVBB3pXRT9PWgUn0R5Zqa8GSKopPzkGdjfbWdY+30U3XI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 5BE80B01EE; Tue, 6 Feb 2024 11:33:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= cebitec.uni-bielefeld.de; h=content-type:content-type :mime-version:user-agent:message-id:in-reply-to:date:date :references:subject:subject:from:from:received:received; s= 20200306; t=1707215598; bh=pAXLaw8hhW8B47MzKgnEOF3xjkbimd81VmK3s CjfLn0=; b=WQAT7ARn18nR2tpKm4MiF/Pt3QI7RWMXPGBzGRnp/0bXcMYj2zpfT NmPPmUltU/IdylMPcikisT6zsdU3PJdvX2c28Ch/vILLxpzukjMDFgXkmf4/eLst NGRCYlMDNB1Ieqi4TvEJuvJoImECoudaa7l1V4CBa9WyVT+uGlvV0hE2HlNkstLV AlPID55+upq08/VmjNmu0IikGHIO4pGTaXT/qslTvJAcyD1CCr5sNDfPqcfOTwdL bmFDSrGFh02myeoyF4j5pKdmv5VuoDZoZqFcUDkfyzEDgBrj9nb1x8kN6hs6suvM pLoP99QGNHuW6DIBTYAGYq+FGLCH/G79w== X-Virus-Scanned: amavisd-new at cebitec.uni-bielefeld.de Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (smtp.cebitec.uni-bielefeld.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id EQK73bkspkrl; Tue, 6 Feb 2024 11:33:18 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p5085539e.dip0.t-ipconnect.de [80.133.83.158]) (Authenticated sender: ro) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id 4E114B01E9; Tue, 6 Feb 2024 11:33:18 +0100 (CET) From: Rainer Orth To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] libssp: Fix gets-chk.c compilation on Solaris References: Date: Tue, 06 Feb 2024 11:33:17 +0100 In-Reply-To: (Jakub Jelinek's message of "Thu, 7 Dec 2023 13:59:46 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1.90 (usg-unix-v) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Status: No, score=-3790.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,KAM_ASCII_DIVIDERS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: --=-=-= Content-Type: text/plain Hi Jakub, sorry for dropping the ball on this. > On Mon, Dec 04, 2023 at 11:42:09AM +0100, Rainer Orth wrote: >> The recent warning patches broke the libssp build on Solaris: >> >> /vol/gcc/src/hg/master/local/libssp/gets-chk.c: In function '__gets_chk': >> /vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: implicit >> declaration of function 'gets'; did you mean 'getw'? >> [-Wimplicit-function-declaration] >> 67 | return gets (s); >> | ^~~~ >> | getw >> /vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: returning >> 'int' from a function with return type 'char *' makes pointer from >> integer without a cast [-Wint-conversion] >> 67 | return gets (s); >> | ^~~~~~~~ >> /vol/gcc/src/hg/master/local/libssp/gets-chk.c:74:12: error: returning >> 'int' from a function with return type 'char *' makes pointer from >> integer without a cast [-Wint-conversion] >> 74 | return gets (s); >> | ^~~~~~~~ >> >> The guard around the gets declaration in gets-chk.c is >> >> #if !(!defined __USE_ISOC11 \ >> || (defined __cplusplus && __cplusplus <= 201103L)) >> extern char *gets (char *); >> #endif >> >> __USE_ISOC11 is a glibc-only thing, while Solaris >> declares gets like >> >> #if __STDC_VERSION__ < 201112L && __cplusplus < 201402L >> extern char *gets(char *) __ATTR_DEPRECATED; >> #endif >> >> If one needs to check __USE_ISO11 at all, one certainly needs to check >> __STDC_VERSION__ to avoid breaking every non-glibc target. Besides, I >> don't see what's the use of checking __cplusplus when compiling a C-only >> source file. On top of all that, the double negation makes the guard >> unnecessarily hard to understand. >> >> I really don't know if it's useful/appropriate to check __USE_ISOC11 and >> __cplusplus here at all; still I've left both for now. >> >> Here's what I've used to complete the Solaris bootstrap. >> >> Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, >> x86_64-pc-linux-gnu, and x86_64-apple-darwin23.1.0. >> >> -- >> ----------------------------------------------------------------------------- >> Rainer Orth, Center for Biotechnology, Bielefeld University >> >> >> 2023-12-03 Rainer Orth >> >> libssp: >> * gets-chk.c (gets): Avoid double negation. >> Also check __STDC_VERSION__ >= 201112L. >> > >> # HG changeset patch >> # Parent 334015ab01f6c0e5af821c1e9bc83b8677cc0bfb >> libssp: Fix gets-chk.c compilation on Solaris >> >> diff --git a/libssp/gets-chk.c b/libssp/gets-chk.c >> --- a/libssp/gets-chk.c >> +++ b/libssp/gets-chk.c >> @@ -51,8 +51,9 @@ see the files COPYING3 and COPYING.RUNTI >> # include >> #endif >> >> -#if !(!defined __USE_ISOC11 \ >> - || (defined __cplusplus && __cplusplus <= 201103L)) >> +#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) \ >> + || !defined __USE_ISOC11 \ >> + || (defined __cplusplus && __cplusplus >= 201402L) > > The above isn't equivalent. Avoiding double negation would mean > #if (defined __USE_ISOC11 \ > && !(defined __cplusplus && __cplusplus <= 201103L)) > or > #if (defined __USE_ISOC11 \ > && (!defined __cplusplus || __cplusplus > 201103L)) > No? > __USE_ISOC11 is defined as > /* This is to enable the ISO C11 extension. */ > #if (defined _ISOC11_SOURCE || defined _ISOC2X_SOURCE \ > || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) > # define __USE_ISOC11 1 > #endif > where _ISOC11_SOURCE or _ISOC2X_SOURCE are defined whenever _GNU_SOURCE > is or when user defines them, or __USE_ISOC11 is also defined for > if __cplusplus >= 201703L. > > Obviously, if you add that > (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) > it will mean it will be prototyped always (as I think we compile it without > any -std= flags). > > What about using what we had for glibc (or even better, expect gets > to be declared for glibc < 2.16) and use what you add for other libraries? > The file is written and compiled as C, so we don't need to bother with C++ > though. > So > #if (defined (__GLIBC_PREREQ) \ > ? (__GLIBC_PREREQ (2, 16) && defined (__USE_ISOC11)) \ > : (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) > ? > >> extern char *gets (char *); >> #endif this doesn't even compile on non-glibc targets: /vol/gcc/src/hg/master/local/libssp/gets-chk.c:55:24: error: missing binary operator before token "(" 55 | ? (__GLIBC_PREREQ (2, 16) && defined (__USE_ISOC11)) \ | Unless one really wants to go for ugly contortions like #ifdef __GLIBC_PREREQ # if __GLIBC_PREREQ (2, 16) && defined (__USE_ISOC11) # define NEED_DECL_GETS # endif #elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L # define NEED_DECL_GETS #endif #ifdef NEED_DECL_GETS I still think it's way easier and more reliable to just use the canonical autoconf test. Bootstrapped on i386-pc-solaris2.11, sparc-sun-solaris2.11, x86_64-pc-linux-gnu, x86_64-apple-darwin23.3.0, and amd64-pc-freebsd14.0. Ok for trunk? Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University 2023-12-07 Rainer Orth libssp: * configure.ac (AC_CHECK_DECLS): Check for gets. * configure, config.h.in: Regenerate. * gets-chk.c (gets): Guard declaration with !HAVE_DECL_GETS. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=sol2-libssp-gets.patch # HG changeset patch # Parent 334015ab01f6c0e5af821c1e9bc83b8677cc0bfb libssp: Fix gets-chk.c compilation on Solaris diffdiff --git a/libssp/configure.ac b/libssp/configure.ac --- a/libssp/configure.ac +++ b/libssp/configure.ac @@ -128,6 +128,7 @@ if test x$gcc_no_link = xyes; then else AC_CHECK_FUNCS(memmove mempcpy strncpy strncat) fi +AC_CHECK_DECLS([gets]) AC_MSG_CHECKING([whether vsnprintf is usable]) AC_RUN_IFELSE([AC_LANG_PROGRAM([ diff --git a/libssp/gets-chk.c b/libssp/gets-chk.c --- a/libssp/gets-chk.c +++ b/libssp/gets-chk.c @@ -51,8 +51,7 @@ see the files COPYING3 and COPYING.RUNTI # include #endif -#if !(!defined __USE_ISOC11 \ - || (defined __cplusplus && __cplusplus <= 201103L)) +#if !HAVE_DECL_GETS extern char *gets (char *); #endif --=-=-=--