Re: [PATCH -v5] kbuild: Add extra gcc checks

From: Michal Marek
Date: Thu Mar 10 2011 - 04:17:30 EST


On 10.3.2011 10:04, Ingo Molnar wrote:
>
> * Sam Ravnborg <sam@xxxxxxxxxxxx> wrote:
>
>>> Another, related, very nice kbuild feature would be to allow for arch maintainers to
>>> mark certain files as "should only build fine without warnings" - i.e. -Werror
>>> should be the default. There would be a Kconfig feature to opt out of this,
>>> CONFIG_CC_IGNORE_WARNINGS=y or so. This would allow for people to still build the
>>> kernel with old (or buggy) versions of GCC.
>>
>> To add -Werror for all files conditionally you can do:
>>
>> ccflags-$(CONFIG_WERROR) += -Werror
>>
>> For individual files we can then drop -Werror like this:
>>
>> CFLAGS_REMOVE_foobar.o := -Werror
>>
>> So it should be doable with the existing infrastructure.
>
> Stupid question: is there an existing kbuild rule that i could use to enable -Werror
> for a single .o file, such as kernel/sched.o - without affecting other files in
> kernel/ that i do not maintain?

CFLAGS_sched.o := -Werror


> Also, adding 3 lines per object file is pretty ugly - would it be possible to create
> a nicer, compact, single-line way to someone condense a CONFIG_ERROR opt-out
> mechanism, the -Werror default and the single-object-file into a single rule?
>
> Something like:
>
> obj-werror-y += sched.o
>
> Although i'm not sure if it is wise to mix build details into the object build tree
> hierarchy like that ...

One way without extending the current rules could be:

ifdef CONFIG_CC_WERROR
Werror := -Werror
endif

CFLAGS_sched.o := $(Werror)
CFLAGS_another.o := $(Werror)

What do you think?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/