[PATCH] Add --disable-werror

Fabrice Fontaine fontaine.fabrice at gmail.com
Thu Apr 21 08:10:18 AEST 2022


Add an option to disable -Werror to fix the following build failure with
gcc 4.8 raised since version 1.4 and
https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/commit/?id=cf8be8a4352a5df3b3acf545af289cb47faa6de0:

In file included from /home/buildroot/autobuild/instance-0/output-1/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/string.h:636:0,
                 from ../include/erofs/internal.h:242,
                 from ../include/erofs/inode.h:11,
                 from main.c:12:
In function 'memset',
    inlined from 'erofsdump_filetype_distribution.constprop.2' at main.c:583:9:
/home/buildroot/autobuild/instance-0/output-1/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/bits/string3.h:81:30: error: call to '__warn_memset_zero_len' declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror]
       __warn_memset_zero_len ();
                              ^

Fixes:
 - http://autobuild.buildroot.org/results/4c776ec935bbb016231b6701471887a7c9ea79e9

Signed-off-by: Fabrice Fontaine <fontaine.fabrice at gmail.com>
---
 configure.ac     | 13 ++++++++++++-
 dump/Makefile.am |  2 +-
 fsck/Makefile.am |  2 +-
 fuse/Makefile.am |  2 +-
 lib/Makefile.am  |  2 +-
 mkfs/Makefile.am |  2 +-
 6 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6fdb0e4..989e4dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,7 +11,7 @@ AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR(config)
-AM_INIT_AUTOMAKE([foreign -Wall -Werror])
+AM_INIT_AUTOMAKE([foreign -Wall])
 
 # Checks for programs.
 AM_PROG_AR
@@ -65,6 +65,12 @@ AC_ARG_ENABLE([debug],
     [enable_debug="$enableval"],
     [enable_debug="no"])
 
+AC_ARG_ENABLE([werror],
+    [AS_HELP_STRING([--disable-werror],
+                    [disable -Werror @<:@default=yes@:>@])],
+    [enable_werror="$enableval"],
+    [enable_werror="yes"])
+
 AC_ARG_ENABLE(lz4,
    [AS_HELP_STRING([--disable-lz4], [disable LZ4 compression support @<:@default=enabled@:>@])],
    [enable_lz4="$enableval"], [enable_lz4="yes"])
@@ -191,6 +197,11 @@ AS_IF([test "x$enable_debug" != "xno"], [], [
   CPPFLAGS="$CPPFLAGS -DNDEBUG"
 ])
 
+# Configure -Werror
+AS_IF([test "x$enable_werror" != "xyes"], [], [
+  CPPFLAGS="$CPPFLAGS -Werror"
+])
+
 # Configure libuuid
 AS_IF([test "x$with_uuid" != "xno"], [
   PKG_CHECK_MODULES([libuuid], [uuid])
diff --git a/dump/Makefile.am b/dump/Makefile.am
index 9f0cd3f..c2bef6d 100644
--- a/dump/Makefile.am
+++ b/dump/Makefile.am
@@ -5,6 +5,6 @@ AUTOMAKE_OPTIONS = foreign
 bin_PROGRAMS     = dump.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS}
 dump_erofs_SOURCES = main.c
-dump_erofs_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
+dump_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
 dump_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
 	${libuuid_LIBS} ${liblz4_LIBS} ${liblzma_LIBS}
diff --git a/fsck/Makefile.am b/fsck/Makefile.am
index 55b31ea..e6a1fb6 100644
--- a/fsck/Makefile.am
+++ b/fsck/Makefile.am
@@ -5,6 +5,6 @@ AUTOMAKE_OPTIONS = foreign
 bin_PROGRAMS     = fsck.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS}
 fsck_erofs_SOURCES = main.c
-fsck_erofs_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
+fsck_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
 fsck_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
 	${libuuid_LIBS} ${liblz4_LIBS} ${liblzma_LIBS}
diff --git a/fuse/Makefile.am b/fuse/Makefile.am
index 7b007f3..a22cc70 100644
--- a/fuse/Makefile.am
+++ b/fuse/Makefile.am
@@ -3,7 +3,7 @@
 AUTOMAKE_OPTIONS = foreign
 bin_PROGRAMS     = erofsfuse
 erofsfuse_SOURCES = dir.c main.c
-erofsfuse_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
+erofsfuse_CFLAGS = -Wall -I$(top_srcdir)/include
 erofsfuse_CFLAGS += -DFUSE_USE_VERSION=26 ${libfuse_CFLAGS} ${libselinux_CFLAGS}
 erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la ${libfuse_LIBS} ${liblz4_LIBS} \
 	${libselinux_LIBS} ${liblzma_LIBS}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 395c712..89a90e7 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -27,7 +27,7 @@ noinst_HEADERS += compressor.h
 liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \
 		      namei.c data.c compress.c compressor.c zmap.c decompress.c \
 		      compress_hints.c hashmap.c sha256.c blobchunk.c
-liberofs_la_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
+liberofs_la_CFLAGS = -Wall -I$(top_srcdir)/include
 if ENABLE_LZ4
 liberofs_la_CFLAGS += ${LZ4_CFLAGS}
 liberofs_la_SOURCES += compressor_lz4.c
diff --git a/mkfs/Makefile.am b/mkfs/Makefile.am
index 2a4bc1d..709d9bf 100644
--- a/mkfs/Makefile.am
+++ b/mkfs/Makefile.am
@@ -4,6 +4,6 @@ AUTOMAKE_OPTIONS = foreign
 bin_PROGRAMS     = mkfs.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS} ${libselinux_CFLAGS}
 mkfs_erofs_SOURCES = main.c
-mkfs_erofs_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
+mkfs_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
 mkfs_erofs_LDADD = ${libuuid_LIBS} $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
 	${liblz4_LIBS} ${liblzma_LIBS}
-- 
2.35.1



More information about the Linux-erofs mailing list