buildsys: Fix Solaris build
cover buildsys: Fix Solaris build
Unfortunately Solaris OS is not tested in our CI, so it bit-rotted. Fortunately the fixes are easy.
Philippe Mathieu-Daudé (3):
qga/commands: Include proper Solaris header for getloadavg() migration/rdma: Check ntohll() availability with meson target/arm/tcg: Undefine Solaris FSCALE definition as a kludge
meson.build | 4 ++++ migration/rdma.c | 4 +--- qga/commands-posix.c | 3 +++ target/arm/tcg/translate-sve.c | 3 +++ 4 files changed, 11 insertions(+), 3 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/3 qga/commands: Include proper Solaris header for getloadavg()
Solaris declares getloadavg() in <sys/loadavg.h>:
getloadavg(3C) Standard C Library Functions getloadavg(3C)
NAME
getloadavg - get system load averages
SYNOPSIS
#include <sys/loadavg.h>
int getloadavg(double loadavg[], int nelem);
[...]
Oracle Solaris 11.4 23 Jul 2020 getloadavg(3C)
Include it in order to avoid:
../qga/commands-posix.c: In function 'qmp_guest_get_load':
../qga/commands-posix.c:1408:9: error: implicit declaration of function 'getloadavg' [-Wimplicit-function-declaration]
1408 | if (getloadavg(loadavg, G_N_ELEMENTS(loadavg)) < 0) {
| ^~~~~~~~~~ ../qga/commands-posix.c:1408:9: warning: nested extern declaration of 'getloadavg' [-Wnested-externs]
../configure relevant output:
C compiler for the host machine: gcc (gcc 14.2.0 "gcc (GCC) 14.2.0") C linker for the host machine: gcc ld.solaris 5.11-1.3315
--- qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+)
qga/commands-posix.c +3 -0
@@ -43,6 +43,9 @@#include <net/ethernet.h> #endif #ifdef CONFIG_SOLARIS +#ifdef CONFIG_GETLOADAVG +#include <sys/loadavg.h> +#endif #include <sys/sockio.h> #endif #endif
Signature · 1 line
2.51.0
Re: [PATCH-for-10.2 1/3] qga/commands: Include proper Solaris header for getloadavg()
Quoted 54 lines · Philippe Mathieu-Daudé
Solaris declares
getloadavg()in <sys/loadavg.h>:getloadavg(3C) Standard C Library Functions getloadavg(3C)
NAME
getloadavg - get system load averagesSYNOPSIS
#include <sys/loadavg.h>int
getloadavg(double loadavg[], int nelem);[...]
Oracle Solaris 11.4 23 Jul 2020 getloadavg(3C)
Include it in order to avoid:
../qga/commands-posix.c: In function 'qmp_guest_get_load':
../qga/commands-posix.c:1408:9: error: implicit declaration of function
'getloadavg' [-Wimplicit-function-declaration]1408 | if (getloadavg(loadavg, G_N_ELEMENTS(loadavg)) < 0) { | ^~~~~~~~~~
../qga/commands-posix.c:1408:9: warning: nested extern declaration of
'getloadavg' [-Wnested-externs]../configure relevant output:
C compiler for the host machine: gcc (gcc 14.2.0 "gcc (GCC) 14.2.0") C linker for the host machine: gcc ld.solaris 5.11-1.3315
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+)qga/commands-posix.c +3
-1@@ -43,6 +43,9 @@#include <net/ethernet.h> #endif #ifdef CONFIG_SOLARIS +#ifdef CONFIG_GETLOADAVG +#include <sys/loadavg.h> +#endif #include <sys/sockio.h> #endif #endif --2.51.0
Re: [PATCH-for-10.2 1/3] qga/commands: Include proper Solaris header for getloadavg()
In reply to Philippe Mathieu-DaudéQuoted 26 lines · Philippe Mathieu-Daudé
Solaris declares
getloadavg()in <sys/loadavg.h>:getloadavg(3C) Standard C Library Functions getloadavg(3C)
NAME
getloadavg - get system load averagesSYNOPSIS
#include <sys/loadavg.h>int
getloadavg(double loadavg[], int nelem);[...]
Oracle Solaris 11.4 23 Jul 2020 getloadavg(3C)
Include it in order to avoid:
../qga/commands-posix.c: In function 'qmp_guest_get_load':
../qga/commands-posix.c:1408:9: error: implicit declaration of function 'getloadavg' [-Wimplicit-function-declaration]1408 | if (getloadavg(loadavg, G_N_ELEMENTS(loadavg)) < 0) { | ^~~~~~~~~~
../qga/commands-posix.c:1408:9: warning: nested extern declaration of 'getloadavg' [-Wnested-externs]../configure relevant output:
Quoted 7 lines
C compiler for the host machine: gcc (gcc 14.2.0 "gcc (GCC) 14.2.0") C linker for the host machine: gcc ld.solaris 5.11-1.3315
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+)
r~
Quoted 15 lines
qga/commands-posix.c +3
-0@@ -43,6 +43,9 @@#include <net/ethernet.h> #endif #ifdef CONFIG_SOLARIS +#ifdef CONFIG_GETLOADAVG +#include <sys/loadavg.h> +#endif #include <sys/sockio.h> #endif #endif
PATCH 2/3 migration/rdma: Check ntohll() availability with meson
In reply to Philippe Mathieu-DaudéCommit 44ce1b5d2fc ("migration/rdma: define htonll/ntohll only if not predefined") tried to only include htonll/ntohll replacements when their symbol is *defined*, but this doesn't work, as they aren't:
../migration/rdma.c:242:17: error: static declaration of 'htonll' follows non-static declaration
242 | static uint64_t htonll(uint64_t v)
| ^~~~~~
In file included from /usr/include/netinet/in.h:73,
from /usr/include/sys/socket.h:32,
from /home/f4bug/qemu/include/system/os-posix.h:30,
from /home/f4bug/qemu/include/qemu/osdep.h:176,
from ../migration/rdma.c:17:
/usr/include/sys/byteorder.h:75:18: note: previous declaration of 'htonll' with type 'uint64_t(uint64_t)' {aka 'long unsigned int(long unsigned int)'}
75 | extern uint64_t htonll(uint64_t);
| ^~~~~~
../migration/rdma.c:252:17: error: static declaration of 'ntohll' follows non-static declaration
252 | static uint64_t ntohll(uint64_t v)
| ^~~~~~
/usr/include/sys/byteorder.h:76:18: note: previous declaration of 'ntohll' with type 'uint64_t(uint64_t)' {aka 'long unsigned int(long unsigned int)'}
76 | extern uint64_t ntohll(uint64_t);
| ^~~~~~Better to check the symbol availability with meson.
--- meson.build | 1 + migration/rdma.c | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-)
meson.build +1 -0
@@ -2663,6 +2663,7 @@ config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs')) config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range')) config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create')) config_host_data.set('CONFIG_GETLOADAVG', cc.has_function('getloadavg')) +config_host_data.set('CONFIG_ARPA_INET_64', cc.has_function('htonll')) config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range')) config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs')) config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice)
migration/rdma.c +1 -3
@@ -238,7 +238,7 @@ static const char *control_desc(unsigned int rdma_control)return strs[rdma_control]; } -#if !defined(htonll) +#if !defined(CONFIG_ARPA_INET_64 )static uint64_t htonll (uint64_t v) {union {uint32_t lv[2 ];uint64_t llv; } u;
@@ -246,9 +246,7 @@ static uint64_t htonll(uint64_t v) u.lv[1 ] =htonl (v &0xFFFFFFFFULL );return u.llv; } -#endif -#if !defined(ntohll)static uint64_t ntohll (uint64_t v) {union {uint32_t lv[2 ];uint64_t llv; } u;
Signature · 1 line
2.51.0
Re: [PATCH-for-10.2 2/3] migration/rdma: Check ntohll() availability with meson
Quoted 23 lines · Philippe Mathieu-Daudé
Commit
44ce1b5d2fc("migration/rdma: define htonll/ntohll only if not predefined") tried to only include htonll/ntohll replacements when their symbol is *defined*, but this doesn't work, as they aren't:
../migration/rdma.c:242:17: error: static declaration of 'htonll' follows non-static declaration242 | static uint64_t htonll(uint64_t v) | ^~~~~~ In file included from /usr/include/netinet/in.h:73, from /usr/include/sys/socket.h:32, from /home/f4bug/qemu/include/system/os-posix.h:30, from /home/f4bug/qemu/include/qemu/osdep.h:176, from ../migration/rdma.c:17: /usr/include/sys/byteorder.h:75:18: note: previous declaration of 'htonll' with type 'uint64_t(uint64_t)' {aka 'long unsigned int(long unsigned int)'} 75 | extern uint64_t htonll(uint64_t); | ^~~~~~ ../migration/rdma.c:252:17: error: static declaration of 'ntohll' follows non-static declaration 252 | static uint64_t ntohll(uint64_t v) | ^~~~~~ /usr/include/sys/byteorder.h:76:18: note: previous declaration of 'ntohll' with type 'uint64_t(uint64_t)' {aka 'long unsigned int(long unsigned int)'} 76 | extern uint64_t ntohll(uint64_t); | ^~~~~~
Quoted 3 lines
Better to check the symbol availability with meson.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Signature · 1 line
Peter Xu
Re: [PATCH-for-10.2 2/3] migration/rdma: Check ntohll() availability with meson
In reply to Philippe Mathieu-DaudéQuoted 36 lines · Philippe Mathieu-Daudé
Commit
44ce1b5d2fc("migration/rdma: define htonll/ntohll only if not predefined") tried to only include htonll/ntohll replacements when their symbol is *defined*, but this doesn't work, as they aren't:../migration/rdma.c:242:17: error: static declaration of 'htonll' follows non-static declaration 242 | static uint64_t htonll(uint64_t v) | ^~~~~~ In file included from /usr/include/netinet/in.h:73, from /usr/include/sys/socket.h:32, from /home/f4bug/qemu/include/system/os-posix.h:30, from /home/f4bug/qemu/include/qemu/osdep.h:176, from ../migration/rdma.c:17: /usr/include/sys/byteorder.h:75:18: note: previous declaration of 'htonll' with type 'uint64_t(uint64_t)' {aka 'long unsigned int(long unsigned int)'} 75 | extern uint64_t htonll(uint64_t); | ^~~~~~ ../migration/rdma.c:252:17: error: static declaration of 'ntohll' follows non-static declaration 252 | static uint64_t ntohll(uint64_t v) | ^~~~~~ /usr/include/sys/byteorder.h:76:18: note: previous declaration of 'ntohll' with type 'uint64_t(uint64_t)' {aka 'long unsigned int(long unsigned int)'} 76 | extern uint64_t ntohll(uint64_t); | ^~~~~~Better to check the symbol availability with meson.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- meson.build | 1 + migration/rdma.c | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-)meson.build +0
-0
meson.build config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs')) · line 2669
Quoted 7 lines
meson.build +1
-0@@ -2663,6 +2663,7 @@ config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs')) config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range')) config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create')) config_host_data.set('CONFIG_GETLOADAVG', cc.has_function('getloadavg')) +config_host_data.set('CONFIG_ARPA_INET_64', cc.has_function('htonll')) config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range')) config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs')) config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice)
Should we bother with htonl{,l} at all, when we have <qemu/bswap.h>?
That said, this is the minimal patch for 10.2, so
r~
PATCH 3/3 target/arm/tcg: Undefine Solaris FSCALE definition as a kludge
In reply to Philippe Mathieu-Daudé CONFIG_SOLARIS_FSCALE
Solaris defines FSCALE in <sys/param.h>:
301 /*
302 * Scale factor for scaled integers used to count 303 * %cpu time and load averages. 304 */
305 #define FSHIFT 8 /* bits to right of fixed binary point */
306 #define FSCALE (1<<FSHIFT)
When emulating the SVE FSCALE instruction, we defines the same name in decodetree format in target/arm/tcg/sve.decode:
1129:FSCALE 01100101 .. 00 1001 100 ... ..... ..... @rdn_pg_rm
This leads to a definition clash:
In file included from ../target/arm/tcg/translate-sve.c:21:
../target/arm/tcg/translate.h:875:17: error: pasting "trans_" and "(" does not give a valid preprocessing token
875 | static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
| ^~~~~~
../target/arm/tcg/translate-sve.c:4205:5: note: in expansion of macro 'TRANS_FEAT'
4205 | TRANS_FEAT(NAME, FEAT, gen_gvec_fpst_arg_zpzz, name##_zpzz_fns[a->esz], a)
| ^~~~~~~~~~
../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP'
4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
| ^~~~~~~~~~
../target/arm/tcg/translate-sve.c:4249:12: error: expected declaration specifiers or '...' before numeric constant
4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
| ^~~~~~
../target/arm/tcg/translate.h:875:25: note: in definition of macro 'TRANS_FEAT'
875 | static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
| ^~~~
../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP'
4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
| ^~~~~~~~~~
../target/arm/tcg/translate.h:875:47: error: pasting "arg_" and "(" does not give a valid preprocessing token
875 | static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
| ^~~~
../target/arm/tcg/translate-sve.c:4205:5: note: in expansion of macro 'TRANS_FEAT'
4205 | TRANS_FEAT(NAME, FEAT, gen_gvec_fpst_arg_zpzz, name##_zpzz_fns[a->esz], a)
| ^~~~~~~~~~
../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP'
4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
| ^~~~~~~~~~
In file included from ../target/arm/tcg/translate-sve.c:100:
libqemu-aarch64-softmmu.a.p/decode-sve.c.inc:1227:13: warning: 'trans_FSCALE' used but never defined
1227 | static bool trans_FSCALE(DisasContext *ctx, arg_FSCALE *a);
| ^~~~~~~~~~~~
../target/arm/tcg/translate-sve.c:4249:30: warning: 'sve_fscalbn_zpzz_fns' defined but not used [-Wunused-const-variable=]
4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn)
| ^~~~~~~~~~~ ../target/arm/tcg/translate-sve.c:4201:42: note: in definition of macro 'DO_ZPZZ_FP'
4201 | static gen_helper_gvec_4_ptr * const name##_zpzz_fns[4] = { \
| ^~~~
As a kludge, check the definition existence with meson, then undefine it locally in target/arm/tcg/translate-sve.c file.
--- meson.build | 3 +++ target/arm/tcg/translate-sve.c | 3 +++ 2 files changed, 6 insertions(+)
meson.build +3 -0
@@ -2779,6 +2779,9 @@ config_host_data.set('HAVE_TCP_KEEPINTVL', #endif int main(void) { return 0; }''', name: 'Win32 TCP_KEEPINTVL')) +if host_os == 'sunos' + config_host_data.set('CONFIG_SOLARIS_FSCALE', cc.has_header_symbol('sys/param.h', 'FSCALE')) +endif # has_member config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
target/arm/tcg/translate-sve.c +3 -0
@@ -4246,6 +4246,9 @@ DO_ZPZZ_AH_FP_B16(FMAX_zpzz, aa64_sve, sve_fmax, sve_ah_fmax) DO_ZPZZ_FP_B16(FMINNM_zpzz, aa64_sve, sve_fminnum) DO_ZPZZ_FP_B16(FMAXNM_zpzz, aa64_sve, sve_fmaxnum) DO_ZPZZ_AH_FP(FABD, aa64_sve, sve_fabd, sve_ah_fabd) +#ifdef CONFIG_SOLARIS_FSCALE +#undef FSCALE/* Kludge for Solaris which defines FSCALE in <sys/param.h> */ +#endif DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn) DO_ZPZZ_FP(FDIV, aa64_sve, sve_fdiv)DO_ZPZZ_FP (FMULX , aa64_sve, sve_fmulx)
Signature · 1 line
2.51.0
Re: [PATCH-for-10.2 3/3] target/arm/tcg: Undefine Solaris FSCALE definition as a kludge
Quoted 85 lines · Philippe Mathieu-Daudé
CONFIG_SOLARIS_FSCALESolaris defines FSCALE in <
sys/param.h>:301 /*
302 * Scale factor for scaled integers used to count 303 * %cpu time and load averages. 304 */305 #define FSHIFT 8 /* bits to right of fixed binary point */
306 #define FSCALE (1<<FSHIFT)When emulating the SVE FSCALE instruction, we defines the same name in decodetree format in target/arm/tcg/sve.decode:
1129:FSCALE 01100101 .. 00 1001 100 ... ..... ..... @rdn_pg_rmThis leads to a definition clash:
In file included from ../target/arm/tcg/translate-sve.c:21: ../target/arm/tcg/translate.h:875:17: error: pasting "trans_" and "(" does not give a valid preprocessing token 875 | static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \ | ^~~~~~ ../target/arm/tcg/translate-sve.c:4205:5: note: in expansion of macro 'TRANS_FEAT' 4205 | TRANS_FEAT(NAME, FEAT, gen_gvec_fpst_arg_zpzz, name##_zpzz_fns[a->esz], a) | ^~~~~~~~~~ ../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP' 4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn) | ^~~~~~~~~~ ../target/arm/tcg/translate-sve.c:4249:12: error: expected declaration specifiers or '...' before numeric constant 4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn) | ^~~~~~ ../target/arm/tcg/translate.h:875:25: note: in definition of macro 'TRANS_FEAT' 875 | static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \ | ^~~~ ../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP' 4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn) | ^~~~~~~~~~ ../target/arm/tcg/translate.h:875:47: error: pasting "arg_" and "(" does not give a valid preprocessing token 875 | static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \ | ^~~~ ../target/arm/tcg/translate-sve.c:4205:5: note: in expansion of macro 'TRANS_FEAT' 4205 | TRANS_FEAT(NAME, FEAT, gen_gvec_fpst_arg_zpzz, name##_zpzz_fns[a->esz], a) | ^~~~~~~~~~ ../target/arm/tcg/translate-sve.c:4249:1: note: in expansion of macro 'DO_ZPZZ_FP' 4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn) | ^~~~~~~~~~ In file included from ../target/arm/tcg/translate-sve.c:100: libqemu-aarch64-softmmu.a.p/decode-sve.c.inc:1227:13: warning: 'trans_FSCALE' used but never defined 1227 | static bool trans_FSCALE(DisasContext *ctx, arg_FSCALE *a); | ^~~~~~~~~~~~ ../target/arm/tcg/translate-sve.c:4249:30: warning: 'sve_fscalbn_zpzz_fns' defined but not used [-Wunused-const-variable=] 4249 | DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn) | ^~~~~~~~~~~ ../target/arm/tcg/translate-sve.c:4201:42: note: in definition of macro 'DO_ZPZZ_FP' 4201 | static gen_helper_gvec_4_ptr * const name##_zpzz_fns[4] = { \ | ^~~~As a kludge, check the definition existence with meson, then undefine it locally in
target/arm/tcg/translate-sve.cfile.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- meson.build | 3 +++ target/arm/tcg/translate-sve.c | 3 +++ 2 files changed, 6 insertions(+)meson.build +3
-0@@ -2779,6 +2779,9 @@ config_host_data.set('HAVE_TCP_KEEPINTVL', #endif int main(void) { return 0; }''', name: 'Win32 TCP_KEEPINTVL')) +if host_os == 'sunos' + config_host_data.set('CONFIG_SOLARIS_FSCALE', cc.has_header_symbol('sys/param.h', 'FSCALE')) +endif # has_member config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',target/arm/tcg/translate-sve.c +0
-0
target/arm/tcg/translate-sve.c DO_ZPZZ_AH_FP_B16(FMAX_zpzz, aa64_sve, sve_fmax, sve_ah_fmax) · line 4254
Quoted 9 lines
target/arm/tcg/translate-sve.c +3
-0@@ -4246,6 +4246,9 @@ DO_ZPZZ_AH_FP_B16(FMAX_zpzz, aa64_sve, sve_fmax, sve_ah_fmax) DO_ZPZZ_FP_B16(FMINNM_zpzz, aa64_sve, sve_fminnum) DO_ZPZZ_FP_B16(FMAXNM_zpzz, aa64_sve, sve_fmaxnum) DO_ZPZZ_AH_FP(FABD, aa64_sve, sve_fabd, sve_ah_fabd) +#ifdef CONFIG_SOLARIS_FSCALE +#undef FSCALE/* Kludge for Solaris which defines FSCALE in <sys/param.h> */ +#endif DO_ZPZZ_FP(FSCALE, aa64_sve, sve_fscalbn) DO_ZPZZ_FP(FDIV, aa64_sve, sve_fdiv)DO_ZPZZ_FP (FMULX , aa64_sve, sve_fmulx)
You don't need an ifdef for undef, just undef it.
r~