bug-gnulib
[Top][All Lists]
Advanced

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

Re: expand-before-require bug


From: Eric Blake
Subject: Re: expand-before-require bug
Date: Wed, 21 Jan 2009 17:48:22 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> 
> As of this morning, autoconf.git now warns you on instances of expand-before-
> require (aka ordering bugs in older autoconf, and redundant output when using 
> bleeding edge autoconf).  I'm working on a series of patches to reduce the 
> number of warnings we trigger, starting with this one:

Next:

configure.ac:44: warning: AC_REQUIRE: `gl_HEADER_ERRNO_H' was expanded before 
it was required
m4/strerror.m4:18: gl_FUNC_STRERROR_SEPARATE is expanded from...
m4/strerror.m4:7: gl_FUNC_STRERROR is expanded from...
m4/gnulib-comp.m4:47: gl_INIT is expanded from...
configure.ac:44: the top level

Here, gnulib-tool was constructing gl_INIT to expand, rather than require 
gl_HEADER_ERRNO_H; but since that macro in turn merely required 
gl_HEADER_ERRNO_H_BODY, there was no actual out-of-order output (I don't know 
any way to easily teach autoconf to avoid a false positive warning on a macro 
that merely requires another macro as its sole content).  But it is a lot 
cleaner to fix it like this, by making the errno_h module require rather than 
expand gl_HEADER_ERRNO_H in the first place, at which point, we no longer need 
the indirection.

I'm pushing this:


From: Eric Blake <address@hidden>
Date: Wed, 21 Jan 2009 10:33:24 -0700
Subject: [PATCH] error: avoid expand-before-require warning

* modules/errno (configure.ac): Require, rather than expand,
gl_HEADER_ERRNO_H.
* m4/errno_h.m4 (gl_HEADER_ERRNO_H_BODY): Merge...
(gl_HEADER_ERRNO_H): ...into this macro, and use AC_DEFUN_ONCE to
enforce that all clients require it.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog     |    7 +++++++
 m4/errno_h.m4 |   12 +++---------
 modules/errno |    2 +-
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7b7c8bd..bc8fc9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-01-21  Eric Blake  <address@hidden>
 
+       error: avoid expand-before-require warning
+       * modules/errno (configure.ac): Require, rather than expand,
+       gl_HEADER_ERRNO_H.
+       * m4/errno_h.m4 (gl_HEADER_ERRNO_H_BODY): Merge...
+       (gl_HEADER_ERRNO_H): ...into this macro, and use AC_DEFUN_ONCE to
+       enforce that all clients require it.
+
        gnulib-tool: avoid warnings from using obsolete AC_GNU_SOURCE
        * gnulib-tool (func_dest_tmpfilename, func_create_testdir): Using
        obsolete AC_GNU_SOURCE causes out-of-order expansion; avoid it,
diff --git a/m4/errno_h.m4 b/m4/errno_h.m4
index 0682d1a..4d77672 100644
--- a/m4/errno_h.m4
+++ b/m4/errno_h.m4
@@ -1,17 +1,11 @@
-# errno_h.m4 serial 3
+# errno_h.m4 serial 4
 dnl Copyright (C) 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-AC_DEFUN([gl_HEADER_ERRNO_H],
-[
-  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
-  dnl once only, before all statements that occur in other macros.
-  AC_REQUIRE([gl_HEADER_ERRNO_H_BODY])
-])
-
-AC_DEFUN([gl_HEADER_ERRNO_H_BODY],
+dnl This macro must pass through AC_REQUIRE (never directly invoke it).
+AC_DEFUN_ONCE([gl_HEADER_ERRNO_H],
 [
   AC_REQUIRE([AC_PROG_CC])
   AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [
diff --git a/modules/errno b/modules/errno
index 8806621..208636d 100644
--- a/modules/errno
+++ b/modules/errno
@@ -9,7 +9,7 @@ Depends-on:
 include_next
 
 configure.ac:
-gl_HEADER_ERRNO_H
+AC_REQUIRE([gl_HEADER_ERRNO_H])
 
 Makefile.am:
 BUILT_SOURCES += $(ERRNO_H)
-- 
1.6.0.4







reply via email to

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