freeswitch-stable: workaround for build failures when gcc 7 is used 261/head
authorSebastian Kemper <sebastian_ml@gmx.net>
Sat, 3 Feb 2018 18:30:34 +0000 (19:30 +0100)
committerSebastian Kemper <sebastian_ml@gmx.net>
Sat, 3 Feb 2018 19:19:20 +0000 (20:19 +0100)
When gcc 7 is used, -Werror=format-truncation finds snprintf() calls in
mod_cdr_mongodb.c and suspects that they may result in truncation. As a
result the build fails.

Work around this by adding -Wno-error=format-truncation to CFLAGS when
gcc support this.

JIRA-10939 has been raised upstream to follow up on this.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
net/freeswitch-stable/patches/320-workaround-format-truncation-error-in-mod_cdr_mongodb.patch [new file with mode: 0644]

diff --git a/net/freeswitch-stable/patches/320-workaround-format-truncation-error-in-mod_cdr_mongodb.patch b/net/freeswitch-stable/patches/320-workaround-format-truncation-error-in-mod_cdr_mongodb.patch
new file mode 100644 (file)
index 0000000..2a93821
--- /dev/null
@@ -0,0 +1,29 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -363,6 +363,16 @@ if test "$ax_cv_c_compiler_vendor" = "gn
+         [ac_cv_gcc_supports_w_no_misleading_indentation=no])])
+   CFLAGS="$saved_CFLAGS"
+   AC_MSG_RESULT($ac_cv_gcc_supports_w_no_misleading_indentation)
++
++  saved_CFLAGS="$CFLAGS"
++  AC_CACHE_CHECK([whether compiler supports -Wno-error=format-truncation],
++    [ac_cv_gcc_supports_w_no_err_format_truncation], [
++      CFLAGS="$CFLAGS -Wno-error=format-truncation"
++      AC_TRY_COMPILE([],[return 0;],
++        [ac_cv_gcc_supports_w_no_err_format_truncation=yes],
++        [ac_cv_gcc_supports_w_no_err_format_truncation=no])])
++  CFLAGS="$saved_CFLAGS"
++  AC_MSG_RESULT($ac_cv_gcc_supports_w_no_err_format_truncation)
+ fi
+ # tweak compiler specific flags
+@@ -402,6 +412,9 @@ elif test "x${ax_cv_c_compiler_vendor}"
+     if test "$ac_cv_gcc_supports_w_no_misleading_indentation" = yes; then
+       APR_ADDTO(SWITCH_AM_CFLAGS, -Wno-misleading-indentation)
+     fi
++    if test "$ac_cv_gcc_supports_w_no_err_format_truncation" = yes; then
++      APR_ADDTO(SWITCH_AM_CFLAGS, -Wno-error=format-truncation)
++    fi
+     if test "${enable_64}" = "yes"; then
+       case "$host" in
+              *darwin*)