[lxc-devel] [PATCH] lxc: let it compile ok for gcc7

Stéphane Graber stgraber at ubuntu.com
Thu Jun 22 17:38:25 UTC 2017


On Thu, Jun 22, 2017 at 04:27:42AM -0400, Dengke Du wrote:
> After gcc upgrade to 7.1, gcc7 contains a number of enhancements that help
> detect buffer overflow and other forms of invalid memory accesses.
> 
> When compiling lxc with gcc7, the system outputs errors:
> 
>    ../../../lxc-2.0.4/src/lxc/bdev/lxcloop.c:297:30: error: '%s' directive
>    output may be truncated writing up to 255 bytes into a region of size 95
>    [-Werror=format-truncation=]
> 
> This is because in configure.ac, the flag "-Werror" let the compiler treat
> the warnings as errors, in order to compile successfully, we should add the
> following to the configure.ac:
> 
>    -Wno-error=format-truncation

Hey there,

We are aware that LXC fails to compile with gcc7, but I don't believe we
should hide the error as this isn't an issue in our code but in gcc
itself.

The upstream gcc bug for this is:
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78969

Stéphane

> 
> Signed-off-by: Dengke Du <dengke.du at windriver.com>
> ---
>  configure.ac | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure.ac b/configure.ac
> index b9646d1..c03dc2c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -626,7 +626,7 @@ AC_PROG_SED
>  LXC_CHECK_TLS
>  
>  if test "x$GCC" = "xyes"; then
> -	CFLAGS="$CFLAGS -Wall -Werror"
> +	CFLAGS="$CFLAGS -Wall -Werror -Wno-error=format-truncation"
>  fi
>  
>  # Files requiring some variable expansion
> -- 
> 2.11.0
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170622/93918e4d/attachment.sig>


More information about the lxc-devel mailing list