Re: How to add a -W flag in local Makefile

From: Warner Losh <imp_at_bsdimp.com>
Date: Thu, 18 Apr 2024 14:47:15 UTC
On Thu, Apr 18, 2024, 7:04 AM Wei Hu <weh@microsoft.com> wrote:

> Hi,
>
> I am trying to add a -W flag to local Makefile so it would only be
> effective for the local source files. But it seems not working when I build
> the entire kernel.
>
> For example, I added a structure in sys/dev/hyperv/vmbus/vmbus_var.h. The
> structure requires adding a -W flag (
> -Wno-gnu-variable-sized-type-not-at-end ) to build successfully for all .c
> files included this header file.
>


What does this type look like?

Maybe the right answer is changing it?

What I did was I add this line in sys/modules/hyperv/vmbus/Makefile:
>
> CWARNFLAGS += -Wno-gnu-variable-sized-type-not-at-end
>

Where did you add it? I think it needs to be after the .includes

Warner


This seems working fine if I build the module by typing 'make' under
> sys/modules/hyperv/vmbus subdir. But it seems having no effect when
> building the kernel by using 'make buildkernel' under global directory.
> Those .c files still fail to build due to lacking this flag.
>
> If I add this flag in the global sys/conf/kern.mk, it seems to be
> working. However, I don't like to add it globally as only a few source
> files under hyperv/vmbus need it. What did I do wrong? Do you know what the
> proper way to add this flag?
>
> Thanks,
> Wei
>
>
>