2002-07-13 07:28:51

by Muli Ben-Yehuda

[permalink] [raw]
Subject: PATCH: compile the kernel with -Werror

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/


Attachments:
(No filename) (1.44 kB)
(No filename) (189.00 B)
Download all attachments

2002-07-13 07:42:41

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

On Sat, 13 Jul 2002, Muli Ben-Yehuda wrote:

> 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.

You need to add more drivers to your config ;)

Cheers,
Zwane

--
function.linuxpower.ca

2002-07-13 07:46:12

by Muli Ben-Yehuda

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

On Sat, Jul 13, 2002 at 10:02:19AM +0200, Zwane Mwaikambo wrote:
> On Sat, 13 Jul 2002, Muli Ben-Yehuda wrote:
>
> > 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.
>
> You need to add more drivers to your config ;)

I'm doing something better - make allyesconfig, minus things like
intermezzo which are totally broken in 2.5.25.

Next up: -pedantic ;)
--
http://vipe.technion.ac.il/~mulix/
http://syscalltrack.sf.net/


Attachments:
(No filename) (538.00 B)
(No filename) (189.00 B)
Download all attachments

2002-07-13 08:16:57

by Mike Galbraith

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

At 10:26 AM 7/13/2002 +0300, Muli Ben-Yehuda wrote:
>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.

If you put -Werror in the stock flags, things like gcc warning that feature-foo
will go away someday becomes deadly.. bad idea IMO.

If people are building kernels (or anything else) and not making/checking
logs, they're wrong.

-Mike

2002-07-13 13:08:00

by Kenneth Johansson

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

On Sat, 2002-07-13 at 09:26, Muli Ben-Yehuda wrote:
> 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).

use

make -j64 KBUILD_VERBOSE=0

This is similar to what kbuils2.5 dose by default but since the in
kernel version do not have one single makefile the output gets a bit
reshuffled.

But -j64 dose seem a but hi I usually use the same as numbers of cpu.
over nfs I go a little higher.



2002-07-13 13:13:27

by Alan

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

On Sat, 2002-07-13 at 08:26, Muli Ben-Yehuda wrote:
> 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.

May I suggest the user learns to use the command line properly. Adding
-Werror doesn't help because gcc emits far too many bogus warnings for
that.

2002-07-13 13:32:57

by William Lee Irwin III

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

On Sat, 2002-07-13 at 08:26, Muli Ben-Yehuda wrote:
>> 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.

On Sat, Jul 13, 2002 at 03:24:03PM +0100, Alan Cox wrote:
> May I suggest the user learns to use the command line properly. Adding
> -Werror doesn't help because gcc emits far too many bogus warnings for
> that.

This is not my favorite motive for -Werror. I prefer the "force people
to write cleaner code" aspect of it, but gcc's warnings are evil...


Cheers,
Bill

2002-07-13 13:38:50

by Roy Sigurd Karlsbakk

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

On Saturday 13 July 2002 09:26, Muli Ben-Yehuda wrote:
> 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).

Why not add a menu item under kernel hacking?

roy

--
Roy Sigurd Karlsbakk, Datavaktmester

Computers are like air conditioners.
They stop working when you open Windows.

2002-07-13 13:49:21

by Alan

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

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


2002-07-13 14:47:49

by Thunder from the hill

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

Hi,

On Sat, 13 Jul 2002, Muli Ben-Yehuda wrote:
> I'm doing something better - make allyesconfig, minus things like
> intermezzo which are totally broken in 2.5.25.

Intermezzo _compiles_ just fine for me.

Regards,
Thunder
--
(Use http://www.ebb.org/ungeek if you can't decode)
------BEGIN GEEK CODE BLOCK------
Version: 3.12
GCS/E/G/S/AT d- s++:-- a? C++$ ULAVHI++++$ P++$ L++++(+++++)$ E W-$
N--- o? K? w-- O- M V$ PS+ PE- Y- PGP+ t+ 5+ X+ R- !tv b++ DI? !D G
e++++ h* r--- y-
------END GEEK CODE BLOCK------

2002-07-13 18:41:38

by Linus Torvalds

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror



On 13 Jul 2002, Alan Cox wrote:
>
> May I suggest the user learns to use the command line properly. Adding
> -Werror doesn't help because gcc emits far too many bogus warnings for
> that.

Especially _some_ versions of gcc.

We've tried this before, and there are versions of gcc that have some
warnings on by default that simply aren't acceptable and cannot be avoided
sanely (I think at least some snapshots had the sign warnings on, for
example, which causes some really silly warnings where the warnings are
less odious than the changes required to get rid of them).

That said, I don't think -Werror is really wrong. It might make it less
likely to have new drivers introducing unnecessary warnings..

Linus

2002-07-13 20:45:45

by Dan Kegel

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

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



2002-07-16 20:36:19

by James Antill

[permalink] [raw]
Subject: Re: PATCH: compile the kernel with -Werror

Roy Sigurd Karlsbakk <[email protected]> writes:

> On Saturday 13 July 2002 09:26, Muli Ben-Yehuda wrote:
> > 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).
>
> Why not add a menu item under kernel hacking?

FFS....

make bzImage > compile.log 2> errors.log

--
James Antill -- [email protected]
"Although I have found authors who assert that the use of internal loop exits
is wrong, I have encountered none that support their claims with objective
evidence." -- Eric S. Roberts, Loop Exits and Structured Programming