[PATCH 3/3] build: Check for -Wno-packed-not-aligned support
tbaeder@redhat.com
tbaeder@redhat.com
Wed Feb 17 09:27:08 GMT 2021
From: Timm Bäder <tbaeder@redhat.com>
Clang does not support this warning, so check for compiler support
before using it.
Signed-off-by: Timm Bäder <tbaeder@redhat.com>
---
config/eu.am | 10 ++++++++--
configure.ac | 9 +++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/config/eu.am b/config/eu.am
index 02512570..2c3e4571 100644
--- a/config/eu.am
+++ b/config/eu.am
@@ -79,6 +79,12 @@ else
TRAMPOLINES_WARNING=
endif
+if HAVE_NO_PACKED_NOT_ALIGNED_WARNING
+NO_PACKED_NOT_ALIGNED_WARNING=-Wno-packed-not-aligned
+else
+NO_PACKED_NOT_ALIGNED_WARNING=
+endif
+
AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
-Wold-style-definition -Wstrict-prototypes $(TRAMPOLINES_WARNING) \
$(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
@@ -86,7 +92,7 @@ AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
$(if $($(*F)_no_Werror),,-Werror) \
$(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
$(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
- $(if $($(*F)_no_Wpacked_not_aligned),-Wno-packed-not-aligned,) \
+ $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \
$($(*F)_CFLAGS)
AM_CXXFLAGS = -std=c++11 -Wall -Wshadow \
@@ -96,7 +102,7 @@ AM_CXXFLAGS = -std=c++11 -Wall -Wshadow \
$(if $($(*F)_no_Werror),,-Werror) \
$(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
$(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
- $(if $($(*F)_no_Wpacked_not_aligned),-Wno-packed-not-aligned,) \
+ $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \
$($(*F)_CXXFLAGS)
COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE))
diff --git a/configure.ac b/configure.ac
index 5f3321aa..aa8439e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -546,6 +546,15 @@ CFLAGS="$old_CFLAGS"])
AM_CONDITIONAL(HAVE_TRAMPOLINES_WARNING,
[test "x$ac_cv_trampolines" != "xno"])
+AC_CACHE_CHECK([whether the compiler accepts -Wno-packed-not-aligned], ac_cv_no_packed_not_aligned, [dnl
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wno-packed-not-aligned -Werror"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
+ ac_cv_no_packed_not_aligned=yes, ac_cv_no_packed_not_aligned=no)
+CFLAGS="$old_CFLAGS"])
+AM_CONDITIONAL(HAVE_NO_PACKED_NOT_ALIGNED_WARNING,
+ [test "x$ac_cv_no_packed_not_aligned" != "xno"])
+
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([argp_parse], [argp])
LIBS="$saved_LIBS"
--
2.26.2
More information about the Elfutils-devel
mailing list