* [PATCH] libssp: Fix gets-chk.c compilation on Solaris @ 2023-12-04 10:42 Rainer Orth 2023-12-07 12:25 ` Rainer Orth 2023-12-07 12:59 ` Jakub Jelinek 0 siblings, 2 replies; 5+ messages in thread From: Rainer Orth @ 2023-12-04 10:42 UTC (permalink / raw) To: gcc-patches [-- Attachment #1: Type: text/plain, Size: 2173 bytes --] 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 <iso/stdio_iso.h> 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 <ro@CeBiTec.Uni-Bielefeld.DE> libssp: * gets-chk.c (gets): Avoid double negation. Also check __STDC_VERSION__ >= 201112L. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: sol2-libssp-gets.patch --] [-- Type: text/x-patch, Size: 600 bytes --] # 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 <string.h> #endif -#if !(!defined __USE_ISOC11 \ - || (defined __cplusplus && __cplusplus <= 201103L)) +#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) \ + || !defined __USE_ISOC11 \ + || (defined __cplusplus && __cplusplus >= 201402L) extern char *gets (char *); #endif ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libssp: Fix gets-chk.c compilation on Solaris 2023-12-04 10:42 [PATCH] libssp: Fix gets-chk.c compilation on Solaris Rainer Orth @ 2023-12-07 12:25 ` Rainer Orth 2023-12-07 12:59 ` Jakub Jelinek 1 sibling, 0 replies; 5+ messages in thread From: Rainer Orth @ 2023-12-07 12:25 UTC (permalink / raw) To: gcc-patches; +Cc: Jakub Jelinek, Richard Biener Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes: > 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 <iso/stdio_iso.h> > 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. Ping? It's only been four days, but without a fix Solaris bootstrap remains broken. In hindsight, I wonder if it wouldn't be better to just check for a gets declaration using AC_CHECK_DECLS, rather than second-guessing what guards various implementions use, even messing with implementation-private macros... Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libssp: Fix gets-chk.c compilation on Solaris 2023-12-04 10:42 [PATCH] libssp: Fix gets-chk.c compilation on Solaris Rainer Orth 2023-12-07 12:25 ` Rainer Orth @ 2023-12-07 12:59 ` Jakub Jelinek 2024-02-06 10:33 ` Rainer Orth 1 sibling, 1 reply; 5+ messages in thread From: Jakub Jelinek @ 2023-12-07 12:59 UTC (permalink / raw) To: Rainer Orth; +Cc: gcc-patches 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 <iso/stdio_iso.h> > 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 <ro@CeBiTec.Uni-Bielefeld.DE> > > 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 <string.h> > #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 Jakub ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libssp: Fix gets-chk.c compilation on Solaris 2023-12-07 12:59 ` Jakub Jelinek @ 2024-02-06 10:33 ` Rainer Orth 2024-02-06 10:38 ` Jakub Jelinek 0 siblings, 1 reply; 5+ messages in thread From: Rainer Orth @ 2024-02-06 10:33 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches [-- Attachment #1: Type: text/plain, Size: 5539 bytes --] 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 <iso/stdio_iso.h> >> 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 <ro@CeBiTec.Uni-Bielefeld.DE> >> >> 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 <string.h> >> #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 <ro@CeBiTec.Uni-Bielefeld.DE> libssp: * configure.ac (AC_CHECK_DECLS): Check for gets. * configure, config.h.in: Regenerate. * gets-chk.c (gets): Guard declaration with !HAVE_DECL_GETS. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: sol2-libssp-gets.patch --] [-- Type: text/x-patch, Size: 797 bytes --] # 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 <string.h> #endif -#if !(!defined __USE_ISOC11 \ - || (defined __cplusplus && __cplusplus <= 201103L)) +#if !HAVE_DECL_GETS extern char *gets (char *); #endif ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libssp: Fix gets-chk.c compilation on Solaris 2024-02-06 10:33 ` Rainer Orth @ 2024-02-06 10:38 ` Jakub Jelinek 0 siblings, 0 replies; 5+ messages in thread From: Jakub Jelinek @ 2024-02-06 10:38 UTC (permalink / raw) To: Rainer Orth; +Cc: gcc-patches On Tue, Feb 06, 2024 at 11:33:17AM +0100, Rainer Orth wrote: > 2023-12-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> > > libssp: > * configure.ac (AC_CHECK_DECLS): Check for gets. > * configure, config.h.in: Regenerate. > * gets-chk.c (gets): Guard declaration with !HAVE_DECL_GETS. Ok, thanks. Jakub ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-06 10:38 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-12-04 10:42 [PATCH] libssp: Fix gets-chk.c compilation on Solaris Rainer Orth 2023-12-07 12:25 ` Rainer Orth 2023-12-07 12:59 ` Jakub Jelinek 2024-02-06 10:33 ` Rainer Orth 2024-02-06 10:38 ` Jakub Jelinek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).