From 7569ec2a6ccaddea9679af6ffe77e5edf4c77e4c Mon Sep 17 00:00:00 2001 From: Thomas Perale Date: Sun, 29 Jun 2025 22:09:17 +0200 Subject: [PATCH] package/kvmtool: fix build failure w/ musl The following error occurs on the autobuilder for builds with musl libc. ``` CC util/bitmap.o In file included from include/linux/bitmap.h:7, from util/bitmap.c:9: include/linux/bitops.h:4:10: fatal error: bits/wordsize.h: No such file or directory 4 | #include | ^~~~~~~~~~~~~~~~~ ``` The error occurs because bits/wordsize.h is specific to glibc. This patch applies an upstream fix that replaces the use of __WORDSIZE with an internal macro, making the code portable across different libc. Fixes: https://autobuild.buildroot.org/results/30d/30d6e407e6a0fc7d85062c2d56008755c70ca733/build-end.log Signed-off-by: Thomas Perale Signed-off-by: Julien Olivain (cherry picked from commit 901b9e19ed3741d0cc379ff8f145b2294a3bd09b) Signed-off-by: Thomas Perale --- ...e-h-inclusion-for-musl-compatibility.patch | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 package/kvmtool/0001-remove-wordsize-h-inclusion-for-musl-compatibility.patch diff --git a/package/kvmtool/0001-remove-wordsize-h-inclusion-for-musl-compatibility.patch b/package/kvmtool/0001-remove-wordsize-h-inclusion-for-musl-compatibility.patch new file mode 100644 index 0000000000..3128a23689 --- /dev/null +++ b/package/kvmtool/0001-remove-wordsize-h-inclusion-for-musl-compatibility.patch @@ -0,0 +1,52 @@ +From 0592f8f829c843ff5cb2d108c309e32f4f6f5379 Mon Sep 17 00:00:00 2001 +From: Andre Przywara +Date: Thu, 1 Aug 2024 12:10:54 +0100 +Subject: remove wordsize.h inclusion (for musl compatibility) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The wordsize.h header file and the __WORDSIZE definition do not seem +to be universal, the musl libc for instance has the definition in a +different header file. This breaks compilation of kvmtool against musl. + +The two leading underscores suggest a compiler-internal symbol anyway, so +let's just remove that particular macro usage entirely, and replace it +with the number we really want: the size of a "long" type. + +Reported-by: J. Neuschäfer +Signed-off-by: Andre Przywara +Reviewed-by: Alexandru Elisei +Link: https://lore.kernel.org/r/20240801111054.818765-1-andre.przywara@arm.com +Signed-off-by: Will Deacon +Upstream: https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git/commit/?id=0592f8f829c843ff5cb2d108c309e32f4f6f5379 +Signed-off-by: Thomas Perale +--- + include/linux/bitops.h | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/include/linux/bitops.h b/include/linux/bitops.h +index ae33922f..ee8fd560 100644 +--- a/include/linux/bitops.h ++++ b/include/linux/bitops.h +@@ -1,15 +1,13 @@ + #ifndef _KVM_LINUX_BITOPS_H_ + #define _KVM_LINUX_BITOPS_H_ + +-#include +- + #include + #include + #include + +-#define BITS_PER_LONG __WORDSIZE + #define BITS_PER_BYTE 8 +-#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) ++#define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long)) ++#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) + + #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) + +-- +cgit 1.2.3-korg +