From: Bruno Haible Date: Sat, 24 May 2025 10:22:28 +0000 (+0200) Subject: AC_CHECK_DECL now ignores future Darwin functions X-Git-Tag: v2.72.90~39 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=e1bbc9b93cdff61d70719c224b37970e065008bb;p=thirdparty%2Fautoconf.git AC_CHECK_DECL now ignores future Darwin functions * lib/autoconf/general.m4 (_AC_UNDECLARED_BUILTIN): Use shorter diagnostic, to be consistent with other changes. (_AC_FUTURE_DARWIN): New macro. (AC_CHECK_DECL): Require per-language _AC_FUTURE_DARWIN. Use $ac_c_future_darwin_options alongside with $ac_c_undeclared_builtin_options. * NEWS: Mention the fix. Co-authored-by: Paul Eggert --- diff --git a/NEWS b/NEWS index 1e4e513ec..8c323887f 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,9 @@ GNU Autoconf NEWS - User visible changes. ** Notable bug fixes +*** AC_CHECK_DECL and AC_CHECK_DECLS will, on macOS, now report "no" for + functions that are declared as existing in future macOS versions only. + *** AC_DEFINE_UNQUOTED no longer mishandles double-quotes inside $(...) and ${...}. diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 7eae5bd23..dccddbe14 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -3105,7 +3105,7 @@ AC_DEFUN([AC_CHECK_FILES], # used by AC_CHECK_DECL, report failure. AC_DEFUN([_AC_UNDECLARED_BUILTIN], [AC_CACHE_CHECK( - [for $[]_AC_CC options needed to detect all undeclared functions], + [for $[]_AC_CC options to detect undeclared functions], [ac_cv_[]_AC_LANG_ABBREV[]_undeclared_builtin_options], [ac_save_CFLAGS=$CFLAGS ac_cv_[]_AC_LANG_ABBREV[]_undeclared_builtin_options='cannot detect' @@ -3145,6 +3145,39 @@ extern void ac_decl (int, char *); [ac_[]_AC_LANG_ABBREV[]_undeclared_builtin_options=$ac_cv_[]_AC_LANG_ABBREV[]_undeclared_builtin_options]) ]) +# _AC_FUTURE_DARWIN +# ----------------- +# Set ac_[]_AC_LANG_ABBREV[]_future_darwin_options to any options needed +# to make the compiler issue a hard error, not a warning, when a function +# is used that is declared in the .h files but that is introduced in a +# version *after* the current minimum OS version. +# These options should not cause any other unrelated warnings to become +# errors. +AC_DEFUN([_AC_FUTURE_DARWIN], +[AC_CACHE_CHECK( + [for $[]_AC_CC options to ignore future-version functions], + [ac_cv_[]_AC_LANG_ABBREV[]_future_darwin_options], + [dnl Test whether the compiler supports the option + dnl '-Werror=unguarded-availability-new'. + ac_compile_saved="$ac_compile" + ac_compile="$ac_compile -Werror=unguarded-availability-new" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if ! (defined __APPLE__ && defined __MACH__) + #error "-Werror=unguarded-availability-new not needed here" + #endif + ]], + [[]])], + [ac_cv_[]_AC_LANG_ABBREV[]_future_darwin_options='-Werror=unguarded-availability-new'], + [ac_cv_[]_AC_LANG_ABBREV[]_future_darwin_options='none needed']) + ac_compile="$ac_compile_saved" + ]) + AS_CASE([$ac_cv_[]_AC_LANG_ABBREV[]_future_darwin_options], + ['none needed'], + [ac_[]_AC_LANG_ABBREV[]_future_darwin_options=''], + [ac_[]_AC_LANG_ABBREV[]_future_darwin_options=$ac_cv_[]_AC_LANG_ABBREV[]_future_darwin_options]) +]) + # _AC_CHECK_DECL_BODY # ------------------- # Shell function body for AC_CHECK_DECL. @@ -3195,10 +3228,16 @@ dnl Initialize each $ac_[]_AC_LANG_ABBREV[]_undeclared_builtin_options once. [AC_DEFUN([_AC_UNDECLARED_BUILTIN_]_AC_LANG_ABBREV, [_AC_UNDECLARED_BUILTIN])]dnl [AC_REQUIRE([_AC_UNDECLARED_BUILTIN_]_AC_LANG_ABBREV)]dnl +dnl Initialize each $ac_[]_AC_LANG_ABBREV[]_future_darwin_options once. +[AC_DEFUN([_AC_FUTURE_DARWIN_]_AC_LANG_ABBREV, + [_AC_FUTURE_DARWIN])]dnl +[AC_REQUIRE([_AC_FUTURE_DARWIN_]_AC_LANG_ABBREV)]dnl [AS_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1])]dnl [ac_fn_check_decl ]dnl ["$LINENO" "$1" "ac_Symbol" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])" ]dnl -["$ac_[]_AC_LANG_ABBREV[]_undeclared_builtin_options" "_AC_LANG_PREFIX[]FLAGS"] +["$ac_[]_AC_LANG_ABBREV[]_undeclared_builtin_options]dnl +[$ac_[]_AC_LANG_ABBREV[]_future_darwin_options" ]dnl +["_AC_LANG_PREFIX[]FLAGS"] [AS_VAR_IF([ac_Symbol], [yes], [$2], [$3])]dnl [AS_VAR_POPDEF([ac_Symbol])]dnl )# AC_CHECK_DECL