[PATCH] sparse: Add CLOG option for saving warning

From: Christopher Li
Date: Mon Jun 30 2014 - 04:57:23 EST


Currently sparse warning only output to stderr.
In the parallel build process, different source
file output is fixed together. It is hard to keep
track of the warning.

Add the CLOG=<logname> option in command line to
save the sparse warning into individual log file.

Typical usage:

make -j8 C=2 CLOG=<logname>

The log file is saved in the target directory as
.xxx.o.<logname>.sparse

By diffing between different log file, it is much
easier to analyze how the sparse change impact
the whole kernel build.

Signed-off-by: Christopher Li <sparse@xxxxxxxxxxx>


Chris
From 3b2ff204cbda684adf9dba2adf568062533ae34d Mon Sep 17 00:00:00 2001
From: Christopher Li <sparse@xxxxxxxxxxx>
Date: Mon, 30 Jun 2014 01:33:22 -0700
Subject: [PATCH] sparse: Add CLOG option for saving warning

Currently sparse warning only output to stderr.
In the parallel build process, different source
file output is fixed together. It is hard to keep
track of the warning.

Add the CLOG=<logname> option in command line to
save the sparse warning into individual log file.

Typical usage:

make -j8 C=2 CLOG=<logname>

The log file is saved in the target directory as
.xxx.o.<logname>.sparse

By diffing between different log file, it is much
easier to analyze how the sparse change impact
the whole kernel build.

Signed-off-by: Christopher Li <sparse@xxxxxxxxxxx>
---
Makefile | 13 ++++++++++++-
scripts/Makefile.build | 11 +++++++++--
2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index b11e2d5..56c3502 100644
--- a/Makefile
+++ b/Makefile
@@ -68,6 +68,16 @@ ifndef KBUILD_CHECKSRC
KBUILD_CHECKSRC = 0
endif

+ifeq ("$(origin CLOG)", "command line")
+ KBUILD_CHECKLOG = $(CLOG)
+endif
+ifndef KBUILD_CHECKLOG
+ KBUILD_CHECKLOG =
+endif
+
+
+
+
# Use make M=dir to specify directory of external module to build
# Old syntax make ... SUBDIRS=$PWD is still supported
# Setting the environment variable KBUILD_EXTMOD take precedence
@@ -287,7 +297,7 @@ ifeq ($(MAKECMDGOALS),)
endif

export KBUILD_MODULES KBUILD_BUILTIN
-export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
+export KBUILD_CHECKSRC KBUILD_CHECKLOG KBUILD_SRC KBUILD_EXTMOD

# Beautify output
# ---------------------------------------------------------------------------
@@ -1370,6 +1380,7 @@ clean: $(clean-dirs)
$(call cmd,rmfiles)
@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
+ -o -name '.*.sparse' \
-o -name '*.ko.*' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-o -name '*.symtypes' -o -name 'modules.order' \
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index bf3e677..45c6004 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -96,14 +96,21 @@ __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
$(subdir-ym) $(always)
@:

+check_log_file = $(dot-target).$(KBUILD_CHECKLOG).sparse
+
+ifneq ($(KBUILD_CHECKLOG),)
+ check_logging = 2> $(check_log_file)
+endif
+
+cmd_check = $(CHECK) $(CHECKFLAGS) $(c_flags) $< $(check_logging) ;
# Linus' kernel sanity checking tool
ifneq ($(KBUILD_CHECKSRC),0)
ifeq ($(KBUILD_CHECKSRC),2)
quiet_cmd_force_checksrc = CHECK $<
- cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
+ cmd_force_checksrc = $(cmd_check)
else
quiet_cmd_checksrc = CHECK $<
- cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
+ cmd_checksrc = $(cmd_check)
endif
endif

--
1.9.3