1*4882a593SmuzhiyunFrom 28ba44ad9ca14153e96c94a9100423ea224c1af3 Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Simon Marchi <simon.marchi@efficios.com> 3*4882a593SmuzhiyunDate: Tue, 18 Feb 2020 13:14:22 -0500 4*4882a593SmuzhiyunSubject: [PATCH] configure: simplify warning flags detection 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunWe currently use the AX_COMPILER_FLAGS macro to detect the warning flags 7*4882a593Smuzhiyunthat the current compiler supports. It works, but is quite invasive. 8*4882a593SmuzhiyunIt unconditionally enables a bunch of warnings we don't want, which 9*4882a593Smuzhiyunforces us to disable them with many -Wno-foo switches. 10*4882a593Smuzhiyun 11*4882a593SmuzhiyunInstead of using AX_COMPILER_FLAGS, we can use the slightly lower lever 12*4882a593Smuzhiyunmacro AX_APPEND_COMPILE_FLAGS to achieve our goal of detecting which 13*4882a593Smuzhiyunwarning flags are supported. This is what we ended up using in 14*4882a593Smuzhiyunlttng-tools (a completely unrelated project, but that has a suspiciously 15*4882a593Smuzhiyunhigh ratio of contributors in common with Babeltrace). 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunI looked in our git history to see which warning flags were mentioned in 18*4882a593Smuzhiyuncommit messages. I have added the flags that did find actual problems 19*4882a593Smuzhiyunand are not enabled by default to the AX_APPEND_COMPILE_FLAGS invocation. 20*4882a593SmuzhiyunI have also added the flags that AX_COMPILER_FLAGS did provide, which we 21*4882a593Smuzhiyundidn't need to disable. 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunThe --{enable,disable}-Werror flag is added using an explicit 24*4882a593SmuzhiyunAC_ARG_ENABLE. In lttng-tools, it was decided to _not_ have -Werror by 25*4882a593Smuzhiyundefault, so I suggest we do the same in Babeltrace, for consistency 26*4882a593Smuzhiyun(although it saddens me very much). Developers who want to build with 27*4882a593Smuzhiyun-Werror will need to pass --enable-Werror. 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunNote that with this patch, we lose the following configure switch, that 30*4882a593Smuzhiyunis provided by AX_COMPILER_FLAGS: 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun --enable-compile-warnings=[no/yes/error] 33*4882a593Smuzhiyun 34*4882a593SmuzhiyunChange-Id: If968f7385a7f5c48d27f402c76bc26241a8f505a 35*4882a593SmuzhiyunSigned-off-by: Simon Marchi <simon.marchi@efficios.com> 36*4882a593SmuzhiyunReviewed-on: https://review.lttng.org/c/babeltrace/+/3209 37*4882a593SmuzhiyunTested-by: jenkins <jenkins@lttng.org> 38*4882a593SmuzhiyunReviewed-by: Michael Jeanson <mjeanson@efficios.com> 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun[Retrieved from: 41*4882a593Smuzhiyunhttps://github.com/efficios/babeltrace/commit/28ba44ad9ca14153e96c94a9100423ea224c1af3] 42*4882a593SmuzhiyunSigned-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 43*4882a593Smuzhiyun--- 44*4882a593Smuzhiyun configure.ac | 74 +++++++++------ 45*4882a593Smuzhiyun m4/ax_compiler_flags.m4 | 158 ------------------------------- 46*4882a593Smuzhiyun m4/ax_compiler_flags_cflags.m4 | 161 -------------------------------- 47*4882a593Smuzhiyun m4/ax_compiler_flags_gir.m4 | 60 ------------ 48*4882a593Smuzhiyun m4/ax_compiler_flags_ldflags.m4 | 111 ---------------------- 49*4882a593Smuzhiyun 5 files changed, 46 insertions(+), 518 deletions(-) 50*4882a593Smuzhiyun delete mode 100644 m4/ax_compiler_flags.m4 51*4882a593Smuzhiyun delete mode 100644 m4/ax_compiler_flags_cflags.m4 52*4882a593Smuzhiyun delete mode 100644 m4/ax_compiler_flags_gir.m4 53*4882a593Smuzhiyun delete mode 100644 m4/ax_compiler_flags_ldflags.m4 54*4882a593Smuzhiyun 55*4882a593Smuzhiyundiff --git a/configure.ac b/configure.ac 56*4882a593Smuzhiyunindex 055fba101..7ebcf2ad4 100644 57*4882a593Smuzhiyun--- a/configure.ac 58*4882a593Smuzhiyun+++ b/configure.ac 59*4882a593Smuzhiyun@@ -660,25 +660,35 @@ target. 60*4882a593Smuzhiyun CFLAGS=${save_CFLAGS} 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun # Detect C and LD warning flags supported by the compiler. 63*4882a593Smuzhiyun-AX_COMPILER_FLAGS( 64*4882a593Smuzhiyun- [WARN_CFLAGS], dnl CFLAGS variable name 65*4882a593Smuzhiyun- [WARN_LDFLAGS], dnl LDFLAGS variable name (unused for now) 66*4882a593Smuzhiyun- [], dnl is-release 67*4882a593Smuzhiyun- [], dnl Extra base CFLAGS 68*4882a593Smuzhiyun- [ dnl Extra "yes" CFLAGS 69*4882a593Smuzhiyun- dnl Disable these flags, either because we don't want them 70*4882a593Smuzhiyun- dnl or because we want them but are not ready to enable them 71*4882a593Smuzhiyun- dnl yet. 72*4882a593Smuzhiyun- -Wno-sign-compare dnl 73*4882a593Smuzhiyun- -Wno-inline dnl 74*4882a593Smuzhiyun- -Wno-declaration-after-statement dnl 75*4882a593Smuzhiyun- -Wno-switch-enum dnl 76*4882a593Smuzhiyun- -Wno-switch-default dnl 77*4882a593Smuzhiyun- -Wno-packed dnl 78*4882a593Smuzhiyun- -Wno-pointer-arith dnl 79*4882a593Smuzhiyun+ 80*4882a593Smuzhiyun+# Detect warning flags supported by the compiler, append them to WARN_CFLAGS. 81*4882a593Smuzhiyun+# 82*4882a593Smuzhiyun+# Pass -Werror as an extra flag during the test: this is needed to make the 83*4882a593Smuzhiyun+# -Wunknown-warning-option diagnostic fatal with clang. 84*4882a593Smuzhiyun+AX_APPEND_COMPILE_FLAGS([ dnl 85*4882a593Smuzhiyun+ -Wall dnl 86*4882a593Smuzhiyun+ -Wextra dnl 87*4882a593Smuzhiyun+ -Wstrict-prototypes dnl 88*4882a593Smuzhiyun+ -Wmissing-prototypes dnl 89*4882a593Smuzhiyun+ -Wmissing-declarations dnl 90*4882a593Smuzhiyun+ -Wnull-dereference dnl 91*4882a593Smuzhiyun+ -Wundef dnl 92*4882a593Smuzhiyun+ -Wredundant-decls dnl 93*4882a593Smuzhiyun+ -Wshadow dnl 94*4882a593Smuzhiyun+ -Wjump-misses-init dnl 95*4882a593Smuzhiyun+ -Wtautological-constant-out-of-range-compare dnl 96*4882a593Smuzhiyun+ -Wnested-externs dnl 97*4882a593Smuzhiyun+ -Wwrite-strings dnl 98*4882a593Smuzhiyun+ -Wformat=2 dnl 99*4882a593Smuzhiyun -Wno-format-nonliteral dnl 100*4882a593Smuzhiyun- -Wno-double-promotion dnl 101*4882a593Smuzhiyun- -Wno-cast-align dnl 102*4882a593Smuzhiyun+ -Wstrict-aliasing dnl 103*4882a593Smuzhiyun+ -Wmissing-noreturn dnl 104*4882a593Smuzhiyun+ -Winit-self dnl 105*4882a593Smuzhiyun+ -Wduplicated-cond dnl 106*4882a593Smuzhiyun+ -Wduplicated-branches dnl 107*4882a593Smuzhiyun+ -Wlogical-op dnl 108*4882a593Smuzhiyun+ -Wno-unused-parameter dnl 109*4882a593Smuzhiyun+ -Wno-sign-compare dnl 110*4882a593Smuzhiyun dnl 111*4882a593Smuzhiyun dnl Some versions of SWIG (like 3.0.12) generate code that produces 112*4882a593Smuzhiyun dnl -Wcast-function-type warnings. This warning is present in gcc >= 8. This 113*4882a593Smuzhiyun@@ -692,24 +702,32 @@ AX_COMPILER_FLAGS( 114*4882a593Smuzhiyun dnl 115*4882a593Smuzhiyun dnl Ref: https://github.com/swig/swig/issues/1259 116*4882a593Smuzhiyun -Wno-cast-function-type dnl 117*4882a593Smuzhiyun- ]) 118*4882a593Smuzhiyun- 119*4882a593Smuzhiyun-# CFLAGS from AX_COMPILER_FLAGS. 120*4882a593Smuzhiyun-AM_CFLAGS="${AM_CFLAGS} ${WARN_CFLAGS}" 121*4882a593Smuzhiyun+ -Wno-missing-field-initializers dnl 122*4882a593Smuzhiyun+ ], 123*4882a593Smuzhiyun+ [WARN_CFLAGS], 124*4882a593Smuzhiyun+ [-Werror]) 125*4882a593Smuzhiyun+ 126*4882a593Smuzhiyun+# When given, add -Werror to WARN_CFLAGS. 127*4882a593Smuzhiyun+AC_ARG_ENABLE([Werror], 128*4882a593Smuzhiyun+ [AS_HELP_STRING([--enable-Werror], [Treat compiler warnings as errors.])] 129*4882a593Smuzhiyun+) 130*4882a593Smuzhiyun+AS_IF([test "x$enable_Werror" = "xyes"], 131*4882a593Smuzhiyun+ [WARN_CFLAGS="${WARN_CFLAGS} -Werror"] 132*4882a593Smuzhiyun+) 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun-# The test used in AX_COMPILER_FLAGS, generated using AC_LANG_PROGRAM, is 135*4882a593Smuzhiyun+# The test used in AX_APPEND_COMPILE_FLAGS, generated using AC_LANG_PROGRAM, is 136*4882a593Smuzhiyun # written in such a way that it triggers a -Wold-style-definition warning. So 137*4882a593Smuzhiyun-# if the user has -Werror in their CFLAGS, that warning flag will end up 138*4882a593Smuzhiyun-# disabled, because the test program will not build. 139*4882a593Smuzhiyun+# this warning always ends up disabled if we put it there, because the test 140*4882a593Smuzhiyun+# program does not build. 141*4882a593Smuzhiyun # 142*4882a593Smuzhiyun # Enable it here unconditionally. It is supported by GCC >= 4.8 and by Clang 143*4882a593Smuzhiyun # (it is accepted for compatibility although it has no effect), and there is 144*4882a593Smuzhiyun # not reason to not want it. 145*4882a593Smuzhiyun 146*4882a593Smuzhiyun-AM_CFLAGS="${AM_CFLAGS} -Wold-style-definition" 147*4882a593Smuzhiyun+WARN_CFLAGS="${WARN_CFLAGS} -Wold-style-definition" 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun-# We want this one to always be an error. 150*4882a593Smuzhiyun-AM_CFLAGS="${AM_CFLAGS} -Werror=implicit-function-declaration" 151*4882a593Smuzhiyun+# CFLAGS from AX_APPEND_COMPILE_FLAGS. 152*4882a593Smuzhiyun+AM_CFLAGS="${AM_CFLAGS} ${WARN_CFLAGS}" 153*4882a593Smuzhiyun 154*4882a593Smuzhiyun # Done for AM_CFLAGS. 155*4882a593Smuzhiyun AC_SUBST(AM_CFLAGS) 156*4882a593Smuzhiyundiff --git a/m4/ax_compiler_flags.m4 b/m4/ax_compiler_flags.m4 157*4882a593Smuzhiyundeleted file mode 100644 158*4882a593Smuzhiyunindex ddb0456c4..000000000 159*4882a593Smuzhiyun--- a/m4/ax_compiler_flags.m4 160*4882a593Smuzhiyun+++ /dev/null 161*4882a593Smuzhiyun@@ -1,158 +0,0 @@ 162*4882a593Smuzhiyun-# =========================================================================== 163*4882a593Smuzhiyun-# https://www.gnu.org/software/autoconf-archive/ax_compiler_flags.html 164*4882a593Smuzhiyun-# =========================================================================== 165*4882a593Smuzhiyun-# 166*4882a593Smuzhiyun-# SYNOPSIS 167*4882a593Smuzhiyun-# 168*4882a593Smuzhiyun-# AX_COMPILER_FLAGS([CFLAGS-VARIABLE], [LDFLAGS-VARIABLE], [IS-RELEASE], [EXTRA-BASE-CFLAGS], [EXTRA-YES-CFLAGS], [UNUSED], [UNUSED], [UNUSED], [EXTRA-BASE-LDFLAGS], [EXTRA-YES-LDFLAGS], [UNUSED], [UNUSED], [UNUSED]) 169*4882a593Smuzhiyun-# 170*4882a593Smuzhiyun-# DESCRIPTION 171*4882a593Smuzhiyun-# 172*4882a593Smuzhiyun-# Check for the presence of an --enable-compile-warnings option to 173*4882a593Smuzhiyun-# configure, defaulting to "error" in normal operation, or "yes" if 174*4882a593Smuzhiyun-# IS-RELEASE is equal to "yes". Return the value in the variable 175*4882a593Smuzhiyun-# $ax_enable_compile_warnings. 176*4882a593Smuzhiyun-# 177*4882a593Smuzhiyun-# Depending on the value of --enable-compile-warnings, different compiler 178*4882a593Smuzhiyun-# warnings are checked to see if they work with the current compiler and, 179*4882a593Smuzhiyun-# if so, are appended to CFLAGS-VARIABLE and LDFLAGS-VARIABLE. This 180*4882a593Smuzhiyun-# allows a consistent set of baseline compiler warnings to be used across 181*4882a593Smuzhiyun-# a code base, irrespective of any warnings enabled locally by individual 182*4882a593Smuzhiyun-# developers. By standardising the warnings used by all developers of a 183*4882a593Smuzhiyun-# project, the project can commit to a zero-warnings policy, using -Werror 184*4882a593Smuzhiyun-# to prevent compilation if new warnings are introduced. This makes 185*4882a593Smuzhiyun-# catching bugs which are flagged by warnings a lot easier. 186*4882a593Smuzhiyun-# 187*4882a593Smuzhiyun-# By providing a consistent --enable-compile-warnings argument across all 188*4882a593Smuzhiyun-# projects using this macro, continuous integration systems can easily be 189*4882a593Smuzhiyun-# configured the same for all projects. Automated systems or build 190*4882a593Smuzhiyun-# systems aimed at beginners may want to pass the --disable-Werror 191*4882a593Smuzhiyun-# argument to unconditionally prevent warnings being fatal. 192*4882a593Smuzhiyun-# 193*4882a593Smuzhiyun-# --enable-compile-warnings can take the values: 194*4882a593Smuzhiyun-# 195*4882a593Smuzhiyun-# * no: Base compiler warnings only; not even -Wall. 196*4882a593Smuzhiyun-# * yes: The above, plus a broad range of useful warnings. 197*4882a593Smuzhiyun-# * error: The above, plus -Werror so that all warnings are fatal. 198*4882a593Smuzhiyun-# Use --disable-Werror to override this and disable fatal 199*4882a593Smuzhiyun-# warnings. 200*4882a593Smuzhiyun-# 201*4882a593Smuzhiyun-# The set of base and enabled flags can be augmented using the 202*4882a593Smuzhiyun-# EXTRA-*-CFLAGS and EXTRA-*-LDFLAGS variables, which are tested and 203*4882a593Smuzhiyun-# appended to the output variable if --enable-compile-warnings is not 204*4882a593Smuzhiyun-# "no". Flags should not be disabled using these arguments, as the entire 205*4882a593Smuzhiyun-# point of AX_COMPILER_FLAGS is to enforce a consistent set of useful 206*4882a593Smuzhiyun-# compiler warnings on code, using warnings which have been chosen for low 207*4882a593Smuzhiyun-# false positive rates. If a compiler emits false positives for a 208*4882a593Smuzhiyun-# warning, a #pragma should be used in the code to disable the warning 209*4882a593Smuzhiyun-# locally. See: 210*4882a593Smuzhiyun-# 211*4882a593Smuzhiyun-# https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas 212*4882a593Smuzhiyun-# 213*4882a593Smuzhiyun-# The EXTRA-* variables should only be used to supply extra warning flags, 214*4882a593Smuzhiyun-# and not general purpose compiler flags, as they are controlled by 215*4882a593Smuzhiyun-# configure options such as --disable-Werror. 216*4882a593Smuzhiyun-# 217*4882a593Smuzhiyun-# IS-RELEASE can be used to disable -Werror when making a release, which 218*4882a593Smuzhiyun-# is useful for those hairy moments when you just want to get the release 219*4882a593Smuzhiyun-# done as quickly as possible. Set it to "yes" to disable -Werror. By 220*4882a593Smuzhiyun-# default, it uses the value of $ax_is_release, so if you are using the 221*4882a593Smuzhiyun-# AX_IS_RELEASE macro, there is no need to pass this parameter. For 222*4882a593Smuzhiyun-# example: 223*4882a593Smuzhiyun-# 224*4882a593Smuzhiyun-# AX_IS_RELEASE([git-directory]) 225*4882a593Smuzhiyun-# AX_COMPILER_FLAGS() 226*4882a593Smuzhiyun-# 227*4882a593Smuzhiyun-# CFLAGS-VARIABLE defaults to WARN_CFLAGS, and LDFLAGS-VARIABLE defaults 228*4882a593Smuzhiyun-# to WARN_LDFLAGS. Both variables are AC_SUBST-ed by this macro, but must 229*4882a593Smuzhiyun-# be manually added to the CFLAGS and LDFLAGS variables for each target in 230*4882a593Smuzhiyun-# the code base. 231*4882a593Smuzhiyun-# 232*4882a593Smuzhiyun-# If C++ language support is enabled with AC_PROG_CXX, which must occur 233*4882a593Smuzhiyun-# before this macro in configure.ac, warning flags for the C++ compiler 234*4882a593Smuzhiyun-# are AC_SUBST-ed as WARN_CXXFLAGS, and must be manually added to the 235*4882a593Smuzhiyun-# CXXFLAGS variables for each target in the code base. EXTRA-*-CFLAGS can 236*4882a593Smuzhiyun-# be used to augment the base and enabled flags. 237*4882a593Smuzhiyun-# 238*4882a593Smuzhiyun-# Warning flags for g-ir-scanner (from GObject Introspection) are 239*4882a593Smuzhiyun-# AC_SUBST-ed as WARN_SCANNERFLAGS. This variable must be manually added 240*4882a593Smuzhiyun-# to the SCANNERFLAGS variable for each GIR target in the code base. If 241*4882a593Smuzhiyun-# extra g-ir-scanner flags need to be enabled, the AX_COMPILER_FLAGS_GIR 242*4882a593Smuzhiyun-# macro must be invoked manually. 243*4882a593Smuzhiyun-# 244*4882a593Smuzhiyun-# AX_COMPILER_FLAGS may add support for other tools in future, in addition 245*4882a593Smuzhiyun-# to the compiler and linker. No extra EXTRA-* variables will be added 246*4882a593Smuzhiyun-# for those tools, and all extra support will still use the single 247*4882a593Smuzhiyun-# --enable-compile-warnings configure option. For finer grained control 248*4882a593Smuzhiyun-# over the flags for individual tools, use AX_COMPILER_FLAGS_CFLAGS, 249*4882a593Smuzhiyun-# AX_COMPILER_FLAGS_LDFLAGS and AX_COMPILER_FLAGS_* for new tools. 250*4882a593Smuzhiyun-# 251*4882a593Smuzhiyun-# The UNUSED variables date from a previous version of this macro, and are 252*4882a593Smuzhiyun-# automatically appended to the preceding non-UNUSED variable. They should 253*4882a593Smuzhiyun-# be left empty in new uses of the macro. 254*4882a593Smuzhiyun-# 255*4882a593Smuzhiyun-# LICENSE 256*4882a593Smuzhiyun-# 257*4882a593Smuzhiyun-# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk> 258*4882a593Smuzhiyun-# Copyright (c) 2015 David King <amigadave@amigadave.com> 259*4882a593Smuzhiyun-# 260*4882a593Smuzhiyun-# Copying and distribution of this file, with or without modification, are 261*4882a593Smuzhiyun-# permitted in any medium without royalty provided the copyright notice 262*4882a593Smuzhiyun-# and this notice are preserved. This file is offered as-is, without any 263*4882a593Smuzhiyun-# warranty. 264*4882a593Smuzhiyun- 265*4882a593Smuzhiyun-#serial 14 266*4882a593Smuzhiyun- 267*4882a593Smuzhiyun-# _AX_COMPILER_FLAGS_LANG([LANGNAME]) 268*4882a593Smuzhiyun-m4_defun([_AX_COMPILER_FLAGS_LANG], 269*4882a593Smuzhiyun-[m4_ifdef([_AX_COMPILER_FLAGS_LANG_]$1[_enabled], [], 270*4882a593Smuzhiyun- [m4_define([_AX_COMPILER_FLAGS_LANG_]$1[_enabled], [])dnl 271*4882a593Smuzhiyun- AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_]$1[FLAGS])])dnl 272*4882a593Smuzhiyun-]) 273*4882a593Smuzhiyun- 274*4882a593Smuzhiyun-AC_DEFUN([AX_COMPILER_FLAGS],[ 275*4882a593Smuzhiyun- # C support is enabled by default. 276*4882a593Smuzhiyun- _AX_COMPILER_FLAGS_LANG([C]) 277*4882a593Smuzhiyun- # Only enable C++ support if AC_PROG_CXX is called. The redefinition of 278*4882a593Smuzhiyun- # AC_PROG_CXX is so that a fatal error is emitted if this macro is called 279*4882a593Smuzhiyun- # before AC_PROG_CXX, which would otherwise cause no C++ warnings to be 280*4882a593Smuzhiyun- # checked. 281*4882a593Smuzhiyun- AC_PROVIDE_IFELSE([AC_PROG_CXX], 282*4882a593Smuzhiyun- [_AX_COMPILER_FLAGS_LANG([CXX])], 283*4882a593Smuzhiyun- [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AX_COMPILER_FLAGS_LANG([CXX])])]) 284*4882a593Smuzhiyun- AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_LDFLAGS]) 285*4882a593Smuzhiyun- 286*4882a593Smuzhiyun- # Default value for IS-RELEASE is $ax_is_release 287*4882a593Smuzhiyun- ax_compiler_flags_is_release=m4_tolower(m4_normalize(ifelse([$3],, 288*4882a593Smuzhiyun- [$ax_is_release], 289*4882a593Smuzhiyun- [$3]))) 290*4882a593Smuzhiyun- 291*4882a593Smuzhiyun- AC_ARG_ENABLE([compile-warnings], 292*4882a593Smuzhiyun- AS_HELP_STRING([--enable-compile-warnings=@<:@no/yes/error@:>@], 293*4882a593Smuzhiyun- [Enable compiler warnings and errors]),, 294*4882a593Smuzhiyun- [AS_IF([test "$ax_compiler_flags_is_release" = "yes"], 295*4882a593Smuzhiyun- [enable_compile_warnings="yes"], 296*4882a593Smuzhiyun- [enable_compile_warnings="error"])]) 297*4882a593Smuzhiyun- AC_ARG_ENABLE([Werror], 298*4882a593Smuzhiyun- AS_HELP_STRING([--disable-Werror], 299*4882a593Smuzhiyun- [Unconditionally make all compiler warnings non-fatal]),, 300*4882a593Smuzhiyun- [enable_Werror=maybe]) 301*4882a593Smuzhiyun- 302*4882a593Smuzhiyun- # Return the user's chosen warning level 303*4882a593Smuzhiyun- AS_IF([test "$enable_Werror" = "no" -a \ 304*4882a593Smuzhiyun- "$enable_compile_warnings" = "error"],[ 305*4882a593Smuzhiyun- enable_compile_warnings="yes" 306*4882a593Smuzhiyun- ]) 307*4882a593Smuzhiyun- 308*4882a593Smuzhiyun- ax_enable_compile_warnings=$enable_compile_warnings 309*4882a593Smuzhiyun- 310*4882a593Smuzhiyun- AX_COMPILER_FLAGS_CFLAGS([$1],[$ax_compiler_flags_is_release], 311*4882a593Smuzhiyun- [$4],[$5 $6 $7 $8]) 312*4882a593Smuzhiyun- m4_ifdef([_AX_COMPILER_FLAGS_LANG_CXX_enabled], 313*4882a593Smuzhiyun- [AX_COMPILER_FLAGS_CXXFLAGS([WARN_CXXFLAGS], 314*4882a593Smuzhiyun- [$ax_compiler_flags_is_release], 315*4882a593Smuzhiyun- [$4],[$5 $6 $7 $8])]) 316*4882a593Smuzhiyun- AX_COMPILER_FLAGS_LDFLAGS([$2],[$ax_compiler_flags_is_release], 317*4882a593Smuzhiyun- [$9],[$10 $11 $12 $13]) 318*4882a593Smuzhiyun- AX_COMPILER_FLAGS_GIR([WARN_SCANNERFLAGS],[$ax_compiler_flags_is_release]) 319*4882a593Smuzhiyun-])dnl AX_COMPILER_FLAGS 320*4882a593Smuzhiyundiff --git a/m4/ax_compiler_flags_cflags.m4 b/m4/ax_compiler_flags_cflags.m4 321*4882a593Smuzhiyundeleted file mode 100644 322*4882a593Smuzhiyunindex 916f91837..000000000 323*4882a593Smuzhiyun--- a/m4/ax_compiler_flags_cflags.m4 324*4882a593Smuzhiyun+++ /dev/null 325*4882a593Smuzhiyun@@ -1,161 +0,0 @@ 326*4882a593Smuzhiyun-# ============================================================================= 327*4882a593Smuzhiyun-# https://www.gnu.org/software/autoconf-archive/ax_compiler_flags_cflags.html 328*4882a593Smuzhiyun-# ============================================================================= 329*4882a593Smuzhiyun-# 330*4882a593Smuzhiyun-# SYNOPSIS 331*4882a593Smuzhiyun-# 332*4882a593Smuzhiyun-# AX_COMPILER_FLAGS_CFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS]) 333*4882a593Smuzhiyun-# 334*4882a593Smuzhiyun-# DESCRIPTION 335*4882a593Smuzhiyun-# 336*4882a593Smuzhiyun-# Add warning flags for the C compiler to VARIABLE, which defaults to 337*4882a593Smuzhiyun-# WARN_CFLAGS. VARIABLE is AC_SUBST-ed by this macro, but must be 338*4882a593Smuzhiyun-# manually added to the CFLAGS variable for each target in the code base. 339*4882a593Smuzhiyun-# 340*4882a593Smuzhiyun-# This macro depends on the environment set up by AX_COMPILER_FLAGS. 341*4882a593Smuzhiyun-# Specifically, it uses the value of $ax_enable_compile_warnings to decide 342*4882a593Smuzhiyun-# which flags to enable. 343*4882a593Smuzhiyun-# 344*4882a593Smuzhiyun-# LICENSE 345*4882a593Smuzhiyun-# 346*4882a593Smuzhiyun-# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk> 347*4882a593Smuzhiyun-# Copyright (c) 2017, 2018 Reini Urban <rurban@cpan.org> 348*4882a593Smuzhiyun-# 349*4882a593Smuzhiyun-# Copying and distribution of this file, with or without modification, are 350*4882a593Smuzhiyun-# permitted in any medium without royalty provided the copyright notice 351*4882a593Smuzhiyun-# and this notice are preserved. This file is offered as-is, without any 352*4882a593Smuzhiyun-# warranty. 353*4882a593Smuzhiyun- 354*4882a593Smuzhiyun-#serial 17 355*4882a593Smuzhiyun- 356*4882a593Smuzhiyun-AC_DEFUN([AX_COMPILER_FLAGS_CFLAGS],[ 357*4882a593Smuzhiyun- AC_REQUIRE([AC_PROG_SED]) 358*4882a593Smuzhiyun- AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) 359*4882a593Smuzhiyun- AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) 360*4882a593Smuzhiyun- AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) 361*4882a593Smuzhiyun- 362*4882a593Smuzhiyun- # Variable names 363*4882a593Smuzhiyun- m4_define([ax_warn_cflags_variable], 364*4882a593Smuzhiyun- [m4_normalize(ifelse([$1],,[WARN_CFLAGS],[$1]))]) 365*4882a593Smuzhiyun- 366*4882a593Smuzhiyun- AC_LANG_PUSH([C]) 367*4882a593Smuzhiyun- 368*4882a593Smuzhiyun- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 369*4882a593Smuzhiyun- [#ifndef __cplusplus 370*4882a593Smuzhiyun- #error "no C++" 371*4882a593Smuzhiyun- #endif]])], 372*4882a593Smuzhiyun- [ax_compiler_cxx=yes;], 373*4882a593Smuzhiyun- [ax_compiler_cxx=no;]) 374*4882a593Smuzhiyun- 375*4882a593Smuzhiyun- # Always pass -Werror=unknown-warning-option to get Clang to fail on bad 376*4882a593Smuzhiyun- # flags, otherwise they are always appended to the warn_cflags variable, and 377*4882a593Smuzhiyun- # Clang warns on them for every compilation unit. 378*4882a593Smuzhiyun- # If this is passed to GCC, it will explode, so the flag must be enabled 379*4882a593Smuzhiyun- # conditionally. 380*4882a593Smuzhiyun- AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[ 381*4882a593Smuzhiyun- ax_compiler_flags_test="-Werror=unknown-warning-option" 382*4882a593Smuzhiyun- ],[ 383*4882a593Smuzhiyun- ax_compiler_flags_test="" 384*4882a593Smuzhiyun- ]) 385*4882a593Smuzhiyun- 386*4882a593Smuzhiyun- # Check that -Wno-suggest-attribute=format is supported 387*4882a593Smuzhiyun- AX_CHECK_COMPILE_FLAG([-Wno-suggest-attribute=format],[ 388*4882a593Smuzhiyun- ax_compiler_no_suggest_attribute_flags="-Wno-suggest-attribute=format" 389*4882a593Smuzhiyun- ],[ 390*4882a593Smuzhiyun- ax_compiler_no_suggest_attribute_flags="" 391*4882a593Smuzhiyun- ]) 392*4882a593Smuzhiyun- 393*4882a593Smuzhiyun- # Base flags 394*4882a593Smuzhiyun- AX_APPEND_COMPILE_FLAGS([ dnl 395*4882a593Smuzhiyun- -fno-strict-aliasing dnl 396*4882a593Smuzhiyun- $3 dnl 397*4882a593Smuzhiyun- ],ax_warn_cflags_variable,[$ax_compiler_flags_test]) 398*4882a593Smuzhiyun- 399*4882a593Smuzhiyun- AS_IF([test "$ax_enable_compile_warnings" != "no"],[ 400*4882a593Smuzhiyun- if test "$ax_compiler_cxx" = "no" ; then 401*4882a593Smuzhiyun- # C-only flags. Warn in C++ 402*4882a593Smuzhiyun- AX_APPEND_COMPILE_FLAGS([ dnl 403*4882a593Smuzhiyun- -Wnested-externs dnl 404*4882a593Smuzhiyun- -Wmissing-prototypes dnl 405*4882a593Smuzhiyun- -Wstrict-prototypes dnl 406*4882a593Smuzhiyun- -Wdeclaration-after-statement dnl 407*4882a593Smuzhiyun- -Wimplicit-function-declaration dnl 408*4882a593Smuzhiyun- -Wold-style-definition dnl 409*4882a593Smuzhiyun- -Wjump-misses-init dnl 410*4882a593Smuzhiyun- ],ax_warn_cflags_variable,[$ax_compiler_flags_test]) 411*4882a593Smuzhiyun- fi 412*4882a593Smuzhiyun- 413*4882a593Smuzhiyun- # "yes" flags 414*4882a593Smuzhiyun- AX_APPEND_COMPILE_FLAGS([ dnl 415*4882a593Smuzhiyun- -Wall dnl 416*4882a593Smuzhiyun- -Wextra dnl 417*4882a593Smuzhiyun- -Wundef dnl 418*4882a593Smuzhiyun- -Wwrite-strings dnl 419*4882a593Smuzhiyun- -Wpointer-arith dnl 420*4882a593Smuzhiyun- -Wmissing-declarations dnl 421*4882a593Smuzhiyun- -Wredundant-decls dnl 422*4882a593Smuzhiyun- -Wno-unused-parameter dnl 423*4882a593Smuzhiyun- -Wno-missing-field-initializers dnl 424*4882a593Smuzhiyun- -Wformat=2 dnl 425*4882a593Smuzhiyun- -Wcast-align dnl 426*4882a593Smuzhiyun- -Wformat-nonliteral dnl 427*4882a593Smuzhiyun- -Wformat-security dnl 428*4882a593Smuzhiyun- -Wsign-compare dnl 429*4882a593Smuzhiyun- -Wstrict-aliasing dnl 430*4882a593Smuzhiyun- -Wshadow dnl 431*4882a593Smuzhiyun- -Winline dnl 432*4882a593Smuzhiyun- -Wpacked dnl 433*4882a593Smuzhiyun- -Wmissing-format-attribute dnl 434*4882a593Smuzhiyun- -Wmissing-noreturn dnl 435*4882a593Smuzhiyun- -Winit-self dnl 436*4882a593Smuzhiyun- -Wredundant-decls dnl 437*4882a593Smuzhiyun- -Wmissing-include-dirs dnl 438*4882a593Smuzhiyun- -Wunused-but-set-variable dnl 439*4882a593Smuzhiyun- -Warray-bounds dnl 440*4882a593Smuzhiyun- -Wreturn-type dnl 441*4882a593Smuzhiyun- -Wswitch-enum dnl 442*4882a593Smuzhiyun- -Wswitch-default dnl 443*4882a593Smuzhiyun- -Wduplicated-cond dnl 444*4882a593Smuzhiyun- -Wduplicated-branches dnl 445*4882a593Smuzhiyun- -Wlogical-op dnl 446*4882a593Smuzhiyun- -Wrestrict dnl 447*4882a593Smuzhiyun- -Wnull-dereference dnl 448*4882a593Smuzhiyun- -Wdouble-promotion dnl 449*4882a593Smuzhiyun- $4 dnl 450*4882a593Smuzhiyun- $5 dnl 451*4882a593Smuzhiyun- $6 dnl 452*4882a593Smuzhiyun- $7 dnl 453*4882a593Smuzhiyun- ],ax_warn_cflags_variable,[$ax_compiler_flags_test]) 454*4882a593Smuzhiyun- ]) 455*4882a593Smuzhiyun- AS_IF([test "$ax_enable_compile_warnings" = "error"],[ 456*4882a593Smuzhiyun- # "error" flags; -Werror has to be appended unconditionally because 457*4882a593Smuzhiyun- # it's not possible to test for 458*4882a593Smuzhiyun- # 459*4882a593Smuzhiyun- # suggest-attribute=format is disabled because it gives too many false 460*4882a593Smuzhiyun- # positives 461*4882a593Smuzhiyun- AX_APPEND_FLAG([-Werror],ax_warn_cflags_variable) 462*4882a593Smuzhiyun- 463*4882a593Smuzhiyun- AX_APPEND_COMPILE_FLAGS([ dnl 464*4882a593Smuzhiyun- [$ax_compiler_no_suggest_attribute_flags] dnl 465*4882a593Smuzhiyun- ],ax_warn_cflags_variable,[$ax_compiler_flags_test]) 466*4882a593Smuzhiyun- ]) 467*4882a593Smuzhiyun- 468*4882a593Smuzhiyun- # In the flags below, when disabling specific flags, always add *both* 469*4882a593Smuzhiyun- # -Wno-foo and -Wno-error=foo. This fixes the situation where (for example) 470*4882a593Smuzhiyun- # we enable -Werror, disable a flag, and a build bot passes CFLAGS=-Wall, 471*4882a593Smuzhiyun- # which effectively turns that flag back on again as an error. 472*4882a593Smuzhiyun- for flag in $ax_warn_cflags_variable; do 473*4882a593Smuzhiyun- AS_CASE([$flag], 474*4882a593Smuzhiyun- [-Wno-*=*],[], 475*4882a593Smuzhiyun- [-Wno-*],[ 476*4882a593Smuzhiyun- AX_APPEND_COMPILE_FLAGS([-Wno-error=$(AS_ECHO([$flag]) | $SED 's/^-Wno-//')], 477*4882a593Smuzhiyun- ax_warn_cflags_variable, 478*4882a593Smuzhiyun- [$ax_compiler_flags_test]) 479*4882a593Smuzhiyun- ]) 480*4882a593Smuzhiyun- done 481*4882a593Smuzhiyun- 482*4882a593Smuzhiyun- AC_LANG_POP([C]) 483*4882a593Smuzhiyun- 484*4882a593Smuzhiyun- # Substitute the variables 485*4882a593Smuzhiyun- AC_SUBST(ax_warn_cflags_variable) 486*4882a593Smuzhiyun-])dnl AX_COMPILER_FLAGS 487*4882a593Smuzhiyundiff --git a/m4/ax_compiler_flags_gir.m4 b/m4/ax_compiler_flags_gir.m4 488*4882a593Smuzhiyundeleted file mode 100644 489*4882a593Smuzhiyunindex 5b4924a20..000000000 490*4882a593Smuzhiyun--- a/m4/ax_compiler_flags_gir.m4 491*4882a593Smuzhiyun+++ /dev/null 492*4882a593Smuzhiyun@@ -1,60 +0,0 @@ 493*4882a593Smuzhiyun-# =========================================================================== 494*4882a593Smuzhiyun-# https://www.gnu.org/software/autoconf-archive/ax_compiler_flags_gir.html 495*4882a593Smuzhiyun-# =========================================================================== 496*4882a593Smuzhiyun-# 497*4882a593Smuzhiyun-# SYNOPSIS 498*4882a593Smuzhiyun-# 499*4882a593Smuzhiyun-# AX_COMPILER_FLAGS_GIR([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS]) 500*4882a593Smuzhiyun-# 501*4882a593Smuzhiyun-# DESCRIPTION 502*4882a593Smuzhiyun-# 503*4882a593Smuzhiyun-# Add warning flags for the g-ir-scanner (from GObject Introspection) to 504*4882a593Smuzhiyun-# VARIABLE, which defaults to WARN_SCANNERFLAGS. VARIABLE is AC_SUBST-ed 505*4882a593Smuzhiyun-# by this macro, but must be manually added to the SCANNERFLAGS variable 506*4882a593Smuzhiyun-# for each GIR target in the code base. 507*4882a593Smuzhiyun-# 508*4882a593Smuzhiyun-# This macro depends on the environment set up by AX_COMPILER_FLAGS. 509*4882a593Smuzhiyun-# Specifically, it uses the value of $ax_enable_compile_warnings to decide 510*4882a593Smuzhiyun-# which flags to enable. 511*4882a593Smuzhiyun-# 512*4882a593Smuzhiyun-# LICENSE 513*4882a593Smuzhiyun-# 514*4882a593Smuzhiyun-# Copyright (c) 2015 Philip Withnall <philip@tecnocode.co.uk> 515*4882a593Smuzhiyun-# 516*4882a593Smuzhiyun-# Copying and distribution of this file, with or without modification, are 517*4882a593Smuzhiyun-# permitted in any medium without royalty provided the copyright notice 518*4882a593Smuzhiyun-# and this notice are preserved. This file is offered as-is, without any 519*4882a593Smuzhiyun-# warranty. 520*4882a593Smuzhiyun- 521*4882a593Smuzhiyun-#serial 6 522*4882a593Smuzhiyun- 523*4882a593Smuzhiyun-AC_DEFUN([AX_COMPILER_FLAGS_GIR],[ 524*4882a593Smuzhiyun- AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) 525*4882a593Smuzhiyun- 526*4882a593Smuzhiyun- # Variable names 527*4882a593Smuzhiyun- m4_define([ax_warn_scannerflags_variable], 528*4882a593Smuzhiyun- [m4_normalize(ifelse([$1],,[WARN_SCANNERFLAGS],[$1]))]) 529*4882a593Smuzhiyun- 530*4882a593Smuzhiyun- # Base flags 531*4882a593Smuzhiyun- AX_APPEND_FLAG([$3],ax_warn_scannerflags_variable) 532*4882a593Smuzhiyun- 533*4882a593Smuzhiyun- AS_IF([test "$ax_enable_compile_warnings" != "no"],[ 534*4882a593Smuzhiyun- # "yes" flags 535*4882a593Smuzhiyun- AX_APPEND_FLAG([ dnl 536*4882a593Smuzhiyun- --warn-all dnl 537*4882a593Smuzhiyun- $4 dnl 538*4882a593Smuzhiyun- $5 dnl 539*4882a593Smuzhiyun- $6 dnl 540*4882a593Smuzhiyun- $7 dnl 541*4882a593Smuzhiyun- ],ax_warn_scannerflags_variable) 542*4882a593Smuzhiyun- ]) 543*4882a593Smuzhiyun- AS_IF([test "$ax_enable_compile_warnings" = "error"],[ 544*4882a593Smuzhiyun- # "error" flags 545*4882a593Smuzhiyun- AX_APPEND_FLAG([ dnl 546*4882a593Smuzhiyun- --warn-error dnl 547*4882a593Smuzhiyun- ],ax_warn_scannerflags_variable) 548*4882a593Smuzhiyun- ]) 549*4882a593Smuzhiyun- 550*4882a593Smuzhiyun- # Substitute the variables 551*4882a593Smuzhiyun- AC_SUBST(ax_warn_scannerflags_variable) 552*4882a593Smuzhiyun-])dnl AX_COMPILER_FLAGS 553*4882a593Smuzhiyundiff --git a/m4/ax_compiler_flags_ldflags.m4 b/m4/ax_compiler_flags_ldflags.m4 554*4882a593Smuzhiyundeleted file mode 100644 555*4882a593Smuzhiyunindex 976d1198d..000000000 556*4882a593Smuzhiyun--- a/m4/ax_compiler_flags_ldflags.m4 557*4882a593Smuzhiyun+++ /dev/null 558*4882a593Smuzhiyun@@ -1,111 +0,0 @@ 559*4882a593Smuzhiyun-# ============================================================================== 560*4882a593Smuzhiyun-# https://www.gnu.org/software/autoconf-archive/ax_compiler_flags_ldflags.html 561*4882a593Smuzhiyun-# ============================================================================== 562*4882a593Smuzhiyun-# 563*4882a593Smuzhiyun-# SYNOPSIS 564*4882a593Smuzhiyun-# 565*4882a593Smuzhiyun-# AX_COMPILER_FLAGS_LDFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS]) 566*4882a593Smuzhiyun-# 567*4882a593Smuzhiyun-# DESCRIPTION 568*4882a593Smuzhiyun-# 569*4882a593Smuzhiyun-# Add warning flags for the linker to VARIABLE, which defaults to 570*4882a593Smuzhiyun-# WARN_LDFLAGS. VARIABLE is AC_SUBST-ed by this macro, but must be 571*4882a593Smuzhiyun-# manually added to the LDFLAGS variable for each target in the code base. 572*4882a593Smuzhiyun-# 573*4882a593Smuzhiyun-# This macro depends on the environment set up by AX_COMPILER_FLAGS. 574*4882a593Smuzhiyun-# Specifically, it uses the value of $ax_enable_compile_warnings to decide 575*4882a593Smuzhiyun-# which flags to enable. 576*4882a593Smuzhiyun-# 577*4882a593Smuzhiyun-# LICENSE 578*4882a593Smuzhiyun-# 579*4882a593Smuzhiyun-# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk> 580*4882a593Smuzhiyun-# Copyright (c) 2017, 2018 Reini Urban <rurban@cpan.org> 581*4882a593Smuzhiyun-# 582*4882a593Smuzhiyun-# Copying and distribution of this file, with or without modification, are 583*4882a593Smuzhiyun-# permitted in any medium without royalty provided the copyright notice 584*4882a593Smuzhiyun-# and this notice are preserved. This file is offered as-is, without any 585*4882a593Smuzhiyun-# warranty. 586*4882a593Smuzhiyun- 587*4882a593Smuzhiyun-#serial 9 588*4882a593Smuzhiyun- 589*4882a593Smuzhiyun-AC_DEFUN([AX_COMPILER_FLAGS_LDFLAGS],[ 590*4882a593Smuzhiyun- AX_REQUIRE_DEFINED([AX_APPEND_LINK_FLAGS]) 591*4882a593Smuzhiyun- AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) 592*4882a593Smuzhiyun- AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) 593*4882a593Smuzhiyun- AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) 594*4882a593Smuzhiyun- 595*4882a593Smuzhiyun- # Variable names 596*4882a593Smuzhiyun- m4_define([ax_warn_ldflags_variable], 597*4882a593Smuzhiyun- [m4_normalize(ifelse([$1],,[WARN_LDFLAGS],[$1]))]) 598*4882a593Smuzhiyun- 599*4882a593Smuzhiyun- # Always pass -Werror=unknown-warning-option to get Clang to fail on bad 600*4882a593Smuzhiyun- # flags, otherwise they are always appended to the warn_ldflags variable, 601*4882a593Smuzhiyun- # and Clang warns on them for every compilation unit. 602*4882a593Smuzhiyun- # If this is passed to GCC, it will explode, so the flag must be enabled 603*4882a593Smuzhiyun- # conditionally. 604*4882a593Smuzhiyun- AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[ 605*4882a593Smuzhiyun- ax_compiler_flags_test="-Werror=unknown-warning-option" 606*4882a593Smuzhiyun- ],[ 607*4882a593Smuzhiyun- ax_compiler_flags_test="" 608*4882a593Smuzhiyun- ]) 609*4882a593Smuzhiyun- 610*4882a593Smuzhiyun- AX_CHECK_LINK_FLAG([-Wl,--as-needed], [ 611*4882a593Smuzhiyun- AX_APPEND_LINK_FLAGS([-Wl,--as-needed], 612*4882a593Smuzhiyun- [AM_LDFLAGS],[$ax_compiler_flags_test]) 613*4882a593Smuzhiyun- ]) 614*4882a593Smuzhiyun- AX_CHECK_LINK_FLAG([-Wl,-z,relro], [ 615*4882a593Smuzhiyun- AX_APPEND_LINK_FLAGS([-Wl,-z,relro], 616*4882a593Smuzhiyun- [AM_LDFLAGS],[$ax_compiler_flags_test]) 617*4882a593Smuzhiyun- ]) 618*4882a593Smuzhiyun- AX_CHECK_LINK_FLAG([-Wl,-z,now], [ 619*4882a593Smuzhiyun- AX_APPEND_LINK_FLAGS([-Wl,-z,now], 620*4882a593Smuzhiyun- [AM_LDFLAGS],[$ax_compiler_flags_test]) 621*4882a593Smuzhiyun- ]) 622*4882a593Smuzhiyun- AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [ 623*4882a593Smuzhiyun- AX_APPEND_LINK_FLAGS([-Wl,-z,noexecstack], 624*4882a593Smuzhiyun- [AM_LDFLAGS],[$ax_compiler_flags_test]) 625*4882a593Smuzhiyun- ]) 626*4882a593Smuzhiyun- # textonly, retpolineplt not yet 627*4882a593Smuzhiyun- 628*4882a593Smuzhiyun- # macOS and cygwin linker do not have --as-needed 629*4882a593Smuzhiyun- AX_CHECK_LINK_FLAG([-Wl,--no-as-needed], [ 630*4882a593Smuzhiyun- ax_compiler_flags_as_needed_option="-Wl,--no-as-needed" 631*4882a593Smuzhiyun- ], [ 632*4882a593Smuzhiyun- ax_compiler_flags_as_needed_option="" 633*4882a593Smuzhiyun- ]) 634*4882a593Smuzhiyun- 635*4882a593Smuzhiyun- # macOS linker speaks with a different accent 636*4882a593Smuzhiyun- ax_compiler_flags_fatal_warnings_option="" 637*4882a593Smuzhiyun- AX_CHECK_LINK_FLAG([-Wl,--fatal-warnings], [ 638*4882a593Smuzhiyun- ax_compiler_flags_fatal_warnings_option="-Wl,--fatal-warnings" 639*4882a593Smuzhiyun- ]) 640*4882a593Smuzhiyun- AX_CHECK_LINK_FLAG([-Wl,-fatal_warnings], [ 641*4882a593Smuzhiyun- ax_compiler_flags_fatal_warnings_option="-Wl,-fatal_warnings" 642*4882a593Smuzhiyun- ]) 643*4882a593Smuzhiyun- 644*4882a593Smuzhiyun- # Base flags 645*4882a593Smuzhiyun- AX_APPEND_LINK_FLAGS([ dnl 646*4882a593Smuzhiyun- $ax_compiler_flags_as_needed_option dnl 647*4882a593Smuzhiyun- $3 dnl 648*4882a593Smuzhiyun- ],ax_warn_ldflags_variable,[$ax_compiler_flags_test]) 649*4882a593Smuzhiyun- 650*4882a593Smuzhiyun- AS_IF([test "$ax_enable_compile_warnings" != "no"],[ 651*4882a593Smuzhiyun- # "yes" flags 652*4882a593Smuzhiyun- AX_APPEND_LINK_FLAGS([$4 $5 $6 $7], 653*4882a593Smuzhiyun- ax_warn_ldflags_variable, 654*4882a593Smuzhiyun- [$ax_compiler_flags_test]) 655*4882a593Smuzhiyun- ]) 656*4882a593Smuzhiyun- AS_IF([test "$ax_enable_compile_warnings" = "error"],[ 657*4882a593Smuzhiyun- # "error" flags; -Werror has to be appended unconditionally because 658*4882a593Smuzhiyun- # it's not possible to test for 659*4882a593Smuzhiyun- # 660*4882a593Smuzhiyun- # suggest-attribute=format is disabled because it gives too many false 661*4882a593Smuzhiyun- # positives 662*4882a593Smuzhiyun- AX_APPEND_LINK_FLAGS([ dnl 663*4882a593Smuzhiyun- $ax_compiler_flags_fatal_warnings_option dnl 664*4882a593Smuzhiyun- ],ax_warn_ldflags_variable,[$ax_compiler_flags_test]) 665*4882a593Smuzhiyun- ]) 666*4882a593Smuzhiyun- 667*4882a593Smuzhiyun- # Substitute the variables 668*4882a593Smuzhiyun- AC_SUBST(ax_warn_ldflags_variable) 669*4882a593Smuzhiyun-])dnl AX_COMPILER_FLAGS 670