[squid-dev] [PATCH] squid: let it compile ok for gcc7

Dengke Du dengke.du at windriver.com
Wed Jun 21 02:54:55 UTC 2017


After the gcc upgrade to gcc7.1, gcc7 contains a number of enhancements that
help detect buffer overflow and other forms of invalid memory accesses. We
can check the changes here:

    https://gcc.gnu.org/gcc-7/changes.html

When gcc7 compiling squid, it outputs error:

    error: '%s' directive output may be truncated writing up to 8191 bytes
    into a region of size 8188 [-Werror=format-truncation=]

This is because the gcc7 detect the program may have buffer overflow, so it
outputs warning, in the squid's Makefile, the Makefile treat the warning as
error by setting: -Werror, in order to compile it successfully,  we should
not treat the warning as error.

Signed-off-by: Dengke Du <dengke.du at windriver.com>
---
 acinclude/compiler-flags.m4 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/acinclude/compiler-flags.m4 b/acinclude/compiler-flags.m4
index bd12a83..5f704fa 100644
--- a/acinclude/compiler-flags.m4
+++ b/acinclude/compiler-flags.m4
@@ -133,8 +133,8 @@ AC_DEFUN([SQUID_CC_GUESS_OPTIONS], [
  AC_MSG_CHECKING([for compiler variant])
  case "$squid_cv_compiler" in
   gcc) 
-   squid_cv_cc_option_werror="-Werror" 
-   squid_cv_cxx_option_werror="-Werror" 
+   squid_cv_cc_option_werror="-Werror -Wno-error=format-truncation -Wno-error=int-in-bool-context" 
+   squid_cv_cxx_option_werror="-Werror -Wno-error=format-truncation -Wno-error=int-in-bool-context" 
    squid_cv_cc_option_wall="-Wall"
    squid_cv_cc_option_optimize="-O3"
    squid_cv_cc_arg_pipe="-pipe"
-- 
2.11.0



More information about the squid-dev mailing list