Skip to contentSkip to conversation

PATCH: compile the kernel with -Werror

PATCH Muli Ben-Yehuda 10 participants 12 messages Jul 13, 2002 – Jul 16, 2002 Kbuild

lore
Share & tools
lore
#0 lore raw

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:

Makefile +2 -2
@@ -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)
 
Signature · 2 lines
http://vipe.technion.ac.il/~mulix/
http://syscalltrack.sf.net/
#1 lore raw
Quoted 3 lines · Muli Ben-Yehuda

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

Signature · 1 line
function.linuxpower.ca
#2 lore raw
Quoted 7 lines · Zwane Mwaikambo
Quoted 3 lines · Muli Ben-Yehuda

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 ;)

Signature · 2 lines
http://vipe.technion.ac.il/~mulix/
http://syscalltrack.sf.net/
#3 lore raw

Hi,

Quoted 2 lines · Muli Ben-Yehuda

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

Signature · 7 lines
(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------
#4 lore raw
In reply to Muli Ben-Yehuda
Quoted 7 lines · Muli Ben-Yehuda

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

Quoted 5 lines

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

#5 lore raw
In reply to Muli Ben-Yehuda
Quoted 6 lines · Muli Ben-Yehuda

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.

#6 lore raw
In reply to Muli Ben-Yehuda
Quoted 3 lines · Muli Ben-Yehuda

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.

#7 lore raw
Quoted 3 lines · Muli Ben-Yehuda
Quoted 3 lines

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.

Quoted 3 lines · Alan Cox

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

#8 lore raw
In reply to Alan Cox
Quoted 4 lines · Alan Cox

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

#9 lore raw
In reply to Muli Ben-Yehuda
Quoted 6 lines · Muli Ben-Yehuda

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

Signature · 4 lines
Roy Sigurd Karlsbakk, Datavaktmester

Computers are like air conditioners.
They stop working when you open Windows.
#10 lore raw
Quoted 1 line · Roy Sigurd Karlsbakk

Why not add a menu item under kernel hacking?

CONFIG_TEACH_USER_TO_USE_GREP

#11 lore raw
In reply to Roy Sigurd Karlsbakk
Quoted 9 lines · Roy Sigurd Karlsbakk
Quoted 6 lines · Muli Ben-Yehuda

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

Signature · 4 lines
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