[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/19] configure: move accelerator logic to meson
From: |
Paolo Bonzini |
Subject: |
[PULL 05/19] configure: move accelerator logic to meson |
Date: |
Mon, 5 Oct 2020 10:23:35 +0200 |
Move to meson the code to detect the presence of accelerators, and
to define accelerator-specific config-target.h symbols.
The logic for now is duplicated in configure because it is still
in use to build the list of targets (which is in turn used to
create the config-target.mak files). The next patches remove it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 19 ---------
meson.build | 109 ++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 94 insertions(+), 34 deletions(-)
diff --git a/configure b/configure
index 9dec87e186..9224ac47e6 100755
--- a/configure
+++ b/configure
@@ -6842,7 +6842,6 @@ if test "$optreset" = "yes" ; then
echo "HAVE_OPTRESET=y" >> $config_host_mak
fi
if test "$tcg" = "enabled"; then
- echo "CONFIG_TCG=y" >> $config_host_mak
if test "$tcg_interpreter" = "yes" ; then
echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
fi
@@ -7622,24 +7621,6 @@ if [ "$TARGET_SYSTBL_ABI" != "" ]; then
echo "TARGET_SYSTBL=$TARGET_SYSTBL" >> $config_target_mak
fi
-if supported_xen_target $target; then
- echo "CONFIG_XEN=y" >> $config_target_mak
- if test "$xen_pci_passthrough" = enabled; then
- echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
- fi
-fi
-if supported_kvm_target $target; then
- echo "CONFIG_KVM=y" >> $config_target_mak
-fi
-if supported_hax_target $target; then
- echo "CONFIG_HAX=y" >> $config_target_mak
-fi
-if supported_hvf_target $target; then
- echo "CONFIG_HVF=y" >> $config_target_mak
-fi
-if supported_whpx_target $target; then
- echo "CONFIG_WHPX=y" >> $config_target_mak
-fi
if test "$target_aligned_only" = "yes" ; then
echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak
fi
diff --git a/meson.build b/meson.build
index 41e5763e75..43ce1272b9 100644
--- a/meson.build
+++ b/meson.build
@@ -50,6 +50,28 @@ configure_file(input: files('scripts/ninjatool.py'),
output: 'ninjatool',
configuration: config_host)
+if cpu in ['x86', 'x86_64']
+ kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
+elif cpu == 'aarch64'
+ kvm_targets = ['aarch64-softmmu']
+elif cpu == 's390x'
+ kvm_targets = ['s390x-softmmu']
+elif cpu in ['ppc', 'ppc64']
+ kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
+else
+ kvm_targets = []
+endif
+
+accelerator_targets = { 'CONFIG_KVM': kvm_targets }
+if cpu in ['x86', 'x86_64']
+ accelerator_targets += {
+ 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
+ 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
+ 'CONFIG_HVF': ['x86_64-softmmu'],
+ 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
+ }
+endif
+
##################
# Compiler flags #
##################
@@ -103,7 +125,7 @@ version_res = []
coref = []
iokit = []
cocoa = not_found
-hvf = []
+hvf = not_found
if targetos == 'windows'
socket = cc.find_library('ws2_32')
winmm = cc.find_library('winmm')
@@ -116,7 +138,6 @@ elif targetos == 'darwin'
coref = dependency('appleframeworks', modules: 'CoreFoundation')
iokit = dependency('appleframeworks', modules: 'IOKit')
cocoa = dependency('appleframeworks', modules: 'Cocoa', required:
get_option('cocoa'))
- hvf = dependency('appleframeworks', modules: 'Hypervisor')
elif targetos == 'sunos'
socket = [cc.find_library('socket'),
cc.find_library('nsl'),
@@ -127,6 +148,64 @@ elif targetos == 'haiku'
cc.find_library('bsd')]
endif
+accelerators = []
+if not get_option('kvm').disabled() and targetos == 'linux'
+ accelerators += 'CONFIG_KVM'
+endif
+if not get_option('xen').disabled() and 'CONFIG_XEN_BACKEND' in config_host
+ accelerators += 'CONFIG_XEN'
+ have_xen_pci_passthrough = not get_option('xen_pci_passthrough').disabled()
and targetos == 'linux'
+else
+ have_xen_pci_passthrough = false
+endif
+if not get_option('whpx').disabled() and targetos == 'windows'
+ if get_option('whpx').enabled() and cpu != 'x86_64'
+ error('WHPX requires 64-bit host')
+ elif cc.has_header('WinHvPlatform.h', required: get_option('whpx')) and \
+ cc.has_header('WinHvEmulation.h', required: get_option('whpx'))
+ accelerators += 'CONFIG_WHPX'
+ endif
+endif
+if not get_option('hvf').disabled()
+ hvf = dependency('appleframeworks', modules: 'Hypervisor',
+ required: get_option('hvf'))
+ if hvf.found()
+ accelerators += 'CONFIG_HVF'
+ endif
+endif
+if not get_option('hax').disabled()
+ if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
+ accelerators += 'CONFIG_HAX'
+ endif
+endif
+if not get_option('tcg').disabled()
+ if cpu not in supported_cpus
+ if 'CONFIG_TCG_INTERPRETER' in config_host
+ warning('Unsupported CPU @0@, will use TCG with TCI
(experimental)'.format(cpu))
+ else
+ error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
+ endif
+ endif
+ accelerators += 'CONFIG_TCG'
+ config_host += { 'CONFIG_TCG': 'y' }
+endif
+
+if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
+ error('KVM not available on this platform')
+endif
+if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
+ error('HVF not available on this platform')
+endif
+if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
+ error('WHPX not available on this platform')
+endif
+if not have_xen_pci_passthrough and get_option('xen_pci_passthrough').enabled()
+ if 'CONFIG_XEN' in accelerators
+ error('Xen PCI passthrough not available on this platform')
+ else
+ error('Xen PCI passthrough requested but Xen not enabled')
+ endif
+endif
if not cocoa.found() and get_option('cocoa').enabled()
error('Cocoa not available on this platform')
endif
@@ -641,17 +720,22 @@ kconfig_external_symbols = [
]
ignored = ['TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_DIRS']
-accel_symbols = [
- 'CONFIG_KVM',
- 'CONFIG_HAX',
- 'CONFIG_HVF',
- 'CONFIG_TCG',
- 'CONFIG_WHPX'
-]
-
foreach target : target_dirs
config_target = keyval.load(meson.current_build_dir() / target /
'config-target.mak')
+ have_accel = false
+ foreach sym: accelerators
+ if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
+ config_target += { sym: 'y' }
+ config_all += { sym: 'y' }
+ if sym == 'CONFIG_XEN' and have_xen_pci_passthrough
+ config_target += { 'CONFIG_XEN_PCI_PASSTHROUGH': 'y' }
+ endif
+ have_accel = true
+ endif
+ endforeach
+ assert(have_accel)
+
foreach k, v: disassemblers
if config_host['ARCH'].startswith(k) or
config_target['TARGET_BASE_ARCH'].startswith(k)
foreach sym: v
@@ -677,11 +761,6 @@ foreach target : target_dirs
config_target_data.set(k, v)
endif
endforeach
- foreach sym: accel_symbols
- if config_target.has_key(sym)
- config_all += { sym: 'y' }
- endif
- endforeach
config_target_h += {target: configure_file(output: target +
'-config-target.h',
configuration:
config_target_data)}
--
2.26.2
- [PULL 00/19] Build system + MCE patches for 2020-10-05, Paolo Bonzini, 2020/10/05
- [PULL 01/19] travis: remove TCI test, Paolo Bonzini, 2020/10/05
- [PULL 02/19] default-configs: move files to default-configs/devices/, Paolo Bonzini, 2020/10/05
- [PULL 07/19] configure: compute derivatives of target name in meson, Paolo Bonzini, 2020/10/05
- [PULL 04/19] configure: rewrite accelerator defaults as tests, Paolo Bonzini, 2020/10/05
- [PULL 03/19] configure: convert accelerator variables to meson options, Paolo Bonzini, 2020/10/05
- [PULL 06/19] configure: remove dead variable, Paolo Bonzini, 2020/10/05
- [PULL 08/19] configure: remove useless config-target.mak symbols, Paolo Bonzini, 2020/10/05
- [PULL 05/19] configure: move accelerator logic to meson,
Paolo Bonzini <=
- [PULL 11/19] configure: move OpenBSD W^X test to meson, Paolo Bonzini, 2020/10/05
- [PULL 12/19] default-configs: use TARGET_ARCH key, Paolo Bonzini, 2020/10/05
- [PULL 10/19] default-configs: remove default-configs/devices for user-mode targets, Paolo Bonzini, 2020/10/05
- [PULL 13/19] default-configs: remove redundant keys, Paolo Bonzini, 2020/10/05
- [PULL 15/19] target-i386: seperate MCIP & MCE_MASK error reason, Paolo Bonzini, 2020/10/05
- [PULL 16/19] qapi/run-state.json: introduce memory failure event, Paolo Bonzini, 2020/10/05
- [PULL 09/19] configure: remove target configuration, Paolo Bonzini, 2020/10/05
- [PULL 19/19] dockerfiles: add diffutils to Fedora, Paolo Bonzini, 2020/10/05
- [PULL 14/19] meson: move sparse detection to Meson and rewrite check_sparse.py, Paolo Bonzini, 2020/10/05
- [PULL 17/19] target-i386: post memory failure event to QMP, Paolo Bonzini, 2020/10/05