Hi Dmitry,

On Fri, Apr 04, 2025 at 04:04:21PM +0300, Dmitry V. Levin wrote:
> On Fri, Apr 04, 2025 at 01:38:01PM +0200, Mark Wielaard wrote:
> > But maybe we should just use AC_CHECK_HEADERS([stdatomic.h]) and drop
> > the AC_COMPILE_IFELSE trick?
> 
> Sure.  And if we want to keep AC_MSG_ERROR, then
>   AC_CHECK_HEADERS([stdatomic.h], [], [AC_MSG_ERROR([stdatomic.h required])])
> should be fine.

That would indeed simplify things. Pushed the attached patch.

Cheers,

Mark
>From 3b71249d4396f742d68e774313c2a2d9caf4d668 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <m...@klomp.org>
Date: Sun, 6 Apr 2025 18:04:10 +0200
Subject: [PATCH] configure: Use AC_CHECK_HEADERS to detect stdatomic.h

        * configure.ac: Use AC_CHECK_HEADERS instead of
        AC_COMPILE_IFELSE.

Suggested-by: Dmitry V. Levin <l...@strace.io>
Signed-off-by: Mark Wielaard <m...@klomp.org>
---
 configure.ac | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1679a17dd23d..27488e3fe44a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -228,11 +228,7 @@ AS_IF([test "x$ac_cv_tls" != xyes],
 
 dnl Although we test for C11 above that doesn't mean we have stdatomic.h
 dnl We need at least gcc 4.9+ for that.
-AC_CACHE_CHECK([whether gcc provides stdatomic.h], ac_cv_has_stdatomic,
-  [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdatomic.h>]])],
-                    ac_cv_has_stdatomic=yes, ac_cv_has_stdatomic=no)])
-AS_IF([test "x$ac_cv_has_stdatomic" = "xno"],
-      [AC_MSG_ERROR([stdatomic.h required])])
+AC_CHECK_HEADERS([stdatomic.h], [], [AC_MSG_ERROR([stdatomic.h required])])
 
 dnl This test must come as early as possible after the compiler configuration
 dnl tests, because the choice of the file model can (in principle) affect
-- 
2.49.0

Reply via email to