0001-configure-simplify-warning-flags-detection.patch 26 KB

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