Discussion:
How to add a -W flag in local Makefile
(too old to reply)
Warner Losh
2024-04-18 14:47:15 UTC
Permalink
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?
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
Konstantin Belousov
2024-04-18 17:57:16 UTC
Permalink
diff --git a/sys/dev/hyperv/vmbus/vmbus_var.h b/sys/dev/hyperv/vmbus/vmbus_var.h
index b598f782947e..6e3b7b040827 100644
--- a/sys/dev/hyperv/vmbus/vmbus_var.h
+++ b/sys/dev/hyperv/vmbus/vmbus_var.h
@@ -193,4 +193,17 @@ struct hyperv_tlb_flush {
uint64_t hv_vm_tlb_flush(pmap_t pmap, vm_offset_t addr1,
vm_offset_t addr2, cpuset_t mask);
+struct hv_vpset {
+ uint64_t format;
+ uint64_t valid_bank_mask;
+ uint64_t bank_contents[];
+} __packed;
+
+struct hv_tlb_flush_ex {
+ uint64_t address_space;
+ uint64_t flags;
+ struct hv_vpset hv_vp_set;
+ uint64_t gva_list[];
+} __packed;
+
#endif /* !_VMBUS_VAR_H_ */
No, the compiler' complain is correct. The structure definition for
hv_tlb_flush_ex does not make sense: you never can access gva_list (except
for the case of bank_contents being zero-sized).


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Dag-Erling Smørgrav
2024-04-19 10:58:19 UTC
Permalink
The same code already exists in Linux and Windows. Linux also added a compiling
flag to suppress similar warnings.
That's not an excuse. The code makes no sense.
Anyway, the purpose of this email is to understand how to add such flags in local
Makefiles and make it effective for global buildkernel. Adding such flags
in local Makefiles already proves to be working when only building under local
directory.
You would have to add it to every line in sys/conf/files* that
references a C file which includes this header.

DES
--
Dag-Erling Smørgrav - ***@FreeBSD.org


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Dag-Erling Smørgrav
2024-04-20 14:29:23 UTC
Permalink
Post by Dag-Erling Smørgrav
The same code already exists in Linux and Windows. Linux also added a
compiling flag to suppress similar warnings.
That's not an excuse. The code makes no sense.
I don't care, it's bad code and the compiler is right to complain about
it.

DES
--
Dag-Erling Smørgrav - ***@FreeBSD.org


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...