util/util/cpuinfo-riscv.c: fix riscv64 build on musl libc
PATCH 1/1 util/util/cpuinfo-riscv.c: fix riscv64 build on musl libc
build fails on musl libc (alpine linux) with this error:
../util/cpuinfo-riscv.c: In function 'cpuinfo_init':../util/cpuinfo-riscv.c:63:21: error: '__NR_riscv_hwprobe' undeclared (first use in this function); did you mean 'riscv_hwprobe'?
63 | if (syscall(__NR_riscv_hwprobe, &pair, 1, 0, NULL, 0) == 0
| ^~~~~~~~~~~~~~~~~~
| riscv_hwprobe../util/cpuinfo-riscv.c:63:21: note: each undeclared identifier is reported only once for each function it appears in
ninja: subcommand failed
add '#include "asm/unistd.h"' to util/cpuinfo-riscv.c fixes build
--- util/cpuinfo-riscv.c | 1 + 1 file changed, 1 insertion(+)
util/cpuinfo-riscv.c +1 -0
@@ -5,6 +5,7 @@#include "qemu/osdep.h" #include "host/cpuinfo.h" +#include "asm/unistd.h" #ifdef CONFIG_ASM_HWPROBE_H #include <asm/hwprobe.h>
Signature · 1 line
2.46.0
Quoted 23 lines · Milan P. Stanić
build fails on musl libc (alpine linux) with this error:
../util/cpuinfo-riscv.c: In function 'cpuinfo_init':../util/cpuinfo-riscv.c:63:21: error: '__NR_riscv_hwprobe' undeclared (first use in this function); did you mean 'riscv_hwprobe'?63 | if (syscall(__NR_riscv_hwprobe, &pair, 1, 0, NULL, 0) == 0 | ^~~~~~~~~~~~~~~~~~ | riscv_hwprobe
../util/cpuinfo-riscv.c:63:21: note: each undeclared identifier is reported only once for each function it appears in
ninja: subcommand failedadd '#include "
asm/unistd.h"' toutil/cpuinfo-riscv.cfixes buildSigned-off-by Milan P. Stanić <[email protected]>--- util/cpuinfo-riscv.c | 1 + 1 file changed, 1 insertion(+)util/cpuinfo-riscv.c +0
-0
util/cpuinfo-riscv.c
Quoted 8 lines
util/cpuinfo-riscv.c +1
-1@@ -5,6 +5,7 @@#include "qemu/osdep.h" #include "host/cpuinfo.h" +#include "asm/unistd.h" #ifdef CONFIG_ASM_HWPROBE_H #include <asm/hwprobe.h> --
Hi; thanks for this patch. I think the new include line should go inside the #ifdef CONFIG_ASM_HWPROBE_H block you can see in the patch here, because the __NR_riscv_hwprobe symbol we want from it is only used by code that's guarded by that ifdef. (Otherwise we'll probably fail to compile on non-Linux hosts.)
System header includes should also use <...>, not "...".
thanks
-- PMM
Hi,
Quoted 39 lines · Peter Maydell
Quoted 23 lines · Milan P. Stanić
build fails on musl libc (alpine linux) with this error:
../util/cpuinfo-riscv.c: In function 'cpuinfo_init':../util/cpuinfo-riscv.c:63:21: error: '__NR_riscv_hwprobe' undeclared (first use in this function); did you mean 'riscv_hwprobe'?63 | if (syscall(__NR_riscv_hwprobe, &pair, 1, 0, NULL, 0) == 0 | ^~~~~~~~~~~~~~~~~~ | riscv_hwprobe
../util/cpuinfo-riscv.c:63:21: note: each undeclared identifier is reported only once for each function it appears in
ninja: subcommand failedadd '#include "
asm/unistd.h"' toutil/cpuinfo-riscv.cfixes buildSigned-off-by Milan P. Stanić <[email protected]>--- util/cpuinfo-riscv.c | 1 + 1 file changed, 1 insertion(+)util/cpuinfo-riscv.c +0
-0util/cpuinfo-riscv.c
Quoted 8 lines
util/cpuinfo-riscv.c +1
-1@@ -5,6 +5,7 @@#include "qemu/osdep.h" #include "host/cpuinfo.h" +#include "asm/unistd.h" #ifdef CONFIG_ASM_HWPROBE_H #include <asm/hwprobe.h> --Hi; thanks for this patch. I think the new include line should go inside the #ifdef
CONFIG_ASM_HWPROBE_Hblock you can see in the patch here, because the__NR_riscv_hwprobesymbol we want from it is only used by code that's guarded by that ifdef. (Otherwise we'll probably fail to compile on non-Linux hosts.)
Quoted 1 line
System header includes should also use <...>, not "...".
Right. Will send patch v2 soon.
Thanks for help
Signature · 1 line
Kind regards
Quoted 2 lines
thanks
-- PMM