Page MenuHomeFreeBSD

iwlwifi: fix the gcc build
ClosedPublic

Authored by ngie on Nov 4 2025, 11:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 4, 2:00 AM
Unknown Object (File)
Wed, Dec 3, 6:32 PM
Unknown Object (File)
Fri, Nov 28, 10:40 PM
Unknown Object (File)
Nov 15 2025, 9:25 PM
Unknown Object (File)
Nov 14 2025, 7:31 AM
Unknown Object (File)
Nov 14 2025, 5:32 AM
Unknown Object (File)
Nov 14 2025, 4:56 AM
Unknown Object (File)
Nov 14 2025, 4:49 AM

Details

Summary
  • Only apply the previously added CWARNFLAGS to drv.c instead of the whole module.
  • Only apply -Wno-initializer-overrides to CWARNFLAGS in the clang scenario for drv.c as the flag is clang-specific.

This fixes building the module with gcc and avoids accidentally
introducing tech debt with the module, in the event other issues are
accidentally introduced.

MFC after: 3 days
Fixes: 6b627f8858 ("iwlwifi: update Intel's mvm/mld drivers")

Test Plan
Basic check to ensure the flag was being passed properly
% CC=gcc14 make -n all | grep 'pcie/drv\.c' | egrep -o 'Wno-override-init|Wno-initializer-overrides'
Wno-override-init
% CC=clang make -n all | grep 'pcie/drv\.c' | egrep -o 'Wno-override-init|Wno-initializer-overrides'
Wno-override-init
Wno-initializer-overrides
Build spot checks

The build passed in the following scenarios:

  • clang from base: make all CC=cc -j$(nproc)
  • devel/freebsd-gcc14 with TARGET=amd64/TARGET_ARCH=amd64: make all CC=x86_64-unknown-freebsd14.3-gcc14 -j$(nproc)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ngie requested review of this revision.Nov 4 2025, 11:09 PM
ngie added a reviewer: bz.
ngie added a subscriber: network.
delphij added a subscriber: delphij.

I think what bz@ really wanted is something like:

.if ${COMPILER_TYPE} == "clang"
CWARNFLAGS.drv.c += -Wno-override-init -Wno-initializer-overrides
.endif

but your change should be sufficient to fix gcc build.

This revision is now accepted and ready to land.Nov 5 2025, 7:09 AM

Give me a day; I think I actually had a proper solution for this for the never happened v6.16 import.
Otherwise be my guest and put this in and I'll follow-up again.

Also -Wno-override-init is for gcc, isn't it?

I think what bz@ really wanted is something like:

.if ${COMPILER_TYPE} == "clang"
CWARNFLAGS.drv.c += -Wno-override-init -Wno-initializer-overrides
.endif

but your change should be sufficient to fix gcc build.

Ah, yes -- that's the best way to handle it.. I'll wait for @bz to do what he plans on doing before landing a similar change.

@bz: Give me a day; I think I actually had a proper solution for this for the never happened v6.16 import.
Otherwise be my guest and put this in and I'll follow-up again.

Also -Wno-override-init is for gcc, isn't it?

Odd. It shows up in the manpage. Ah, wait... -Wno-initializer-overrides is the one that isn't present in gcc13--so technically my proposed change was incorrect.

Incorporate corrections/suggestions from @delphij

This revision now requires review to proceed.Nov 5 2025, 8:15 PM
bz requested changes to this revision.Nov 5 2025, 8:45 PM
bz added inline comments.
sys/modules/iwlwifi/Makefile
99

Missing -

This revision now requires changes to proceed.Nov 5 2025, 8:45 PM
In D53591#1223710, @bz wrote:

You do not need the .if if you do it as suggested here:
https://lists.freebsd.org/archives/freebsd-hackers/2025-August/004872.html

That line/logic doesn't exist on main. That requires a change to bsd.sys.mk.

ngie marked an inline comment as done.Nov 5 2025, 8:59 PM

I cannot test gcc currently but if the above logic is correct you can simplify it to

% git diff .
diff --git sys/modules/iwlwifi/Makefile sys/modules/iwlwifi/Makefile
index 5d4830537a0b..f880536d5885 100644
--- sys/modules/iwlwifi/Makefile
+++ sys/modules/iwlwifi/Makefile
@@ -91,7 +91,6 @@ CFLAGS+=      -DCONFIG_IWLWIFI_DEVICE_TRACING=1
 #CFLAGS+=      -DCONFIG_THERMAL=1
 #CFLAGS+=      -DCONFIG_EFI=1
 
-# XXX-BZ how to do this just for pcie/drv.c (and gcc vs. clang)?
-CFLAGS += -Wno-override-init -Wno-initializer-overrides
+CWARNFLAGS.drv.c+=         -Wno-override-init
 
 .include <bsd.kmod.mk>

which seems to work on main currently with clang (please make sure to test both before commit).

My initial version was to do something like:

diff --git sys/modules/iwlwifi/Makefile sys/modules/iwlwifi/Makefile
index 5d4830537a0b..1a99e3c0b74a 100644
--- sys/modules/iwlwifi/Makefile
+++ sys/modules/iwlwifi/Makefile
@@ -91,7 +91,8 @@ CFLAGS+=      -DCONFIG_IWLWIFI_DEVICE_TRACING=1
 #CFLAGS+=      -DCONFIG_THERMAL=1
 #CFLAGS+=      -DCONFIG_EFI=1
 
-# XXX-BZ how to do this just for pcie/drv.c (and gcc vs. clang)?
-CFLAGS += -Wno-override-init -Wno-initializer-overrides
+CWARNFLAGS.gcc.drv.c+=         -Wno-override-init
+CWARNFLAGS.clang.drv.c+=       -Wno-initializer-overrides
+CWARNFLAGS.drv.c+=             ${CWARNFLAGS.${COMPILER_TYPE}.${.IMPSRC:T}}
 
 .include <bsd.kmod.mk>
ngie edited the test plan for this revision. (Show Details)

Incorporate feedback from @bz

ngie edited the test plan for this revision. (Show Details)

I still think it's a good idea to push ${CWARNFLAGS.${COMPILER_TYPE}.${.IMPSRC:T}} into bsd.sys.mk, but this is ok too.

I still think it's a good idea to push ${CWARNFLAGS.${COMPILER_TYPE}.${.IMPSRC:T}} into bsd.sys.mk, but this is ok too.

If you want to do this I think it needs to be consistent between user land and kernel and modules and thus should be a totally different change and then some of the current "hacks" would need to be undone at the same time. I'd be happy if someone would persue this but it's clearly not my area of expertise.

bz added inline comments.
sys/modules/iwlwifi/Makefile
95

In Phabricator on the web this looks like a space issue but seems to be clean in the patch.

Also, again, the original reason to set both options was that one was sufficient for each compiler. I wonder how -Wno-override-init is implemented in clang?

contrib/llvm-project/clang/include/clang/Basic/DiagnosticGroups.td:// For compatibility with GCC; -Woverride-init = -Winitializer-overrides

I'd still feel it'd be cleaner to either only set one or set one per compiler.

But let's get this in and then if we get proper per-compiler, per-file support then we can still have a .clang. and a .gcc. with the different options or we migrate the "alias" into a central place.

This revision is now accepted and ready to land.Nov 6 2025, 9:32 PM
This revision was automatically updated to reflect the committed changes.
ngie marked an inline comment as done.Nov 6 2025, 9:45 PM
ngie added inline comments.
sys/modules/iwlwifi/Makefile
95

Oof -- it is kind of silly to specify both for clang... oh well.
I'll look at what's needed for share/mk to generalize this pattern and unwind this a bit later.