Message ID | 20240727-musl-v2-2-b106252a1cba@gmx.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix compilation with musl-libc based toolchains | expand |
Hi, CC'ing the maintainers (can be found in README). On Sat, Jul 27, 2024 at 07:11:03PM +0200, J. Neuschäfer wrote: > musl-libc doesn't provide <bits/wordsize.h>, but it defines __WORDSIZE > in <sys/reg.h> and <sys/user.h>. > > Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net> > --- > include/linux/bitops.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/bitops.h b/include/linux/bitops.h > index ae33922..4f133ba 100644 > --- a/include/linux/bitops.h > +++ b/include/linux/bitops.h > @@ -1,7 +1,7 @@ > #ifndef _KVM_LINUX_BITOPS_H_ > #define _KVM_LINUX_BITOPS_H_ > > -#include <bits/wordsize.h> > +#include <sys/reg.h> When cross-compiling on x86 for arm64, as well as when compiling natively for arm64 I get this error: In file included from include/linux/bitmap.h:7, from util/find.c:4: include/linux/bitops.h:5:10: fatal error: sys/reg.h: No such file or directory 5 | #include <sys/reg.h> | ^~~~~~~~~~~ compilation terminated. make: *** [Makefile:510: util/find.o] Error 1 make: *** Waiting for unfinished jobs.... In file included from include/linux/bitmap.h:7, from util/bitmap.c:9: include/linux/bitops.h:5:10: fatal error: sys/reg.h: No such file or directory 5 | #include <sys/reg.h> | ^~~~~~~~~~~ compilation terminated. make: *** [Makefile:510: util/bitmap.o] Error 1 Also, grep finds __WORDSIZE only in bits/wordsize.h on an x86 and arm64 machine: $ grep -r "define __WORDSIZE" /usr/include/ /usr/include/bits/wordsize.h:# define __WORDSIZE 64 /usr/include/bits/wordsize.h:# define __WORDSIZE 32 /usr/include/bits/wordsize.h:# define __WORDSIZE32_SIZE_ULONG 1 /usr/include/bits/wordsize.h:# define __WORDSIZE32_PTRDIFF_LONG 1 /usr/include/bits/wordsize.h:#define __WORDSIZE_TIME64_COMPAT32 0 Thanks, Alex > > #include <linux/kernel.h> > #include <linux/compiler.h> > > -- > 2.43.0 > >
On Mon, 29 Jul 2024 17:24:24 +0100 Alexandru Elisei <alexandru.elisei@arm.com> wrote: > Hi, > > CC'ing the maintainers (can be found in README). > > On Sat, Jul 27, 2024 at 07:11:03PM +0200, J. Neuschäfer wrote: > > musl-libc doesn't provide <bits/wordsize.h>, but it defines __WORDSIZE > > in <sys/reg.h> and <sys/user.h>. > > > > Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net> > > --- > > include/linux/bitops.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/include/linux/bitops.h b/include/linux/bitops.h > > index ae33922..4f133ba 100644 > > --- a/include/linux/bitops.h > > +++ b/include/linux/bitops.h > > @@ -1,7 +1,7 @@ > > #ifndef _KVM_LINUX_BITOPS_H_ > > #define _KVM_LINUX_BITOPS_H_ > > > > -#include <bits/wordsize.h> > > +#include <sys/reg.h> > > When cross-compiling on x86 for arm64, as well as when compiling natively for > arm64 I get this error: > > In file included from include/linux/bitmap.h:7, > from util/find.c:4: > include/linux/bitops.h:5:10: fatal error: sys/reg.h: No such file or directory > 5 | #include <sys/reg.h> > | ^~~~~~~~~~~ > compilation terminated. > make: *** [Makefile:510: util/find.o] Error 1 > make: *** Waiting for unfinished jobs.... > In file included from include/linux/bitmap.h:7, > from util/bitmap.c:9: > include/linux/bitops.h:5:10: fatal error: sys/reg.h: No such file or directory > 5 | #include <sys/reg.h> > | ^~~~~~~~~~~ > compilation terminated. > make: *** [Makefile:510: util/bitmap.o] Error 1 > > Also, grep finds __WORDSIZE only in bits/wordsize.h on an x86 and arm64 machine: I wonder if __WORDSIZE (with two leading underscores!) is something portable enough to be used in userland tools in the first place. The kernel seems to use it, and that's where we inherited it from, I guess. But since we only use it in one place (to define BITS_PER_LONG), can't we just replace this there, with something based on "sizeof(long)"? Looks cleaner anyway, since "word" is an overloaded term. Cheers, Andre > > $ grep -r "define __WORDSIZE" /usr/include/ > /usr/include/bits/wordsize.h:# define __WORDSIZE 64 > /usr/include/bits/wordsize.h:# define __WORDSIZE 32 > /usr/include/bits/wordsize.h:# define __WORDSIZE32_SIZE_ULONG 1 > /usr/include/bits/wordsize.h:# define __WORDSIZE32_PTRDIFF_LONG 1 > /usr/include/bits/wordsize.h:#define __WORDSIZE_TIME64_COMPAT32 0 > > > Thanks, > Alex > > > > > #include <linux/kernel.h> > > #include <linux/compiler.h> > > > > -- > > 2.43.0 > > > > >
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index ae33922..4f133ba 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -1,7 +1,7 @@ #ifndef _KVM_LINUX_BITOPS_H_ #define _KVM_LINUX_BITOPS_H_ -#include <bits/wordsize.h> +#include <sys/reg.h> #include <linux/kernel.h> #include <linux/compiler.h>
musl-libc doesn't provide <bits/wordsize.h>, but it defines __WORDSIZE in <sys/reg.h> and <sys/user.h>. Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net> --- include/linux/bitops.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.43.0