bug-autoconf
[Top][All Lists]
Advanced

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

Re: autoconf 2.63b: wrong macro expansion order


From: Eric Blake
Subject: Re: autoconf 2.63b: wrong macro expansion order
Date: Mon, 06 Apr 2009 06:46:57 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Andreas Schwab on 4/5/2009 9:22 AM:
>>From the POV of the macro writer the 2.63 behaviour does not look like a
> bug.  Basically the following two snippets:
> 
>     AC_DEFUN([FOO],[AC_COMPILE_IFELSE([])])
>     foobar=
>     AC_PROG_CC
>     FOO
> 
> and
> 
>     AC_DEFUN([FOO],[AC_COMPILE_IFELSE([])])
>     AC_DEFUN([BAR],[
>     foobar=
>     AC_PROG_CC
>     FOO])
>     BAR
> 
> are expected to be completely equivalent.

Unfortunately, that expectation is wrong, because of the existence of
AC_REQUIRE.  At this point, I think the only thing I can do is add some
documentation, in three places:

- - to AC_COMPILE_IFELSE to mention that it uses AC_REQUIRE (and thus that
its requirements will be hoisted outside the outermost AC_DEFUN macro if
they have not previously been met)

- - to AC_PROG_CC to mention that this macro is frequently required, that it
performs some checks only the first time it is used, and that if you NEED
text to occur before AC_PROG_CC that you should also use AC_REQUIRE to
guarantee ordering

- - to the expand-before-require section to give this example as an
excellent case study in why AC_DEFUN is NOT like function calls, along
with a demonstration of how to guarantee that the foobar= setting is
indeed hoisted prior to AC_PROG_CC expansion

I also think you should push a bug report to the KDE folks to point them
to this thread.  It is possible to write macros that avoid the
expand-before-require warning and the attendant out-of-order expansion in
2.63 or code duplication in 2.63b, and I will gladly help people find the
right way to do that, but I don't see how I can change AC_DEFUN/AC_REQUIRE
semantics without breaking the fix that I added to 2.63b and still support
the expectation that the KDE folks seem to be relying on.

>  In other words, you should be
> able to replace an arbitrary block of text with a macro call and get
> exactly the same behaviour.

Only if that macro call was created with m4_define, and NOT with AC_DEFUN.
 AC_DEFUN has special properties, in that text is reordered due to
AC_REQUIRE.  In the above case, if you do m4_define([BAR]) instead of
AC_DEFUN([BAR]), you will get the semantics you want.

> 
> If autoconf macros were implemented in terms of shell functions this
> would probably be easy to achieve.
> 
> Andreas.
> 

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknZ9gMACgkQ84KuGfSFAYCtzgCfRnfwczyJbqIOdMt9TJo8aDne
uBYAnR5VUVLhnmOA4ch8AFIGxDvaWwyw
=uaGD
-----END PGP SIGNATURE-----




reply via email to

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