bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Missing -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 in pkg-config files in


From: Thomas Dickey
Subject: Re: Missing -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 in pkg-config files in Clang + LLVM environment?
Date: Sat, 10 Sep 2022 11:48:01 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Sat, Sep 10, 2022 at 02:47:50PM +0100, Sam James wrote:
> 
> 
> > On 10 Sep 2022, at 14:11, Thomas Dickey <dickey@his.com> wrote:
> > 
> > On Fri, Sep 09, 2022 at 01:49:05AM +0100, Sam James wrote:
> >> 
> >> 
> >>> On 9 Sep 2022, at 01:02, Sam James <sam@gentoo.org> wrote:
> >>> [snip]
> >>> 
> >>>>> This is on a musl + Clang system (details below for how
> >>>>> to reproduce).
> >>>> 
> >>>> none of the systems that I develop on have musl.
> >>>> (you're free to submit a patch, if you use musl).
> >>>> 
> >>> 
> >>> Thanks, I'll take a look.
> >> 
> >> So, if I just do e.g.
> >> ```
> >> --- a/Ada95/aclocal.m4
> >> +++ b/Ada95/aclocal.m4
> > 
> > actually that would be the top-level aclocal.m4 (this particular file
> > is used for building AdaCurses separately from the main sources).
> 
> Right, I just patched all the files identically but changed
> some so copied that part to illustrate an example change.
> 
> > 
> >> @@ -5056,6 +5056,9 @@ case "$host_os" in
> >>    cf_xopen_source="-D_SGI_SOURCE"
> >>    cf_XOPEN_SOURCE=
> >>    ;;
> >> +(linux*musl*)
> >> +  CF_TRY_XOPEN_SOURCE
> >> +  ;;
> > 
> > that part looks right
> > 
> >> (linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
> >>    CF_GNU_SOURCE($cf_XOPEN_SOURCE)
> >>    ;;
> >> ```
> >> 
> >> It's insufficient because it thinks we don't need to set it.
> >> 
> >> Apparently this is because when building a test program
> >> with
> >> #include <stdlib.h>
> >> #include <string.h>
> >> #include <sys/types.h>
> >> This ends up enabling XOPEN_SOURCE (some header
> >> is defining it, I guess).

one or more of these should be defining _XOPEN_SOURCE
(I'd expect the first, of course).

However, just because some header defines _XOPEN_SOURCE is only a hint.
A lot of that happens to be copy/paste without actually matching the
standard.  So the test-compiles add a little extra to flush out some
of that.

The string.h is there because it helped with the IRIX64 port.

(I could have included unistd.h rather than sys/stat.h as a double-check).

> >> Is there a reason those headers are used for the tiny test
> >> programs?
> > 
> > The test-programs all can be built separately from the main sources.
> > (That's done so they can be compared with other versions of ncurses,
> > as well as other implementations of curses).
> 
> Sorry, I meant "test programs" as in "programs configure builds
> for detecting macros and such".
> 
> > 
> >> If I drop them from the include like so, all is well,
> >> and configure adds XOPEN_SOURCE appropriately:
> >> 
> >> ```
> >> --- a/aclocal.m4
> >> +++ b/aclocal.m4
> >> @@ -8377,9 +8377,6 @@ dnl can define it successfully.
> >> AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
> >> AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
> >>    AC_TRY_COMPILE([
> >> -#include <stdlib.h>
> >> -#include <string.h>
> >> -#include <sys/types.h>
> > 
> > I'd have to see what config.log showed, to advise on how to work around
> > whatever problem exists with musl.  Omitting the standard headers is
> > not an improvement...
> 
> Sure, ask and ye:
> * Vanilla config.log (no patches): 
> https://dev.gentoo.org/~sam/tmp/ncurses-musl-config.log-2022-09-10
> * Patched (patch here to only add CF_TRY_XOPEN_SOURCE which proves 
> insufficient(?):, 
> https://dev.gentoo.org/~sam/tmp/ncurses-musl-patch-2022-09-10, config.log: 
> https://dev.gentoo.org/~sam/tmp/ncurses-musl-config.log-patched-2022-09-10)
> 
> If you need anything else, just ask. Happy to provide.
> 
> And yes, that's why I asked about why the headers were there in the first
> place. Could you tell me why they're there? For certain configure tests, it 
> just seems like
> they're introducing contagion. We're not using anything from them in this 
> configure test?
> Or what am I missing?

If all of those platforms followed the standards, the tests could be simpler.
But that doesn't happen in practice.
 
> > 
> >> ],[
> >> #ifndef _XOPEN_SOURCE
> >> make an error
> >> @@ -8388,9 +8385,6 @@ make an error
> >>    [cf_save="$CPPFLAGS"
> >>     CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
> >>     AC_TRY_COMPILE([
> >> -#include <stdlib.h>
> >> -#include <string.h>
> >> -#include <sys/types.h>
> >> ],[
> >> #ifdef _XOPEN_SOURCE
> >> make an error
> >> @@ -9915,6 +9909,9 @@ case "$host_os" in
> >>    cf_xopen_source="-D_SGI_SOURCE"
> >>    cf_XOPEN_SOURCE=
> >>    ;;
> >> +(linux*musl*)
> >> +  CF_TRY_XOPEN_SOURCE
> >> +  ;;
> >> (linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
> >>    CF_GNU_SOURCE($cf_XOPEN_SOURCE)
> >>    ;;
> >> ```
> >> 
> >> 
> >>> 
> >>> Best,
> >>> sam
> >> 
> > 
> > 
> > 
> > --
> > Thomas E. Dickey <dickey@invisible-island.net>
> > https://invisible-island.net
> > ftp://ftp.invisible-island.net
> 



-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]