From 55d9ff6a66c20569bb4cb5511cb879f6e5c07e82 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 18 Mar 2016 10:40:34 -0700 Subject: [PATCH] config: make -Werror optional and off by default Allow end users to build the code even if, for example, warnings are added with new compilers versions. -Werror is still enforced for automated builds. Change-Id: I567009d55cf5b941c452bd41d09f75d03b037209 Signed-off-by: Daniel Verkamp --- CONFIG | 3 +++ mk/spdk.common.mk | 6 +++++- scripts/autotest_common.sh | 2 +- unittest.sh | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CONFIG b/CONFIG index 93fad93de..00de5a110 100644 --- a/CONFIG +++ b/CONFIG @@ -34,6 +34,9 @@ # Build with debug logging. Turn off for performance testing and normal usage CONFIG_DEBUG?=n +# Treat warnings as errors (fail the build on any warning). +CONFIG_WERROR?=n + # Build with code coverage instrumentation. CONFIG_COVERAGE?=n diff --git a/mk/spdk.common.mk b/mk/spdk.common.mk index fe8d6892f..d7821bd9e 100644 --- a/mk/spdk.common.mk +++ b/mk/spdk.common.mk @@ -43,7 +43,11 @@ endif OS := $(shell uname) -COMMON_CFLAGS = -g $(C_OPT) -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wmissing-declarations -Wstrict-prototypes -Werror -fno-strict-aliasing -march=native -m64 -I$(SPDK_ROOT_DIR)/include +COMMON_CFLAGS = -g $(C_OPT) -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wmissing-declarations -Wstrict-prototypes -fno-strict-aliasing -march=native -m64 -I$(SPDK_ROOT_DIR)/include + +ifeq ($(CONFIG_WERROR), y) +COMMON_CFLAGS += -Werror +endif COMMON_CFLAGS += -Wformat -Wformat-security -Wformat-nonliteral diff --git a/scripts/autotest_common.sh b/scripts/autotest_common.sh index 9ad176bab..34e64d7cf 100755 --- a/scripts/autotest_common.sh +++ b/scripts/autotest_common.sh @@ -1,7 +1,7 @@ set -xe ulimit -c unlimited -MAKECONFIG='CONFIG_DEBUG=y' +MAKECONFIG='CONFIG_DEBUG=y CONFIG_WERROR=y' case `uname` in FreeBSD) diff --git a/unittest.sh b/unittest.sh index ed16772ea..98c0a2720 100755 --- a/unittest.sh +++ b/unittest.sh @@ -2,7 +2,7 @@ set -xe -make -C test/lib/nvme/unit +make -C test/lib/nvme/unit CONFIG_WERROR=y test/lib/nvme/unit/nvme_c/nvme_ut test/lib/nvme/unit/nvme_ctrlr_c/nvme_ctrlr_ut @@ -10,6 +10,6 @@ test/lib/nvme/unit/nvme_ctrlr_cmd_c/nvme_ctrlr_cmd_ut test/lib/nvme/unit/nvme_ns_cmd_c/nvme_ns_cmd_ut test/lib/nvme/unit/nvme_qpair_c/nvme_qpair_ut -make -C test/lib/ioat/unit +make -C test/lib/ioat/unit CONFIG_WERROR=y test/lib/ioat/unit/ioat_ut