Skip to contentSkip to conversation

PATCH: compile the kernel with -Werror

DISCUSSION Dan Kegel 1 participant 1 message Jul 13, 2002

lore
Share & tools
lore

Dan Kegel

author
#0 lore raw
Quoted 4 lines · Alan Cox
Quoted 1 line · Roy Sigurd Karlsbakk

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 [email protected] 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;
}