The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=9755a80363549cc5504b4bb2d18a4a12e34ded28
commit 9755a80363549cc5504b4bb2d18a4a12e34ded28 Author: Bjoern A. Zeeb <[email protected]> AuthorDate: 2025-09-15 23:52:13 +0000 Commit: Bjoern A. Zeeb <[email protected]> CommitDate: 2026-01-16 08:48:47 +0000 LinuxKPI: bitcount fix builds with gcc and older llvm LLVM before 19 and gcc before 14 do not support __builtin_popcountg(). Use __const_bitcount<n> from sys/bitcount.h as a replacement in these cases. This should still allow drm-kmod to build where the size needs to be known at compile-time. Remove the conditional for gcc around the iwlwifi modules build, which was collateral damage in all this. Sponsored by: The FreeBSD Foundation Fixes: 7cbc4d875971, 5e0a4859f28a Reviewed by: brooks, emaste (without the sys/modules/Makefile change) Differential Revision: https://reviews.freebsd.org/D54297 (cherry picked from commit 34892a8e30055000352d9612ad985be550c82bea) --- sys/compat/linuxkpi/common/include/linux/bitops.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/bitops.h b/sys/compat/linuxkpi/common/include/linux/bitops.h index a5a7abd55287..8fac80820f30 100644 --- a/sys/compat/linuxkpi/common/include/linux/bitops.h +++ b/sys/compat/linuxkpi/common/include/linux/bitops.h @@ -57,10 +57,18 @@ #define hweight64(x) bitcount64(x) #define hweight_long(x) bitcountl(x) +#if __has_builtin(__builtin_popcountg) #define HWEIGHT8(x) (__builtin_popcountg((uint8_t)(x))) #define HWEIGHT16(x) (__builtin_popcountg((uint16_t)(x))) #define HWEIGHT32(x) (__builtin_popcountg((uint32_t)(x))) #define HWEIGHT64(x) (__builtin_popcountg((uint64_t)(x))) +#else +/* LLVM before 19, gcc before 14. */ +#define HWEIGHT8(x) (__const_bitcount8((uint8_t)(x))) +#define HWEIGHT16(x) (__const_bitcount16((uint16_t)(x))) +#define HWEIGHT32(x) (__const_bitcount32((uint32_t)(x))) +#define HWEIGHT64(x) (__const_bitcount64((uint64_t)(x))) +#endif static inline int __ffs(int mask)
