[PATCH v1 kbuild for-next 1/2] makefiles: add config option to force all cc warnings to errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a Kconfig option to force cc warnings to errors. Also, to promote
better code hygiene enable the configuration option by default to force
authors to take some action. If for some reason a compilation unit
cannot get rid of the error the author has the option to suppress the
warning for that compile unit or module, see
Documentation/kbuild/makefiles.txt for details.

Signed-off-by: Jonathan Toppins <jtoppins@xxxxxxxxxxxxxxxxxxx>
---
 Makefile          |    4 ++++
 lib/Kconfig.debug |   14 ++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/Makefile b/Makefile
index abf7bb1..eb47733 100644
--- a/Makefile
+++ b/Makefile
@@ -764,6 +764,10 @@ ifdef CONFIG_DEBUG_SECTION_MISMATCH
 KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
 endif
 
+ifdef CONFIG_DEBUG_FORCE_CC_WARNINGS_TO_ERRORS
+KBUILD_CFLAGS += $(call cc-option, -Werror)
+endif
+
 # arch Makefile may override CC so keep this after arch Makefile is included
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 CHECKFLAGS     += $(NOSTDINC_FLAGS)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 3e0289e..0b288db 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -347,6 +347,20 @@ config DEBUG_FORCE_WEAK_PER_CPU
 	  To ensure that generic code follows the above rules, this
 	  option forces all percpu variables to be defined as weak.
 
+config DEBUG_FORCE_CC_WARNINGS_TO_ERRORS
+	bool "Force cc warnings to errors"
+	default y
+	help
+	  Simply enables the gcc compiler option -Werror for the entire
+	  build. If a compilation unit cannot handle -Werror by fixing the
+	  warning then that unit must suppress the cc warning using
+	  cc-disable-warning for that compilation unit in the unit's makefile.
+	  .
+	  This option is intended to be more in the developer's face and
+	  encourage effort of some kind to remove the compilation warning.
+	  .
+	  If unsure say y.
+
 endmenu # "Compiler options"
 
 config MAGIC_SYSRQ
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux