public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: PATCH: compile the kernel with -Werror
@ 2002-07-13 21:31 Dan Kegel
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Kegel @ 2002-07-13 21:31 UTC (permalink / raw)
  To: linux-kernel

Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:

> On Sat, 2002-07-13 at 14:41, Roy Sigurd Karlsbakk wrote: 
>> Why not add a menu item under kernel hacking?
> 
> CONFIG_TEACH_USER_TO_USE_GREP 

It's a bit challenging to grep for errors in gcc's output, as
gcc produces multiline errors and warnings.
Here's a perl script I whipped up yesterday to filter out
all but the errors and warnings from a make + gcc run
for some other project; it'd probably do nicely on kernel
builds.  I use it like this:

     make > log 2>&1
     errfilter.pl log | more

It has the dubious feature that it properly filters out the
warnings gcc produces on .h files that don't end in newlines
(guess what IDE people use here?)
- Dan

--- errfilter.pl ---



#!/usr/bin/perl
# Filter out all but essential lines of the output of a make + gcc run.
# Dan Kegel dkegel@ixiacom.com 12 July 2002

# Join logical lines which have been split into multiple physical lines
while (<>) {
     chop;
     if (/^\S/) {
         &save($linebuf);
         $linebuf = "";
     }
     $linebuf .= $_;
}
# Force blank lines at end
&save($linebuf);
&save("");

# Handle next logical line.  Handle lines of context, like 'Entering directory', properly.
sub save
{
     my($buf) = $_[0];

     # Remove excess space used at beginning of all but first physical
     # of a long logical line.
     $buf =~ s/  */ /g;

     if ($buf =~ /In file included from/) {
         # Handle include context.
         $prefix = $buf."\n";
     } elsif ($buf =~ /Entering directory/) {
         # Handle directory context.
         unshift(@dir, $buf."\n");
         $curdir = $dir[0];
     } elsif ($buf =~ /Leaving directory/) {
         # Handle directory context.
         shift(@dir);
         $curdir = $dir[0];
     } else {
         # Handle possible error lines.
         if (&filter($buf)) {
             # It's an error.  Print it out with its context.
             print $curdir.$prefix.$buf;
             print "\n";
             # Dir context only gets printed out once per directory change.
             $curdir = "";
         }
         # Include context only gets printed out for immediately following line.
         $prefix = "";
     }
}

# Return true if given logical line contains a gcc error or warning and has not been seen before
sub filter
{
     my($line) = $_[0];

     if ($line =~ /:.*:/) {
         if ($line !~ /treated|sed.*\.d|no newline at end|warning: overriding commands|warning: ignoring old commands|File format not recognized/) {
             # uniq
             if ($out{$line} == 0) {
                 $out{$line}++;
                 return 1;
             }
         }
     }
     return 0;
}




^ permalink raw reply	[flat|nested] 13+ messages in thread
* PATCH: compile the kernel with -Werror
@ 2002-07-13  7:26 Muli Ben-Yehuda
  2002-07-13  8:02 ` Zwane Mwaikambo
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Muli Ben-Yehuda @ 2002-07-13  7:26 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: William Lee Irwin III, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1512 bytes --]

A full kernel compilation, especially when using the -j switch to
make, can cause warnings to "fly off the screen" without the user
noticing them. For example, wli's patch lazy_buddy.2.5.25-1 of today
had a missing return statement in a function returning non void, which
the compiler probably complained about but the warning got lost in the
noise (a little birdie told me wli used -j64). 

The easiest safeguard agsinst this kind of problems is to compile with
-Werror, so that wherever there's a warning, compilation
stops. Compiling 2.5.25 with -Werror with my .config found only three
warnings (quite impressive, IMHO), and patches for those were sent to
trivial@rusty.

Patch against 2.5.25 to add -Werror attached:

--- linux-2.5.25-vanilla/Makefile	Sat Jul  6 02:42:04 2002
+++ linux-2.5.25-mx/Makefile	Sat Jul 13 10:01:55 2002
@@ -39,7 +39,7 @@
 FINDHPATH	= $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net
 
 HOSTCC  	= gcc
-HOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
+HOSTCFLAGS	= -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer 
 
 CROSS_COMPILE 	=
 
@@ -211,7 +211,7 @@
 
 CPPFLAGS := -D__KERNEL__ -I$(HPATH)
 
-CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
+CFLAGS := $(CPPFLAGS) -Wall -Werror -Wstrict-prototypes -Wno-trigraphs -O2 \
 	  -fomit-frame-pointer -fno-strict-aliasing -fno-common
 AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS)

-- 
http://vipe.technion.ac.il/~mulix/
http://syscalltrack.sf.net/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2002-07-16 20:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-13 21:31 PATCH: compile the kernel with -Werror Dan Kegel
  -- strict thread matches above, loose matches on Subject: below --
2002-07-13  7:26 Muli Ben-Yehuda
2002-07-13  8:02 ` Zwane Mwaikambo
2002-07-13  7:43   ` Muli Ben-Yehuda
2002-07-13 14:49     ` Thunder from the hill
2002-07-13  8:17 ` Mike Galbraith
2002-07-13 13:10 ` Kenneth Johansson
2002-07-13 13:41 ` Roy Sigurd Karlsbakk
2002-07-13 14:59   ` Alan Cox
2002-07-16 20:36   ` James Antill
2002-07-13 14:24 ` Alan Cox
2002-07-13 13:34   ` William Lee Irwin III
2002-07-13 18:46   ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox