[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL
From: |
Bruno Haible |
Subject: |
Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL |
Date: |
Sat, 18 Jan 2020 14:14:10 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-171-generic; KDE/5.18.0; x86_64; ; ) |
Hi Paul,
> Thanks for the diagnosis. I came up with a simpler patch to Emacs, and
> installed it into Emacs master (attached).
>
> This patch doesn't solve the general problem, just this particular case.
Yes. Among the hundreds of packages that use gnulib, it's likely that
some other package has the same issue.
> I don't have any specific suggestion
> to work around this problem in Gnulib, though.
OK, here's my take at it:
- Restore the assumption that Autoconf built-in macros like AC_CHECK_DECL
don't AC_REQUIRE anything.
- Perform the clang tests at the end of AC_PROG_CC instead.
Since I was testing this with the Emacs git, I noticed that the override
of AC_PROG_CC was not working, because Emacs redefines AC_PROG_CC.
As a mitigation:
1) I moved the AC_PROG_CC override from 00gnulib.m4 to ~~gnulib.m4; this
file sorts after the other *.m4 files in the same directory.
2) Since I don't see a way to make things work if a package is redefining
AC_PROG_CC in a file that sorts after m4/~~gnulib.m4: Use ac_compile
if ac_compile_for_check_decl is not defined.
2020-01-18 Bruno Haible <address@hidden>
Fix major regression from 2020-01-10.
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-01/msg00079.html>.
* m4/00gnulib.m4 (gl_COMPILER_CLANG, gl_COMPILER_PREPARE_CHECK_DECL):
Don't AC_REQUIRE anything.
(gl_COMPILER_PREPARE_CHECK_DECL): Define through AC_DEFUN, not
AC_DEFUN_ONCE. Use _AC_COMPILE_IFELSE, not AC_COMPILE_IFELSE.
(_AC_CHECK_DECL_BODY): If ac_compile_for_check_decl has not been set,
use ac_compile instead.
(AC_CHECK_DECL): Remove override.
* m4/~~gnulib.m4: New file.
* gnulib-tool (func_get_filelist): Add also ~~gnulib.m4.
* pygnulib/GLModuleSystem.py (getFiles): Likewise.
diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4
index 58bc4ef..36304b9 100644
--- a/m4/00gnulib.m4
+++ b/m4/00gnulib.m4
@@ -1,4 +1,4 @@
-# 00gnulib.m4 serial 5
+# 00gnulib.m4 serial 6
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,9 +48,14 @@ 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],[
@@ -62,10 +67,10 @@ barfbarf
[gl_cv_compiler_clang=no])
])
])
-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 +78,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 +95,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 ~~gnulib.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.m4 b/m4/~~gnulib.m4
new file mode 100644
index 0000000..bb5e910
--- /dev/null
+++ b/m4/~~gnulib.m4
@@ -0,0 +1,17 @@
+# ~~gnulib.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
+])
diff --git a/gnulib-tool b/gnulib-tool
index 1bf1be3..ba51606 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -2294,6 +2294,7 @@ func_get_filelist ()
fi
fi
echo m4/00gnulib.m4
+ echo 'm4/~~gnulib.m4'
echo m4/gnulib-common.m4
}
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 9560bc2..72a6c9f 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -544,6 +544,7 @@ Include:|Link:|License:|Maintainer:)'
parts += [line]
result = [part.strip() for part in parts if part.strip()]
result += [joinpath('m4', '00gnulib.m4')]
+ result += [joinpath('m4', '~~gnulib.m4')]
result += [joinpath('m4', 'gnulib-common.m4')]
self.cache['files'] = list(result)
return(list(self.cache['files']))
- Messed up gl_COMPILER_PREPARE_CHECK_DECL, Mats Erik Andersson, 2020/01/10
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Bruno Haible, 2020/01/10
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Mats Erik Andersson, 2020/01/10
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Paul Eggert, 2020/01/10
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Bruno Haible, 2020/01/10
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Paul Eggert, 2020/01/10
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Bruno Haible, 2020/01/13
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Paul Eggert, 2020/01/13
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL,
Bruno Haible <=
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Bruno Haible, 2020/01/18
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Mats Erik Andersson, 2020/01/18
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Bruno Haible, 2020/01/18
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Mats Erik Andersson, 2020/01/18
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Bruno Haible, 2020/01/18
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Paul Eggert, 2020/01/18
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Bruno Haible, 2020/01/18
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Paul Eggert, 2020/01/18
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Bruno Haible, 2020/01/18
- Re: Messed up gl_COMPILER_PREPARE_CHECK_DECL, Bruno Haible, 2020/01/18