]> git.eshelyaron.com Git - emacs.git/commitdiff
Enable warnings when building as a developer with Clang
authorMattias Engdegård <mattiase@acm.org>
Fri, 8 Apr 2022 12:57:17 +0000 (14:57 +0200)
committerMattias Engdegård <mattiase@acm.org>
Fri, 8 Apr 2022 13:00:38 +0000 (15:00 +0200)
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

index cda2a04be955dd2a4ecebe8558b3139ea38537bb..6b834a2f65588db250a20cb6b9c5f90498d30501 100644 (file)
@@ -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.