On 2026-03-19 07:41, Akim Demaille wrote:
I believe the answer is 
inhttps://lists.gnu.org/archive/html/autoconf-patches/2002-10/msg00072.html.

Thanks, that explains things. Via the attached patch I attempted to go back to the old way of doing things (but outputting confdefs.h info in a different way). However, this didn't affect overall performance significantly for me on my Fedora 43 system. And although the patch does avoid cat's unnecessary copying of confdefs.h, it causes a bit more work for the C preprocessor and it's not clear that this is an overall win.

Also, although this sort of patch may be a win on platforms where copy_file_range is unhappily inefficient, this sort of performance experimentation should probably not be done just before an Autoconf release.

From 82bf02c8e36f87c571da4defd5af97233f9b5161 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Thu, 19 Mar 2026 10:03:32 -0700
Subject: [PATCH] Include confdefs.h rather than copying it

The goal is to improve performance by moving work
from cat to the C preprocessor.
* lib/autoconf/c.m4 (AC_LANG_CONFTEST(C)):
Include confdefs.h rather than copying it into conftest.$ac_ext.
* lib/autoconf/general.m4 (_AC_MSG_LOG_CONFTEST):
Report contents of both confdefs.h and conftest.$ac_ext.
---
 lib/autoconf/c.m4       | 4 ++--
 lib/autoconf/general.m4 | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 4771b2c9..ed07669f 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -85,8 +85,8 @@ AU_DEFUN([AC_LANG_C], [AC_LANG(C)])
 # rejects $LINENO greater than 32767, and some configure scripts
 # are longer than 32767 lines.
 m4_define([AC_LANG_CONFTEST(C)],
-[cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+[cat <<_ACEOF >conftest.$ac_ext
+#include "confdefs.h"
 $1
 _ACEOF])
 
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 900ba1e0..9b5cfcbd 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2545,8 +2545,8 @@ See 'config.log' for more details], [$2]); }])
 # _AC_MSG_LOG_CONFTEST
 # --------------------
 m4_define([_AC_MSG_LOG_CONFTEST],
-[AS_ECHO(["$as_me: failed program was:"]) >&AS_MESSAGE_LOG_FD
-sed 's/^/| /' conftest.$ac_ext >&AS_MESSAGE_LOG_FD
+[AS_ECHO(["$as_me: failed confdefs.h + program was:"]) >&AS_MESSAGE_LOG_FD
+sed 's/^/| /' confdefs.h conftest.$ac_ext >&AS_MESSAGE_LOG_FD
 ])
 
 
-- 
2.53.0

Reply via email to