Re: Use system extensions conditionally?

2014-03-03 Thread Eric Blake
On 03/01/2014 08:32 PM, Fredrik Tolf wrote:
 On Thu, 27 Feb 2014, Eric Blake wrote:
 Isn't it ugly, then, to always enable system extensions, regardless
 of environment?

 No.  Most programs WANT to blindly turn on all extensions, regardless of
 environment, because it is easier to write programs that can take
 advantage of extensions, regardless of how cavalier the system is about
 namespace pollution even when extensions are not requested.
 [...]
 There is a small set of projects that really DOES want to remain
 completely POSIX-compliant (or even stricter ANSI-C compliant) - those
 programs do NOT want to request extensions by default, so that they
 minimize namespace pollution from system headers.  But they tend to be
 the minority.
 
 Thanks for your reply!
 
 I've been mulling over it for a while now, but I still don't think I
 quite get it. In particular, I'm still not in the clear about what
 AC_USE_SYSTEM_EXTENSIONS really does.
 
 I read what you write kind of as if systems shouldn't expose anything
 non-POSIX as long as it isn't used, but this is clearly not the case;
 not only with funopen() on *BSD, but also with e.g. epoll() on
 GNU/Linux, or just such things as GCC C extensions.

How do you get epoll() on GNU/Linux?  By including sys/epoll.h, but
that's a header that is not mentioned in POSIX.  Therefore, a strictly
conforming program CANNOT use this interface, and therefore there is no
reason to gate that header by _GNU_SOURCE, therefore, there is no need
to use AC_USE_SYSTEM_EXTENSIONS to make use of the interface.

On the other hand, BSD's funopen() is exposed in stdio.h, which IS a
standard header; but the name funopen() is not in the list of reserved
name patterns in POSIX.  Therefore, if BSD wants to comply with POSIX,
then when _POSIX_C_SOURCE is defined before including stdio.h, then
funopen() must NOT be visible to a user of stdio.h.  Now, not everyone
cares about being strictly POSIX-compliant, so the default behavior,
when you don't request extensions, might have names leaked into the
environment.  But on the converse side, when you KNOW you want to use
extensions, you are best off to explicitly request those extensions.
And if you are going to use non-POSIX extensions, you might as well use
all extensions on all platforms, all in one go.

 
 As such, it seems to me that there are basically three different modes
 of operation: Standards-compliant mode, enabled explicitly by setting
 POSIXLY_CORRECT or similar; extensions mode, enabled explicitly by using
 AC_USE_SYSTEM_EXTENSIONS; and also default mode, which is what we have
 if we don't do any of those.

Yes, a fairly reasonable summary (setting POSIXLY_CORRECT alone is not
enough to guarantee a strictly conforming environment, but might be part
of the steps on some platforms, confstr() can be used to determine
whether POSIXLY_CORRECT is required.  Another required step in a
strictly conforming setup is to pre-define _POSIX_C_SOURCE to the
correct value prior to including any system headers).

 
 Seeing as how there are a lot of extensions available in default mode, I
 don't really see what the formal distinction between default mode and
 extensions mode. I'm willing to buy that there is no formally defined
 distinction between the two, and that the, perhaps arguably sloppy,
 nature of systems development leaves things a bit unclear. But if that
 is so, isn't it still ugly to have to use AC_USE_SYSTEM_EXTENSIONS
 always, on all systems, rather than being left the option of using
 whatever the system considers to be its default environment?

glibc is one of the best systems out there that is actively trying to
minimize namespace pollution in default mode.  BSD is slowly catching
up, but not there yet.  Relying on the default environment is risky -
something that might be polluted into the namespace today could
disappear tomorrow if the system headers get patched to provide less
pollution.  Explicitly requesting extensions is the only way to ensure
that your program that takes advantage of the extensions will not be
broken by changes to the default mode.


-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
___
Autoconf mailing list
Autoconf@gnu.org
https://lists.gnu.org/mailman/listinfo/autoconf


Re: Use system extensions conditionally?

2014-03-03 Thread Russ Allbery
Eric Blake ebl...@redhat.com writes:

 On the other hand, BSD's funopen() is exposed in stdio.h, which IS a
 standard header; but the name funopen() is not in the list of reserved
 name patterns in POSIX.  Therefore, if BSD wants to comply with POSIX,
 then when _POSIX_C_SOURCE is defined before including stdio.h, then
 funopen() must NOT be visible to a user of stdio.h.  Now, not everyone
 cares about being strictly POSIX-compliant, so the default behavior,
 when you don't request extensions, might have names leaked into the
 environment.  But on the converse side, when you KNOW you want to use
 extensions, you are best off to explicitly request those extensions.
 And if you are going to use non-POSIX extensions, you might as well use
 all extensions on all platforms, all in one go.

Of course, one of the drawbacks is that you have an all-or-nothing
situation.  Either you have to stick to only POSIX interfaces, or you have
to give the local system carte blanche to stomp all over your namespace,
possibly resulting in code breakage down the line when some new local
extension is introduced that conflicts with your code.

This of course isn't a problem that Autoconf can solve.  It's basically
inherent in how the feature test macros work.  But it's worth being aware
of.  All namespace bets are essentially off once you enable system
extensions.

-- 
Russ Allbery (ea...@eyrie.org)  http://www.eyrie.org/~eagle/

___
Autoconf mailing list
Autoconf@gnu.org
https://lists.gnu.org/mailman/listinfo/autoconf


Re: Use system extensions conditionally?

2014-03-03 Thread Nick Bowler
On 2014-03-03 13:50 -0800, Russ Allbery wrote:
 Eric Blake ebl...@redhat.com writes:
 
  On the other hand, BSD's funopen() is exposed in stdio.h, which IS a
  standard header; but the name funopen() is not in the list of reserved
  name patterns in POSIX.  Therefore, if BSD wants to comply with POSIX,
  then when _POSIX_C_SOURCE is defined before including stdio.h, then
  funopen() must NOT be visible to a user of stdio.h.  Now, not everyone
  cares about being strictly POSIX-compliant, so the default behavior,
  when you don't request extensions, might have names leaked into the
  environment.  But on the converse side, when you KNOW you want to use
  extensions, you are best off to explicitly request those extensions.
  And if you are going to use non-POSIX extensions, you might as well use
  all extensions on all platforms, all in one go.
 
 Of course, one of the drawbacks is that you have an all-or-nothing
 situation.  Either you have to stick to only POSIX interfaces, or you have
 to give the local system carte blanche to stomp all over your namespace,
 possibly resulting in code breakage down the line when some new local
 extension is introduced that conflicts with your code.
 
 This of course isn't a problem that Autoconf can solve.  It's basically
 inherent in how the feature test macros work.  But it's worth being aware
 of.  All namespace bets are essentially off once you enable system
 extensions.

Even without the use of system extensions Autoconf makes no attempt to
enable standards-conformance mode in compilers, and most of them stomp
all over the application namespace by default.  So all namespace bets
are off with or without AC_ENABLE_SYSTEM_EXTENSIONS.

For a concrete example, try to declare a variable called unix on a
typical GNU/Linux system...

Cheers,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)

___
Autoconf mailing list
Autoconf@gnu.org
https://lists.gnu.org/mailman/listinfo/autoconf


Re: Wrong quoting by autoreconf?

2014-03-03 Thread Philipp Thomas
* Eric Blake (ebl...@redhat.com) [20140228 17:21]:

 Can you post the actual error you got from your shell?
 line numbers, can you also post actual context from the configure file
 around that line number?

I'll see if I can reproduce it, which I assume I can. In that case I'll post
the relevant part of config.log

Is this a case of using $use_tcl later on without proper shell quoting?

I'm not sure yet. I'll be back with more precise data.

Philipp