[Top][All Lists]

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

Re: AC_PACKAGE_VERSION visibility slightly changed in autoconf-2.69c. Bu

From: Zack Weinberg
Subject: Re: AC_PACKAGE_VERSION visibility slightly changed in autoconf-2.69c. Bug or feature?
Date: Wed, 21 Oct 2020 09:15:41 -0400

On Tue, Oct 20, 2020 at 4:57 PM Nick Bowler <nbowler@draconx.ca> wrote:
> On 2020-10-20, Sergei Trofimovich <slyfox@gentoo.org> wrote:
> > Initial bug is reported as autoconf failure on ghc-8.8.4:
> >     https://bugs.gentoo.org/750191
> > There autconf 2.69 works, 2.69c does not.
> >   $ cat configure.ac
> >   AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.1.0],
> > [glasgow-haskell-bugs@haskell.org], [ghc-AC_PACKAGE_VERSION])
> >
> >   echo "$PACKAGE_VERSION"
> >

If I understand correctly, the intention is to have $PACKAGE_VERSION
set to "9.1.0" and $PACKAGE_TARNAME set to "ghc-9.1.0"?

> Note: the change you report is introduced by Zack's fix for related
> AC_INIT quoting regressions.  This patch is not included in 2.69c (or
> even on git master), but does seem to be applied by the Gentoo package.

Yeah, this is a "can't have it both ways" kind of thing.  We can
reliably round-trip "unusual" characters (like the ones that appear
all the time in URLs and email addresses) through AC_INIT's arguments,
or we can expand macros in those arguments even when they're quoted on
input; I don't think there's any way to do both.

This only works by accident in 2.69, incidentally.  AC_PACKAGE_VERSION
is defined *after* AC_PACKAGE_TARNAME (see _AC_INIT_PACKAGE, lines
235-261 of $prefix/share/autoconf/general.m4) so both old and new
autoconf set AC_PACKAGE_TARNAME to the literal string
"ghc-AC_PACKAGE_VERSION".  The value undergoes an extra round of
expansion when it's used to set the shell variable PACKAGE_TARNAME
(lines 416-428 of the same file).  This extra round of expansion is
undesirable in general.

You can fix this in configure.ac without repeating the version number
by defining an extra M4 macro and using it in both arguments:

m4_define([ghc_VERSION], [9.1.0])
AC_INIT([The Glorious Glasgow Haskell Compilation System],

I'm being extra careful with quotation here; `ghc_VERSION` and
`m4_defn([ghc_VERSION])` both expand to the definition of ghc_VERSION,
but the latter quotes its output. This would matter if the value of
ghc_VERSION could contain more M4 macros, which it *currently*

(If you don't mind, I think I might add this to the manual as an
example of computing the arguments to AC_INIT, with all the
GHC-specific terms removed, of course.)

We *could* add a special case in AC_INIT where, if any of the third,
fourth, or fifth arguments contain the literal strings
`AC_PACKAGE_NAME` or `AC_PACKAGE_VERSION`, those are replaced with the
values of the first and second argument, respectively.  This would
keep the GHC code working as-is.  I'm not sure whether that's a good
idea; cc:ing Paul and Eric for their thoughts.


reply via email to

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