From 13c8cc58bbd829ca4616dea09cb050dc977db9ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Fri, 8 Apr 2022 14:57:17 +0200 Subject: [PATCH] Enable warnings when building as a developer with Clang The configure-script logic that automatically enables warnings when building in a development tree didn't work for Clang because it was identified as an old GCC version. * configure.ac: Don't test Clang version as if it were GCC. --- configure.ac | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index cda2a04be95..6b834a2f655 100644 --- a/configure.ac +++ b/configure.ac @@ -965,6 +965,17 @@ AC_DEFUN([gl_GCC_VERSION_IFELSE], ] ) +# clang is unduly picky about some things. +AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #ifndef __clang__ + error "not clang"; + #endif + ]])], + [emacs_cv_clang=yes], + [emacs_cv_clang=no])]) + AC_ARG_ENABLE([gcc-warnings], [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@], [control generation of GCC warnings. The TYPE 'yes' @@ -984,7 +995,11 @@ AC_ARG_ENABLE([gcc-warnings], # just a release imported into Git for patch management. gl_gcc_warnings=no if test -e "$srcdir"/.git && test ! -f "$srcdir"/.tarball-version; then - gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only]) + # Clang typically identifies itself as GCC 4.2 or something similar + # even if it is recent enough to accept the warnings we enable. + AS_IF([test "$emacs_cv_clang" = yes], + [gl_gcc_warnings=warn-only], + [gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only])]) fi]) AC_ARG_ENABLE([check-lisp-object-type], @@ -996,17 +1011,6 @@ if test "$enable_check_lisp_object_type" = yes; then [Define to enable compile-time checks for the Lisp_Object data type.]) fi -# clang is unduly picky about some things. -AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ - #ifndef __clang__ - error "not clang"; - #endif - ]])], - [emacs_cv_clang=yes], - [emacs_cv_clang=no])]) - WERROR_CFLAGS= # When compiling with GCC, prefer -isystem to -I when including system # include files, to avoid generating useless diagnostics for the files. -- 2.39.5