From 52baaca152135e3b67edb13df392ae9047af015c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 18 Jan 2020 20:34:55 -0800 Subject: [PATCH] Update from Gnulib This incorporates: 2020-01-18 Rename ~~gnulib.m4 to zzgnulib.m4 2020-01-18 Fix "m4_require: circular dependency of AC_LANG_COMPILER(C)" 2020-01-18 Ensure Automake does not drop ~~gnulib.m4 2020-01-18 Fix major regression from 2020-01-10 * m4/00gnulib.m4, m4/gnulib-common.m4: Copy from Gnulib. * m4/gnulib-comp.m4: Regenerate. * m4/zzgnulib.m4: New file, from Gnulib. --- m4/00gnulib.m4 | 51 ++++++++++++++++++++++++++------------------- m4/gnulib-common.m4 | 3 ++- m4/gnulib-comp.m4 | 1 + m4/zzgnulib.m4 | 23 ++++++++++++++++++++ 4 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 m4/zzgnulib.m4 diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4 index 58bc4efb9c5..06eff4f3863 100644 --- a/m4/00gnulib.m4 +++ b/m4/00gnulib.m4 @@ -1,4 +1,4 @@ -# 00gnulib.m4 serial 5 +# 00gnulib.m4 serial 7 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -48,24 +48,34 @@ m4_version_prereq([2.63.263], [], # mode. As of clang 9.0, these "known" functions are identified through # LIBBUILTIN invocations in the LLVM source file # llvm/tools/clang/include/clang/Basic/Builtins.def. +# It's not possible to AC_REQUIRE the extra tests from AC_CHECK_DECL, +# because AC_CHECK_DECL, like other Autoconf built-ins, is not supposed +# to AC_REQUIRE anything: some configure.ac files have their first +# AC_CHECK_DECL executed conditionally. Therefore append the extra tests +# to AC_PROG_CC. AC_DEFUN([gl_COMPILER_CLANG], [ - AC_REQUIRE([AC_PROG_CC]) +dnl AC_REQUIRE([AC_PROG_CC]) AC_CACHE_CHECK([whether the compiler is clang], [gl_cv_compiler_clang], - [AC_EGREP_CPP([barfbarf],[ -#ifdef __clang__ -barfbarf -#endif - ], - [gl_cv_compiler_clang=yes], - [gl_cv_compiler_clang=no]) + [dnl Use _AC_COMPILE_IFELSE instead of AC_EGREP_CPP, to avoid error + dnl "circular dependency of AC_LANG_COMPILER(C)" if AC_PROG_CC has + dnl not yet been invoked. + _AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #ifdef __clang__ + barfbarf + #endif + ]],[[]]) + ], + [gl_cv_compiler_clang=no], + [gl_cv_compiler_clang=yes]) ]) ]) -AC_DEFUN_ONCE([gl_COMPILER_PREPARE_CHECK_DECL], +AC_DEFUN([gl_COMPILER_PREPARE_CHECK_DECL], [ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([gl_COMPILER_CLANG]) +dnl AC_REQUIRE([AC_PROG_CC]) +dnl AC_REQUIRE([gl_COMPILER_CLANG]) AC_CACHE_CHECK([for compiler option needed when checking for declarations], [gl_cv_compiler_check_decl_option], [if test $gl_cv_compiler_clang = yes; then @@ -73,7 +83,9 @@ AC_DEFUN_ONCE([gl_COMPILER_PREPARE_CHECK_DECL], dnl '-Werror=implicit-function-declaration'. save_ac_compile="$ac_compile" ac_compile="$ac_compile -Werror=implicit-function-declaration" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])], + dnl Use _AC_COMPILE_IFELSE instead of AC_COMPILE_IFELSE, to avoid a + dnl warning "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS". + _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])], [gl_cv_compiler_check_decl_option='-Werror=implicit-function-declaration'], [gl_cv_compiler_check_decl_option=none]) ac_compile="$save_ac_compile" @@ -88,18 +100,15 @@ AC_DEFUN_ONCE([gl_COMPILER_PREPARE_CHECK_DECL], fi ]) dnl Redefine _AC_CHECK_DECL_BODY so that it references ac_compile_for_check_decl -dnl instead of ac_compile. +dnl instead of ac_compile. If, for whatever reason, the override of AC_PROG_CC +dnl in zzgnulib.m4 is inactive, use the original ac_compile. m4_define([_AC_CHECK_DECL_BODY], [ ac_save_ac_compile="$ac_compile" - ac_compile="$ac_compile_for_check_decl"] + if test -n "$ac_compile_for_check_decl"; then + ac_compile="$ac_compile_for_check_decl" + fi] m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_save_ac_compile" ]) - ]) -dnl Redefine AC_CHECK_DECL so that it starts with an invocation of -dnl gl_COMPILER_PREPARE_CHECK_DECL. -m4_define([AC_CHECK_DECL], - [gl_COMPILER_PREPARE_CHECK_DECL dnl -]m4_defn([AC_CHECK_DECL])) # gl_00GNULIB # ----------- diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 6c4cad6cef4..276ed1affa5 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 46 +# gnulib-common.m4 serial 47 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,6 +12,7 @@ AC_DEFUN([gl_COMMON], [ dnl Use AC_REQUIRE here, so that the code is expanded once only. AC_REQUIRE([gl_00GNULIB]) AC_REQUIRE([gl_COMMON_BODY]) + AC_REQUIRE([gl_ZZGNULIB]) ]) AC_DEFUN([gl_COMMON_BODY], [ AH_VERBATIM([_Noreturn], diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index abaca719024..cb3b89dd72f 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -1159,4 +1159,5 @@ AC_DEFUN([gl_FILE_LIST], [ m4/warnings.m4 m4/wchar_t.m4 m4/wint_t.m4 + m4/zzgnulib.m4 ]) diff --git a/m4/zzgnulib.m4 b/m4/zzgnulib.m4 new file mode 100644 index 00000000000..98fa68f51a6 --- /dev/null +++ b/m4/zzgnulib.m4 @@ -0,0 +1,23 @@ +# zzgnulib.m4 serial 1 +dnl Copyright (C) 2020 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. + +dnl This file must be named something that sorts after all other +dnl package- or gnulib-provided .m4 files - at least for those packages +dnl that redefine AC_PROG_CC. + +dnl Redefine AC_PROG_CC so that it ends with invocations of gl_COMPILER_CLANG +dnl and gl_COMPILER_PREPARE_CHECK_DECL. +m4_define([AC_PROG_CC], + m4_defn([AC_PROG_CC])[ +gl_COMPILER_CLANG +gl_COMPILER_PREPARE_CHECK_DECL +]) + +# gl_ZZGNULIB +# ----------- +# Witness macro that this file has been included. Needed to force +# Automake to include this file after all other gnulib .m4 files. +AC_DEFUN([gl_ZZGNULIB]) -- 2.39.2