Ticket #4524: 0001-m4-add-Werror-when-checking-for-compiler-flags.patch

File 0001-m4-add-Werror-when-checking-for-compiler-flags.patch, 2.0 KB (added by zaytsev, 7 months ago)
  • m4.include/ax_check_compile_flag.m4

    From 52866c44ceee5e07c450374857ff501eb581fd3c Mon Sep 17 00:00:00 2001
    From: "Yury V. Zaytsev" <yury@shurup.com>
    Date: Thu, 30 May 2024 16:25:34 +0200
    Subject: [PATCH] m4: add Werror when checking for compiler flags
    
    Seemingly that at some point clang started accepting _any_ flags,
    whereas previously it would error out.
    
    These days, you can give it -Whamsandwich and it will succeed, while
    at the same time throwing an annoying warning.
    
    Add -Werror so that everything gets flagged and set accordingly.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108082
    Cc: Vinson Lee <vlee@freedesktop.org>
    Repored-by: Vinson Lee <vlee@freedesktop.org>
    Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
    Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
    Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
    
    Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
    ---
     m4.include/ax_check_compile_flag.m4 | 7 ++++++-
     1 file changed, 6 insertions(+), 1 deletion(-)
    
    diff --git a/m4.include/ax_check_compile_flag.m4 b/m4.include/ax_check_compile_flag.m4
    index bd753b34d..8323a2275 100644
    a b  
    3434#   and this notice are preserved.  This file is offered as-is, without any 
    3535#   warranty. 
    3636 
     37# Yury Zaytsev: 
     38# Toggle Werror since at some point clang started treating unknown -W 
     39# flags as warnings, succeeding with the build, yet issuing an annoying 
     40# warning. 
     41 
    3742#serial 6 
    3843 
    3944AC_DEFUN([AX_CHECK_COMPILE_FLAG], 
    AC_DEFUN([AX_CHECK_COMPILE_FLAG], 
    4146AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl 
    4247AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ 
    4348  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS 
    44   _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" 
     49  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1 -Werror" 
    4550  AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], 
    4651    [AS_VAR_SET(CACHEVAR,[yes])], 
    4752    [AS_VAR_SET(CACHEVAR,[no])])