[PATCH 16/21] meson: separate host-specific checks from option validation

Paolo Bonzini posted 21 patches 11 months, 1 week ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Thomas Huth <thuth@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Raphael Norwitz <raphael.norwitz@nutanix.com>, Gerd Hoffmann <kraxel@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Greg Kurz <groug@kaod.org>, Christian Schoenebeck <qemu_oss@crudebyte.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Jonathan Cameron <jonathan.cameron@huawei.com>, Fan Ni <fan.ni@samsung.com>, Jason Wang <jasowang@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, Pavel Pisa <pisa@cmp.felk.cvut.cz>, Vikram Garhwal <fnu.vikram@xilinx.com>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>, Michael Roth <michael.roth@amd.com>, Konstantin Kostiuk <kkostiuk@redhat.com>, Fam Zheng <fam@euphon.net>, Peter Maydell <peter.maydell@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Laurent Vivier <lvivier@redhat.com>
[PATCH 16/21] meson: separate host-specific checks from option validation
Posted by Paolo Bonzini 11 months, 1 week ago
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build | 97 +++++++++++++++++++++++++++--------------------------
 1 file changed, 50 insertions(+), 47 deletions(-)

diff --git a/meson.build b/meson.build
index f7e7deeabdc..e777f507ce3 100644
--- a/meson.build
+++ b/meson.build
@@ -602,53 +602,6 @@ have_vhost_net_vdpa = have_vhost_vdpa and get_option('vhost_net').allowed()
 have_vhost_net_kernel = have_vhost_kernel and get_option('vhost_net').allowed()
 have_vhost_net = have_vhost_net_kernel or have_vhost_net_user or have_vhost_net_vdpa
 
-# Target-specific libraries and flags
-libm = cc.find_library('m', required: false)
-threads = dependency('threads')
-util = cc.find_library('util', required: false)
-winmm = []
-socket = []
-version_res = []
-coref = []
-iokit = []
-emulator_link_args = []
-nvmm =not_found
-hvf = not_found
-midl = not_found
-widl = not_found
-pathcch = not_found
-host_dsosuf = '.so'
-if targetos == 'windows'
-  midl = find_program('midl', required: false)
-  widl = find_program('widl', required: false)
-  pathcch = cc.find_library('pathcch')
-  socket = cc.find_library('ws2_32')
-  winmm = cc.find_library('winmm')
-
-  win = import('windows')
-  version_res = win.compile_resources('version.rc',
-                                      depend_files: files('pc-bios/qemu-nsis.ico'),
-                                      include_directories: include_directories('.'))
-  host_dsosuf = '.dll'
-elif targetos == 'darwin'
-  coref = dependency('appleframeworks', modules: 'CoreFoundation')
-  iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
-  host_dsosuf = '.dylib'
-elif targetos == 'sunos'
-  socket = [cc.find_library('socket'),
-            cc.find_library('nsl'),
-            cc.find_library('resolv')]
-elif targetos == 'haiku'
-  socket = [cc.find_library('posix_error_mapper'),
-            cc.find_library('network'),
-            cc.find_library('bsd')]
-elif targetos == 'openbsd'
-  if get_option('tcg').allowed() and target_dirs.length() > 0
-    # Disable OpenBSD W^X if available
-    emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
-  endif
-endif
-
 # Target-specific configuration of accelerators
 accelerators = []
 if get_option('kvm').allowed() and targetos == 'linux'
@@ -716,6 +669,56 @@ if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
   error('WHPX not available on this platform')
 endif
 
+#####################################
+# Host-specific libraries and flags #
+#####################################
+
+libm = cc.find_library('m', required: false)
+threads = dependency('threads')
+util = cc.find_library('util', required: false)
+winmm = []
+socket = []
+version_res = []
+coref = []
+iokit = []
+emulator_link_args = []
+nvmm =not_found
+hvf = not_found
+midl = not_found
+widl = not_found
+pathcch = not_found
+host_dsosuf = '.so'
+if targetos == 'windows'
+  midl = find_program('midl', required: false)
+  widl = find_program('widl', required: false)
+  pathcch = cc.find_library('pathcch')
+  socket = cc.find_library('ws2_32')
+  winmm = cc.find_library('winmm')
+
+  win = import('windows')
+  version_res = win.compile_resources('version.rc',
+                                      depend_files: files('pc-bios/qemu-nsis.ico'),
+                                      include_directories: include_directories('.'))
+  host_dsosuf = '.dll'
+elif targetos == 'darwin'
+  coref = dependency('appleframeworks', modules: 'CoreFoundation')
+  iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
+  host_dsosuf = '.dylib'
+elif targetos == 'sunos'
+  socket = [cc.find_library('socket'),
+            cc.find_library('nsl'),
+            cc.find_library('resolv')]
+elif targetos == 'haiku'
+  socket = [cc.find_library('posix_error_mapper'),
+            cc.find_library('network'),
+            cc.find_library('bsd')]
+elif targetos == 'openbsd'
+  if get_option('tcg').allowed() and target_dirs.length() > 0
+    # Disable OpenBSD W^X if available
+    emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
+  endif
+endif
+
 ################
 # Dependencies #
 ################
-- 
2.43.0
Re: [PATCH 16/21] meson: separate host-specific checks from option validation
Posted by Philippe Mathieu-Daudé 11 months ago
On 21/12/23 18:19, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   meson.build | 97 +++++++++++++++++++++++++++--------------------------
>   1 file changed, 50 insertions(+), 47 deletions(-

[...]

> -elif targetos == 'openbsd'
> -  if get_option('tcg').allowed() and target_dirs.length() > 0
> -    # Disable OpenBSD W^X if available
> -    emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
> -  endif
> -endif
> -
>   # Target-specific configuration of accelerators
>   accelerators = []
>   if get_option('kvm').allowed() and targetos == 'linux'
> @@ -716,6 +669,56 @@ if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
>     error('WHPX not available on this platform')
>   endif

[*]

> +#####################################
> +# Host-specific libraries and flags #
> +#####################################
> +
> +libm = cc.find_library('m', required: false)
> +threads = dependency('threads')
> +util = cc.find_library('util', required: false)
> +winmm = []
> +socket = []
> +version_res = []
> +coref = []
> +iokit = []
> +emulator_link_args = []

This ...

> +nvmm =not_found
> +hvf = not_found

... could be moved at [*] with 'accelerators'.
(missing space around nvmm)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> +midl = not_found
> +widl = not_found
> +pathcch = not_found
> +host_dsosuf = '.so'
> +if targetos == 'windows'
> +  midl = find_program('midl', required: false)
> +  widl = find_program('widl', required: false)
> +  pathcch = cc.find_library('pathcch')
> +  socket = cc.find_library('ws2_32')
> +  winmm = cc.find_library('winmm')

[...]