* [PATCH v2 kbuild for-next 1/2] makefiles: add config option to force all cc warnings to errors
@ 2015-03-27 17:51 Jonathan Toppins
2015-03-27 17:51 ` [PATCH v2 kbuild for-next 2/2] modpost: add Kconfig option to report warnings as errors Jonathan Toppins
2015-03-30 13:35 ` [PATCH v2 kbuild for-next 1/2] makefiles: add config option to force all cc warnings to errors Michal Marek
0 siblings, 2 replies; 3+ messages in thread
From: Jonathan Toppins @ 2015-03-27 17:51 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild
Add a Kconfig option to force cc warnings to errors. For new
development it is recommended this setting be enabled as warnings
in the code will be quite obvious.
v2: * remove DOTs from Kconfig entries
* reworded Kconfig to not imply suppressing cc warnings was
acceptable
* default option to 'n'
Signed-off-by: Jonathan Toppins <jtoppins@cumulusnetworks.com>
---
Makefile | 4 ++++
lib/Kconfig.debug | 10 ++++++++++
2 files changed, 14 insertions(+)
diff --git a/Makefile b/Makefile
index dc2d91a..a69562a 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..bbe2eed 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -347,6 +347,16 @@ 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"
+ help
+ Simply enables the gcc compiler option -Werror for the entire
+ build. This option is intended to be more in the developer's
+ face and encourage effort of some kind to remove the
+ compilation warning.
+
+ If doing new development recommend setting to y.
+
endmenu # "Compiler options"
config MAGIC_SYSRQ
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 kbuild for-next 2/2] modpost: add Kconfig option to report warnings as errors
2015-03-27 17:51 [PATCH v2 kbuild for-next 1/2] makefiles: add config option to force all cc warnings to errors Jonathan Toppins
@ 2015-03-27 17:51 ` Jonathan Toppins
2015-03-30 13:35 ` [PATCH v2 kbuild for-next 1/2] makefiles: add config option to force all cc warnings to errors Michal Marek
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Toppins @ 2015-03-27 17:51 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild
Add a Kconfig option to cause modpost to report warnings as errors.
This is a simplistic implementation in that modpost only reports the
first warning as an error and subsequent unreported warnings that will
kill the build may still exist.
v2: * removed DOTs from Kconfig entries
Signed-off-by: Jonathan Toppins <jtoppins@cumulusnetworks.com>
---
lib/Kconfig.debug | 9 +++++++++
scripts/mod/modpost.c | 5 +++++
2 files changed, 14 insertions(+)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index bbe2eed..94ee0c4 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -357,6 +357,15 @@ config DEBUG_FORCE_CC_WARNINGS_TO_ERRORS
If doing new development recommend setting to y.
+config DEBUG_FORCE_MODPOST_WARNINGS_TO_ERRORS
+ bool "Force modpost warnings to errors"
+ help
+ Force warnings generated by modpost to be reported as errors.
+ Another build time setting to encourage some action be taken by
+ the developer to fix the problem.
+
+ If developing new code say y.
+
endmenu # "Compiler options"
config MAGIC_SYSRQ
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index d439856..d430eb6 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -70,6 +70,11 @@ PRINTF void warn(const char *fmt, ...)
va_start(arglist, fmt);
vfprintf(stderr, fmt, arglist);
va_end(arglist);
+
+#ifdef CONFIG_DEBUG_FORCE_MODPOST_WARNINGS_TO_ERRORS
+ fprintf(stderr, "modpost: warnings treated as errors.\n");
+ exit(1);
+#endif
}
PRINTF void merror(const char *fmt, ...)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 kbuild for-next 1/2] makefiles: add config option to force all cc warnings to errors
2015-03-27 17:51 [PATCH v2 kbuild for-next 1/2] makefiles: add config option to force all cc warnings to errors Jonathan Toppins
2015-03-27 17:51 ` [PATCH v2 kbuild for-next 2/2] modpost: add Kconfig option to report warnings as errors Jonathan Toppins
@ 2015-03-30 13:35 ` Michal Marek
1 sibling, 0 replies; 3+ messages in thread
From: Michal Marek @ 2015-03-30 13:35 UTC (permalink / raw)
To: Jonathan Toppins; +Cc: linux-kbuild
On 2015-03-27 18:51, Jonathan Toppins wrote:
> Add a Kconfig option to force cc warnings to errors. For new
> development it is recommended this setting be enabled as warnings
> in the code will be quite obvious.
I don't want to add such kconfig option, because it will break
all{mod,yes}config for little gain. And there are warnings like the
preprocessor #warning or the use of a function marked as __deprecated --
these a basically TODOs and there is no point in failing the build. Test
builds can be done with KCFLAGS=-Werror or you can grep build logs.
Michal
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-30 13:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-27 17:51 [PATCH v2 kbuild for-next 1/2] makefiles: add config option to force all cc warnings to errors Jonathan Toppins
2015-03-27 17:51 ` [PATCH v2 kbuild for-next 2/2] modpost: add Kconfig option to report warnings as errors Jonathan Toppins
2015-03-30 13:35 ` [PATCH v2 kbuild for-next 1/2] makefiles: add config option to force all cc warnings to errors Michal Marek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).