blob: 302136a03c6ed1ce7a6f92a1b71067b83d530b89 [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From c21adbb0b230ffba97cf5d059e2bd024e13a37df Mon Sep 17 00:00:00 2001
Brad Bishopd7bf8c12018-02-25 22:55:05 -05002From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 22 Apr 2017 11:54:57 -0700
4Subject: [PATCH] configure: Check for -Wno-error=format-truncation compiler
5 option
6
7If this option is supported by compiler then disable it ( gcc7+)
8Fixes
9client.c:834:23: error: '%s' directive output may be truncated writing up to 1023 bytes into a region of size 1010 [-Werror=format-truncation=]
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012
Brad Bishop316dfdd2018-06-25 12:45:53 -040013---
14 acinclude/ax_check_compile_flag.m4 | 74 ++++++++++++++++++++++++++++++++++++++
15 configure.ac | 2 ++
16 2 files changed, 76 insertions(+)
17 create mode 100644 acinclude/ax_check_compile_flag.m4
18
19diff --git a/acinclude/ax_check_compile_flag.m4 b/acinclude/ax_check_compile_flag.m4
20new file mode 100644
21index 0000000..dcabb92
Brad Bishopd7bf8c12018-02-25 22:55:05 -050022--- /dev/null
Brad Bishop316dfdd2018-06-25 12:45:53 -040023+++ b/acinclude/ax_check_compile_flag.m4
Brad Bishopd7bf8c12018-02-25 22:55:05 -050024@@ -0,0 +1,74 @@
25+# ===========================================================================
26+# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
27+# ===========================================================================
28+#
29+# SYNOPSIS
30+#
31+# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
32+#
33+# DESCRIPTION
34+#
35+# Check whether the given FLAG works with the current language's compiler
36+# or gives an error. (Warnings, however, are ignored)
37+#
38+# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
39+# success/failure.
40+#
41+# If EXTRA-FLAGS is defined, it is added to the current language's default
42+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
43+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
44+# force the compiler to issue an error when a bad flag is given.
45+#
46+# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
47+#
48+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
49+# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
50+#
51+# LICENSE
52+#
53+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
54+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
55+#
56+# This program is free software: you can redistribute it and/or modify it
57+# under the terms of the GNU General Public License as published by the
58+# Free Software Foundation, either version 3 of the License, or (at your
59+# option) any later version.
60+#
61+# This program is distributed in the hope that it will be useful, but
62+# WITHOUT ANY WARRANTY; without even the implied warranty of
63+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
64+# Public License for more details.
65+#
66+# You should have received a copy of the GNU General Public License along
67+# with this program. If not, see <https://www.gnu.org/licenses/>.
68+#
69+# As a special exception, the respective Autoconf Macro's copyright owner
70+# gives unlimited permission to copy, distribute and modify the configure
71+# scripts that are the output of Autoconf when processing the Macro. You
72+# need not follow the terms of the GNU General Public License when using
73+# or distributing such scripts, even though portions of the text of the
74+# Macro appear in them. The GNU General Public License (GPL) does govern
75+# all other use of the material that constitutes the Autoconf Macro.
76+#
77+# This special exception to the GPL applies to versions of the Autoconf
78+# Macro released by the Autoconf Archive. When you make and distribute a
79+# modified version of the Autoconf Macro, you may extend this special
80+# exception to the GPL to apply to your modified version as well.
81+
82+#serial 5
83+
84+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
85+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
86+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
87+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
88+ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
89+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
90+ AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
91+ [AS_VAR_SET(CACHEVAR,[yes])],
92+ [AS_VAR_SET(CACHEVAR,[no])])
93+ _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
94+AS_VAR_IF(CACHEVAR,yes,
95+ [m4_default([$2], :)],
96+ [m4_default([$3], :)])
97+AS_VAR_POPDEF([CACHEVAR])dnl
98+])dnl AX_CHECK_COMPILE_FLAGS
Brad Bishop316dfdd2018-06-25 12:45:53 -040099diff --git a/configure.ac b/configure.ac
100index ff4688c..9382fdf 100644
101--- a/configure.ac
102+++ b/configure.ac
103@@ -26,6 +26,7 @@ m4_include([acinclude/pkg.m4])
104 m4_include([acinclude/lib-checks.m4])
105 m4_include([acinclude/ax_cxx_compile_stdcxx_11.m4])
106 m4_include([acinclude/ax_cxx_0x_types.m4])
107+m4_include([acinclude/ax_check_compile_flag.m4])
108
109 HOSTCXX="$BUILD_CXX"
110 PRESET_CFLAGS="$CFLAGS"
111@@ -44,6 +45,7 @@ AC_PROG_CXX
112 AC_LANG([C++])
113 AC_CANONICAL_HOST
114
115+AX_CHECK_COMPILE_FLAG([-Werror=format-truncation],[CFLAGS="$CFLAGS -Wno-error=format-truncation" CXXFLAGS="$CXXFLAGS -Wno-error=format-truncation"])
116 # Clang 3.2 on some CPUs requires -march-native to detect correctly.
117 # GCC 4.3+ can also produce faster executables when its used.
118 # But building inside a virtual machine environment has been found to