From 00d92d0b6a495a81e4c585be7a41f10ef4b6d47c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Wed, 17 Feb 2021 10:27:07 +0100 Subject: [PATCH] build: Check for -Wtrampolines support MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Clang does not support -Wtrampolines, so check if the compiler supports it before using it. Signed-off-by: Timm Bäder --- ChangeLog | 4 ++++ config/ChangeLog | 6 ++++++ config/eu.am | 10 ++++++++-- configure.ac | 9 +++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d379e7137..fdcc082bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2021-02-17 Timm Bäder + + * configure.ac: Add -Wtrampolines check. + 2021-02-05 Mark Wielaard * configure.ac (AC_INIT): Set version to 0.183. diff --git a/config/ChangeLog b/config/ChangeLog index e877bddac..cd8ff74ca 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,9 @@ +2021-02-17 Timm Bäder + + * eu.am (TRAMPOLINES_WARNING): New variable. + (AM_CFLAGS): Use TRAMPOLINES_WARNING. + (AM_CXXFLAGS): Likewise. + 2021-02-12 Mark Wielaard * elfutils.spec.in: Escape %%check in comment. diff --git a/config/eu.am b/config/eu.am index e109ffd3b..025125703 100644 --- a/config/eu.am +++ b/config/eu.am @@ -73,8 +73,14 @@ else IMPLICIT_FALLTHROUGH_WARNING= endif +if HAVE_TRAMPOLINES_WARNING +TRAMPOLINES_WARNING=-Wtrampolines +else +TRAMPOLINES_WARNING= +endif + AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \ - -Wold-style-definition -Wstrict-prototypes -Wtrampolines \ + -Wold-style-definition -Wstrict-prototypes $(TRAMPOLINES_WARNING) \ $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \ $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \ $(if $($(*F)_no_Werror),,-Werror) \ @@ -84,7 +90,7 @@ AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \ $($(*F)_CFLAGS) AM_CXXFLAGS = -std=c++11 -Wall -Wshadow \ - -Wtrampolines \ + $(TRAMPOLINES_WARNING) \ $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \ $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \ $(if $($(*F)_no_Werror),,-Werror) \ diff --git a/configure.ac b/configure.ac index e56aeb6a7..5f3321aa8 100644 --- a/configure.ac +++ b/configure.ac @@ -537,6 +537,15 @@ if test "$ac_cv_implicit_fallthrough" = "yes"; then [Defined if __attribute__((fallthrough)) is supported]) fi +AC_CACHE_CHECK([whether the compiler accepts -Wtrampolines], ac_cv_trampolines, [dnl +old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wtrampolines -Werror" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], + ac_cv_trampolines=yes, ac_cv_trampolines=no) +CFLAGS="$old_CFLAGS"]) +AM_CONDITIONAL(HAVE_TRAMPOLINES_WARNING, + [test "x$ac_cv_trampolines" != "xno"]) + saved_LIBS="$LIBS" AC_SEARCH_LIBS([argp_parse], [argp]) LIBS="$saved_LIBS" -- 2.47.2