git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Consistent use of AC_LANG_PROGRAM in configure.ac and aclocal.m4.

From
RWRalf Wildenhues <ralf.wildenhues@gmx.de>
Date
Jan 2, 2011, 09:47 UTC
Message-ID
<20110102094730.GA10365@gmx.de>
In-Reply-To
<20110102075953.GB8937@burratino>
* Jonathan Nieder wrote on Sun, Jan 02, 2011 at 08:59:53AM CET:
Show 7 quoted lines
> Ralf Wildenhues wrote:
> 
> > The patch should not cause any semantic changes in the generated
> > configure script.
> 
> This part belongs in the commit message too, imho (though no need to
> resend just for that, of course).
Yeah, you're right.
Show 6 quoted lines
> > -   AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])
> > +   AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])
> 
> Could you say a few words about the effect of this?  Mostly because
> it would be useful to people down the line tempted to make the same
> mistake again.
Allow me to quote autoconf-2.68/NEWS:
  ** The macros AC_PREPROC_IFELSE, AC_COMPILE_IFELSE, AC_LINK_IFELSE, and
     AC_RUN_IFELSE now warn if the first argument failed to use
     AC_LANG_SOURCE or AC_LANG_PROGRAM to generate the conftest file
     contents.  A new macro AC_LANG_DEFINES_PROVIDED exists if you have
     a compelling reason why you cannot use AC_LANG_SOURCE but must
     avoid the warning.

The underlying reason for this change is that AC_LANG_{SOURCE,PROGRAM} take care to actually supply the previously computed set of #defines (and include the standard headers if so desired), for preprocessed languages like C and C++. In the above case, AC_LANG_PROGRAM is already used, but not sufficiently m4-quoted, so that the autoconf warning will be triggered bogusly.

The general rule for m4 quotation is: one set of quotes for each macro
argument, e.g.:
  MACRO1([arg with MACRO2([arg], [arg])], [arg], ...)
and for innermost arguments which need to undergo no m4 expansion at all
a double set of quotes should be used, e.g.:
  AC_LANG_SOURCE([[int s[42]; /* Program sources containing brackets.  */]])

Only for some special macros that need to be expanded before recursion no quoting should be used.

These and more rules are described in detail in 'info Autoconf "Programming in M4"'. The rules can often be relaxed when the macro arguments contain no active characters like comma, brackets or other macro invocations themselves, but IMVHO it is easier getting used to just quote things normally.

Show 8 quoted lines
> > @@ -500,7 +494,7 @@ for l in $lib_order; do
> >      old_LIBS="$LIBS"
> >      LIBS="$LIBS $l"
> >      AC_MSG_CHECKING([for iconv in $l])
> > -    AC_LINK_IFELSE(ICONVTEST_SRC,
> > +    AC_LINK_IFELSE([ICONVTEST_SRC],
> 
> I'm curious about this one, too.
Likewise this is just underquotation leading to false positive.
Show 15 quoted lines
> > @@ -931,18 +915,16 @@ AC_SUBST(NO_INITGROUPS)
> >  #
> >  # Define PTHREAD_LIBS to the linker flag used for Pthread support.
> >  AC_DEFUN([PTHREADTEST_SRC], [
> > +AC_LANG_PROGRAM([[
> >  #include <pthread.h>
> > -
> > -int main(void)
> > -{
> > +]], [[
> >  	pthread_mutex_t test_mutex;
> 
> By the way, what problem is the warning about AC_LANG_PROGRAM meant to
> prevent?  (Just curious.  A five-minute google search didn't reveal
> anything obvious.)
See above.

I would be happy to update the patch in a way that makes it more helpful, but most of the above is fairly general Autoconf rules, so I'm not sure what you need (being blinded by looking at this stuff too often).

Cheers, Ralf

Previous: Jonathan NiederNext: Jonathan Nieder
Message 3 of 7 in “Consistent use of AC_LANG_PROGRAM in configure.ac and aclocal.m4.”
  1. Consistent use of AC_LANG_PROGRAM in configure.ac and aclocal.m4.Ralf Wildenhues, Jan 2, 2011
  2. Jonathan NiederJan 2, 2011
  3. Ralf WildenhuesJan 2, 2011
  4. Jonathan NiederJan 2, 2011
  5. Consistent use of AC_LANG_PROGRAM in configure.ac and aclocal.m4.Ralf Wildenhues, Jan 2, 2011
  6. Ralf WildenhuesFeb 1, 2011
  7. configure: use AC_LANG_PROGRAM consistentlyJonathan Nieder, Feb 12, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.