On 2026-03-18 22:01, Nick Bowler wrote:
On Wed, Mar 18, 2026 at 12:57:53PM -0400, Zack Weinberg wrote:
Do you happen to remember why we concatenate confdefs.h and the test
program, instead of #include-ing confdefs.h from the test program?

A long time ago C compilations did use #include "confdefs.h" but it was
changed to resemble the current method in version 2.55 (2002).

No explicit rationale is given but it was probably done this way to
improve the logging around compilation failures.

Thanks, then let's ask Akim. Akim, is that why you installed commit c4e69deefdc48a44849fd6c1ae4a49811e62f0c1 dated 2002-10-31 into lib/autoconf/c.m4's AC_LANG_SOURCE(C)? We're asking because we're thinking of going back to the old way of doing things, for efficiency reasons. I'm attaching a copy of that old commit for convenience.
From c4e69deefdc48a44849fd6c1ae4a49811e62f0c1 Mon Sep 17 00:00:00 2001
From: Akim Demaille <[email protected]>
Date: Thu, 31 Oct 2002 08:27:15 +0000
Subject: [PATCH] * lib/autoconf/general.m4 (_AC_MSG_LOG_CONFTEST): New.
 (_AC_PREPROC_IFELSE, _AC_COMPILE_IFELSE, _AC_LINK_IFELSE) (_AC_RUN_IFELSE):
 Use it. * lib/autoconf/lang.m4 (_AC_COMPILER_OBJEXT):
 (_AC_COMPILER_EXEEXT_DEFAULT): Likewise. * lib/autoconf/c.m4
 (AC_LANG_SOURCE): Don't include confdefs.h, inline it.

---
 ChangeLog               | 10 ++++++++++
 lib/autoconf/c.m4       |  6 +++++-
 lib/autoconf/general.m4 | 21 +++++++++++++--------
 lib/autoconf/lang.m4    |  6 ++----
 4 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d6fc35e1..ce8b944d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-10-31  Akim Demaille  <[email protected]>
+
+	* lib/autoconf/general.m4 (_AC_MSG_LOG_CONFTEST): New.
+	(_AC_PREPROC_IFELSE, _AC_COMPILE_IFELSE, _AC_LINK_IFELSE)
+	(_AC_RUN_IFELSE): Use it.
+	* lib/autoconf/lang.m4 (_AC_COMPILER_OBJEXT):
+	(_AC_COMPILER_EXEEXT_DEFAULT): Likewise.
+	* lib/autoconf/c.m4 (AC_LANG_SOURCE): Don't include confdefs.h,
+	inline it.
+
 2002-10-30  Akim Demaille  <[email protected]>
 
 	* bin/autom4te.in (&parse_args, $help): Support --no-cache.
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 99059011..b5b63ba8 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -121,7 +121,11 @@ m4_define([_AC_LANG_ABBREV(C++)], [cxx])
 # #line $LINENO "$[0]"
 m4_define([AC_LANG_SOURCE(C)],
 [#line $LINENO "configure"
-#include "confdefs.h"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 $1])
 
 
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 1b2244c3..864b85e0 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1972,6 +1972,15 @@ m4_define([AC_MSG_FAILURE],
 [AC_MSG_ERROR([$1
 See `config.log' for more details.], [$2])])
 
+
+# _AC_MSG_LOG_CONFTEST
+# --------------------
+m4_define([_AC_MSG_LOG_CONFTEST],
+[echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
+sed 's/^/| /' conftest.$ac_ext >&AS_MESSAGE_LOG_FD
+])
+
+
 # AU::AC_CHECKING(FEATURE)
 # ------------------------
 AU_DEFUN([AC_CHECKING],
@@ -2090,8 +2099,7 @@ fi
 if test -z "$ac_cpp_err"; then
   m4_default([$2], :)
 else
-  echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
-  cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
+  _AC_MSG_LOG_CONFTEST
   $3
 fi
 rm -f conftest.err m4_ifval([$1], [conftest.$ac_ext])[]dnl
@@ -2166,8 +2174,7 @@ rm -f conftest.$ac_objext
 AS_IF([AC_TRY_EVAL(ac_compile) &&
          AC_TRY_COMMAND([test -s conftest.$ac_objext])],
       [$2],
-      [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
-cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
+      [_AC_MSG_LOG_CONFTEST
 m4_ifvaln([$3],[$3])dnl])dnl
 rm -f conftest.$ac_objext m4_ifval([$1], [conftest.$ac_ext])[]dnl
 ])# _AC_COMPILE_IFELSE
@@ -2206,8 +2213,7 @@ rm -f conftest.$ac_objext conftest$ac_exeext
 AS_IF([AC_TRY_EVAL(ac_link) &&
          AC_TRY_COMMAND([test -s conftest$ac_exeext])],
       [$2],
-      [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
-cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
+      [_AC_MSG_LOG_CONFTEST
 m4_ifvaln([$3], [$3])dnl])[]dnl
 rm -f conftest.$ac_objext conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl
 ])# _AC_LINK_IFELSE
@@ -2260,8 +2266,7 @@ rm -f conftest$ac_exeext
 AS_IF([AC_TRY_EVAL(ac_link) && AC_TRY_COMMAND(./conftest$ac_exeext)],
       [$2],
       [echo "$as_me: program exited with status $ac_status" >&AS_MESSAGE_LOG_FD
-echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
-cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
+_AC_MSG_LOG_CONFTEST
 m4_ifvaln([$3],
           [( exit $ac_status )
 $3])dnl])[]dnl
diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4
index ba728a09..72ac4cfa 100644
--- a/lib/autoconf/lang.m4
+++ b/lib/autoconf/lang.m4
@@ -478,8 +478,7 @@ do
         break;;
   esac
 done],
-      [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
-cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
+      [_AC_MSG_LOG_CONFTEST
 AC_MSG_FAILURE([_AC_LANG compiler cannot create executables], 77)])
 ac_exeext=$ac_cv_exeext
 AC_MSG_RESULT([$ac_file])
@@ -597,8 +596,7 @@ AS_IF([AC_TRY_EVAL(ac_compile)],
        break;;
   esac
 done],
-      [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
-cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
+      [_AC_MSG_LOG_CONFTEST
 AC_MSG_FAILURE([cannot compute suffix of object files: cannot compile])])
 rm -f conftest.$ac_cv_objext conftest.$ac_ext])
 AC_SUBST([OBJEXT], [$ac_cv_objext])dnl
-- 
2.53.0

Reply via email to