package/kvmtool: fix build failure w/ musl
PATCH 1/1 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 <bits/wordsize.h>
| ^~~~~~~~~~~~~~~~~
```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.
--- ...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
package/kvmtool/0001-remove-wordsize-h-inclusion-for-musl-compatibility.patch new file +52 -0
@@ -0,0 +1,52 @@ +From 0592f8f829c843ff5cb2d108c309e32f4f6f5379 Mon Sep 17 00:00:00 2001 +From: Andre Przywara <[email protected]> +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 <[email protected]> +Signed-off-by: Andre Przywara <[email protected]> +Reviewed-by: Alexandru Elisei <[email protected]> +Link: https://lore.kernel.org/r/[email protected] +Signed-off-by: Will Deacon <[email protected]> +Upstream: https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git/commit/?id=0592f8f829c843ff5cb2d108c309e32f4f6f5379 +Signed-off-by: Thomas Perale <[email protected]> +--- + 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 <bits/wordsize.h> +- + #include <linux/kernel.h> + #include <linux/compiler.h> + #include <asm/hweight.h> + +-#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 +
Signature · 6 lines
2.50.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Julien Olivain via buildroot
AppliedQuoted 12 lines · Thomas Perale via buildroot
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 <bits/wordsize.h> | ^~~~~~~~~~~~~~~~~ ```
Quoted 7 lines
The error occurs because
bits/wordsize.his specific to glibc.This patch applies an upstream fix that replaces the use of
__WORDSIZEwith an internal macro, making the code portable across different libc.
Applied to master, thanks.
While testing this patch, I noticed it fixed the reported issue in a gcc13 and musl libc configuration, but switching to gcc14 fails.
It can be reproduced with:
cat >.config <<EOF
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_AARCH64_MUSL_BLEEDING_EDGE=y BR2_PACKAGE_KVMTOOL=y
EOF
make olddefconfig
make kvmtool
Compilation fails with message:
vfio/core.c: In function ‘vfio_group_get_for_dev’:
vfio/core.c:537:22: error: implicit declaration of function
‘basename’ [-Wimplicit-function-declaration]
537 | group_name = basename(group_path);
| ^~~~~~~~
vfio/core.c:537:22: warning: nested extern declaration of ‘basename’
[-Wnested-externs]
vfio/core.c:537:20: error: assignment to ‘char *’ from ‘int’ makes
pointer from integer without a cast [-Wint-conversion]
537 | group_name = basename(group_path);
| ^Could you have a look, please?
Best regards,
Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas Perale via buildroot
AppliedIn reply of:
Quoted 12 lines
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 <bits/wordsize.h> | ^~~~~~~~~~~~~~~~~ ```
Quoted 7 lines
The error occurs because
bits/wordsize.his specific to glibc.This patch applies an upstream fix that replaces the use of
__WORDSIZEwith an internal macro, making the code portable across different libc.
Applied to 2025.02.x & 2025.05.x. Thanks
Quoted 70 lines
--- ...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.patchpackage/kvmtool/0001-remove-wordsize-h-inclusion-for-musl-compatibility.patch new file +52
-0@@ -0,0 +1,52 @@ +From 0592f8f829c843ff5cb2d108c309e32f4f6f5379 Mon Sep 17 00:00:00 2001 +From: Andre Przywara <[email protected]> +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 <[email protected]> +Signed-off-by: Andre Przywara <[email protected]> +Reviewed-by: Alexandru Elisei <[email protected]> +Link: https://lore.kernel.org/r/[email protected] +Signed-off-by: Will Deacon <[email protected]> +Upstream: https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git/commit/?id=0592f8f829c843ff5cb2d108c309e32f4f6f5379 +Signed-off-by: Thomas Perale <[email protected]> +--- + 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 <bits/wordsize.h> +- + #include <linux/kernel.h> + #include <linux/compiler.h> + #include <asm/hweight.h> + +-#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 +Signature · 6 lines
2.50.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot