Paolo Bonzini | 07f0d32 | 2024-10-03 16:28:43 +0300 | [diff] [blame] | 1 | project('qemu', ['c'], meson_version: '>=1.5.0', |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 2 | default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto', |
Paolo Bonzini | 0a31e3a | 2022-04-20 17:33:59 +0200 | [diff] [blame] | 3 | 'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true'], |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 4 | version: files('VERSION')) |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 5 | |
Thomas Huth | e287072 | 2022-03-10 08:50:48 +0100 | [diff] [blame] | 6 | add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true) |
| 7 | add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow']) |
| 8 | add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough']) |
Paolo Bonzini | 3d2f73e | 2021-02-11 06:15:12 -0500 | [diff] [blame] | 9 | |
Akihiko Odaki | cf60ccc | 2022-06-24 23:50:37 +0900 | [diff] [blame] | 10 | meson.add_postconf_script(find_program('scripts/symlink-install-tree.py')) |
| 11 | |
Paolo Bonzini | ea444d9 | 2023-09-08 12:06:12 +0200 | [diff] [blame] | 12 | #################### |
| 13 | # Global variables # |
| 14 | #################### |
| 15 | |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 16 | not_found = dependency('', required: false) |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 17 | keyval = import('keyval') |
Paolo Bonzini | be3fc97 | 2024-10-15 10:08:57 +0200 | [diff] [blame] | 18 | rust = import('rust') |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 19 | ss = import('sourceset') |
Richard Henderson | 8b18cdb | 2020-09-13 12:19:25 -0700 | [diff] [blame] | 20 | fs = import('fs') |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 21 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 22 | host_os = host_machine.system() |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 23 | config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') |
Paolo Bonzini | d7dedf4 | 2021-01-26 11:15:33 +0100 | [diff] [blame] | 24 | |
Yonggang Luo | e366766 | 2020-10-16 06:06:25 +0800 | [diff] [blame] | 25 | # Temporary directory used for files created while |
| 26 | # configure runs. Since it is in the build directory |
| 27 | # we can safely blow away any previous version of it |
| 28 | # (and we need not jump through hoops to try to delete |
| 29 | # it when configure exits.) |
| 30 | tmpdir = meson.current_build_dir() / 'meson-private/temp' |
Marc-André Lureau | 8fe1123 | 2020-09-11 14:42:48 +0200 | [diff] [blame] | 31 | |
| 32 | if get_option('qemu_suffix').startswith('/') |
| 33 | error('qemu_suffix cannot start with a /') |
| 34 | endif |
| 35 | |
Paolo Bonzini | 16bf7a3 | 2020-10-16 03:19:14 -0400 | [diff] [blame] | 36 | qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix') |
Marc-André Lureau | ab4c099 | 2020-08-26 15:04:16 +0400 | [diff] [blame] | 37 | qemu_datadir = get_option('datadir') / get_option('qemu_suffix') |
Marc-André Lureau | 491e74c | 2020-08-26 15:04:17 +0400 | [diff] [blame] | 38 | qemu_docdir = get_option('docdir') / get_option('qemu_suffix') |
Paolo Bonzini | 16bf7a3 | 2020-10-16 03:19:14 -0400 | [diff] [blame] | 39 | qemu_moddir = get_option('libdir') / get_option('qemu_suffix') |
| 40 | |
| 41 | qemu_desktopdir = get_option('datadir') / 'applications' |
| 42 | qemu_icondir = get_option('datadir') / 'icons' |
| 43 | |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 44 | genh = [] |
Vladimir Sementsov-Ogievskiy | b83a80e | 2022-01-26 17:11:27 +0100 | [diff] [blame] | 45 | qapi_trace_events = [] |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 46 | |
Paolo Bonzini | 20cf5cb | 2021-10-15 16:47:43 +0200 | [diff] [blame] | 47 | bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin'] |
Paolo Bonzini | 201e8ed | 2020-09-01 07:45:54 -0400 | [diff] [blame] | 48 | supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux'] |
Philippe Mathieu-Daudé | 278c1bc | 2023-06-27 16:32:34 +0200 | [diff] [blame] | 49 | supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64', |
Richard Henderson | 6d0b52e | 2022-10-17 08:00:57 +0300 | [diff] [blame] | 50 | 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64'] |
Paolo Bonzini | 201e8ed | 2020-09-01 07:45:54 -0400 | [diff] [blame] | 51 | |
| 52 | cpu = host_machine.cpu_family() |
Richard Henderson | c94c239 | 2021-11-16 10:50:42 +0100 | [diff] [blame] | 53 | |
Paolo Bonzini | 20cf5cb | 2021-10-15 16:47:43 +0200 | [diff] [blame] | 54 | target_dirs = config_host['TARGET_DIRS'].split() |
Paolo Bonzini | 44458a6 | 2023-09-08 12:06:57 +0200 | [diff] [blame] | 55 | |
| 56 | ############ |
| 57 | # Programs # |
| 58 | ############ |
| 59 | |
| 60 | sh = find_program('sh') |
| 61 | python = import('python').find_installation() |
| 62 | |
| 63 | cc = meson.get_compiler('c') |
| 64 | all_languages = ['c'] |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 65 | if host_os == 'windows' and add_languages('cpp', required: false, native: false) |
Paolo Bonzini | 44458a6 | 2023-09-08 12:06:57 +0200 | [diff] [blame] | 66 | all_languages += ['cpp'] |
| 67 | cxx = meson.get_compiler('cpp') |
| 68 | endif |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 69 | if host_os == 'darwin' and \ |
Peter Maydell | 2ef938a | 2024-03-11 13:33:34 +0000 | [diff] [blame] | 70 | add_languages('objc', required: true, native: false) |
Paolo Bonzini | 44458a6 | 2023-09-08 12:06:57 +0200 | [diff] [blame] | 71 | all_languages += ['objc'] |
| 72 | objc = meson.get_compiler('objc') |
| 73 | endif |
Manos Pitsidianakis | 764a6ee | 2024-10-03 16:28:44 +0300 | [diff] [blame] | 74 | have_rust = false |
Paolo Bonzini | 95e82f9b | 2024-10-14 16:36:40 +0200 | [diff] [blame] | 75 | if not get_option('rust').disabled() and add_languages('rust', required: get_option('rust'), native: false) \ |
| 76 | and add_languages('rust', required: get_option('rust'), native: true) |
Manos Pitsidianakis | 764a6ee | 2024-10-03 16:28:44 +0300 | [diff] [blame] | 77 | rustc = meson.get_compiler('rust') |
| 78 | have_rust = true |
| 79 | if rustc.version().version_compare('<1.80.0') |
| 80 | if get_option('rust').enabled() |
| 81 | error('rustc version ' + rustc.version() + ' is unsupported: Please upgrade to at least 1.80.0') |
| 82 | else |
| 83 | warning('rustc version ' + rustc.version() + ' is unsupported: Disabling Rust compilation. Please upgrade to at least 1.80.0 to use Rust.') |
| 84 | have_rust = false |
| 85 | endif |
| 86 | endif |
| 87 | endif |
Paolo Bonzini | 44458a6 | 2023-09-08 12:06:57 +0200 | [diff] [blame] | 88 | |
| 89 | dtrace = not_found |
| 90 | stap = not_found |
| 91 | if 'dtrace' in get_option('trace_backends') |
| 92 | dtrace = find_program('dtrace', required: true) |
| 93 | stap = find_program('stap', required: false) |
| 94 | if stap.found() |
| 95 | # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol |
| 96 | # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility |
| 97 | # instead. QEMU --enable-modules depends on this because the SystemTap |
| 98 | # semaphores are linked into the main binary and not the module's shared |
| 99 | # object. |
| 100 | add_global_arguments('-DSTAP_SDT_V2', |
| 101 | native: false, language: all_languages) |
| 102 | endif |
| 103 | endif |
| 104 | |
| 105 | if get_option('iasl') == '' |
| 106 | iasl = find_program('iasl', required: false) |
| 107 | else |
| 108 | iasl = find_program(get_option('iasl'), required: true) |
| 109 | endif |
| 110 | |
Xianglai Li | b883fb9 | 2024-07-24 10:22:45 +0800 | [diff] [blame] | 111 | edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu', 'riscv64-softmmu', 'loongarch64-softmmu' ] |
Paolo Bonzini | 44458a6 | 2023-09-08 12:06:57 +0200 | [diff] [blame] | 112 | unpack_edk2_blobs = false |
| 113 | foreach target : edk2_targets |
| 114 | if target in target_dirs |
| 115 | bzip2 = find_program('bzip2', required: get_option('install_blobs')) |
| 116 | unpack_edk2_blobs = bzip2.found() |
| 117 | break |
| 118 | endif |
| 119 | endforeach |
| 120 | |
| 121 | ##################### |
| 122 | # Option validation # |
| 123 | ##################### |
| 124 | |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 125 | # Fuzzing |
| 126 | if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \ |
| 127 | not cc.links(''' |
| 128 | #include <stdint.h> |
| 129 | #include <sys/types.h> |
| 130 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); |
| 131 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; } |
| 132 | ''', |
| 133 | args: ['-Werror', '-fsanitize=fuzzer']) |
| 134 | error('Your compiler does not support -fsanitize=fuzzer') |
| 135 | endif |
| 136 | |
| 137 | # Tracing backends |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 138 | if 'ftrace' in get_option('trace_backends') and host_os != 'linux' |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 139 | error('ftrace is supported only on Linux') |
| 140 | endif |
| 141 | if 'syslog' in get_option('trace_backends') and not cc.compiles(''' |
| 142 | #include <syslog.h> |
| 143 | int main(void) { |
| 144 | openlog("qemu", LOG_PID, LOG_DAEMON); |
| 145 | syslog(LOG_INFO, "configure"); |
| 146 | return 0; |
| 147 | }''') |
| 148 | error('syslog is not supported on this system') |
| 149 | endif |
| 150 | |
| 151 | # Miscellaneous Linux-only features |
| 152 | get_option('mpath') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 153 | .require(host_os == 'linux', error_message: 'Multipath is supported only on Linux') |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 154 | |
| 155 | multiprocess_allowed = get_option('multiprocess') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 156 | .require(host_os == 'linux', error_message: 'Multiprocess QEMU is supported only on Linux') \ |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 157 | .allowed() |
| 158 | |
| 159 | vfio_user_server_allowed = get_option('vfio_user_server') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 160 | .require(host_os == 'linux', error_message: 'vfio-user server is supported only on Linux') \ |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 161 | .allowed() |
| 162 | |
| 163 | have_tpm = get_option('tpm') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 164 | .require(host_os != 'windows', error_message: 'TPM emulation only available on POSIX systems') \ |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 165 | .allowed() |
| 166 | |
| 167 | # vhost |
| 168 | have_vhost_user = get_option('vhost_user') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 169 | .disable_auto_if(host_os != 'linux') \ |
| 170 | .require(host_os != 'windows', |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 171 | error_message: 'vhost-user is not available on Windows').allowed() |
| 172 | have_vhost_vdpa = get_option('vhost_vdpa') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 173 | .require(host_os == 'linux', |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 174 | error_message: 'vhost-vdpa is only available on Linux').allowed() |
| 175 | have_vhost_kernel = get_option('vhost_kernel') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 176 | .require(host_os == 'linux', |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 177 | error_message: 'vhost-kernel is only available on Linux').allowed() |
| 178 | have_vhost_user_crypto = get_option('vhost_crypto') \ |
| 179 | .require(have_vhost_user, |
| 180 | error_message: 'vhost-crypto requires vhost-user to be enabled').allowed() |
| 181 | |
| 182 | have_vhost = have_vhost_user or have_vhost_vdpa or have_vhost_kernel |
| 183 | |
| 184 | have_vhost_net_user = have_vhost_user and get_option('vhost_net').allowed() |
| 185 | have_vhost_net_vdpa = have_vhost_vdpa and get_option('vhost_net').allowed() |
| 186 | have_vhost_net_kernel = have_vhost_kernel and get_option('vhost_net').allowed() |
| 187 | have_vhost_net = have_vhost_net_kernel or have_vhost_net_user or have_vhost_net_vdpa |
| 188 | |
| 189 | # type of binaries to build |
Paolo Bonzini | 20cf5cb | 2021-10-15 16:47:43 +0200 | [diff] [blame] | 190 | have_linux_user = false |
| 191 | have_bsd_user = false |
| 192 | have_system = false |
| 193 | foreach target : target_dirs |
| 194 | have_linux_user = have_linux_user or target.endswith('linux-user') |
| 195 | have_bsd_user = have_bsd_user or target.endswith('bsd-user') |
| 196 | have_system = have_system or target.endswith('-softmmu') |
| 197 | endforeach |
| 198 | have_user = have_linux_user or have_bsd_user |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 199 | |
Paolo Bonzini | 20cf5cb | 2021-10-15 16:47:43 +0200 | [diff] [blame] | 200 | have_tools = get_option('tools') \ |
| 201 | .disable_auto_if(not have_system) \ |
| 202 | .allowed() |
| 203 | have_ga = get_option('guest_agent') \ |
| 204 | .disable_auto_if(not have_system and not have_tools) \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 205 | .require(host_os in ['sunos', 'linux', 'windows', 'freebsd', 'netbsd', 'openbsd'], |
Paolo Bonzini | 20cf5cb | 2021-10-15 16:47:43 +0200 | [diff] [blame] | 206 | error_message: 'unsupported OS for QEMU guest agent') \ |
| 207 | .allowed() |
Paolo Bonzini | a9cba05 | 2023-12-30 18:42:30 +0100 | [diff] [blame] | 208 | have_block = have_system or have_tools |
| 209 | |
Paolo Bonzini | 6002711 | 2022-10-20 14:53:10 +0200 | [diff] [blame] | 210 | enable_modules = get_option('modules') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 211 | .require(host_os != 'windows', |
Paolo Bonzini | 6002711 | 2022-10-20 14:53:10 +0200 | [diff] [blame] | 212 | error_message: 'Modules are not available for Windows') \ |
| 213 | .require(not get_option('prefer_static'), |
| 214 | error_message: 'Modules are incompatible with static linking') \ |
| 215 | .allowed() |
Paolo Bonzini | 20cf5cb | 2021-10-15 16:47:43 +0200 | [diff] [blame] | 216 | |
Paolo Bonzini | ea444d9 | 2023-09-08 12:06:12 +0200 | [diff] [blame] | 217 | ####################################### |
| 218 | # Variables for host and accelerators # |
| 219 | ####################################### |
| 220 | |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 221 | if cpu not in supported_cpus |
| 222 | host_arch = 'unknown' |
| 223 | elif cpu == 'x86' |
| 224 | host_arch = 'i386' |
Richard Henderson | 0e3ed77 | 2021-12-31 05:25:11 +0000 | [diff] [blame] | 225 | elif cpu == 'mips64' |
| 226 | host_arch = 'mips' |
Philippe Mathieu-Daudé | 278c1bc | 2023-06-27 16:32:34 +0200 | [diff] [blame] | 227 | elif cpu in ['riscv32', 'riscv64'] |
| 228 | host_arch = 'riscv' |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 229 | else |
| 230 | host_arch = cpu |
| 231 | endif |
| 232 | |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 233 | if cpu in ['x86', 'x86_64'] |
| 234 | kvm_targets = ['i386-softmmu', 'x86_64-softmmu'] |
| 235 | elif cpu == 'aarch64' |
| 236 | kvm_targets = ['aarch64-softmmu'] |
| 237 | elif cpu == 's390x' |
| 238 | kvm_targets = ['s390x-softmmu'] |
| 239 | elif cpu in ['ppc', 'ppc64'] |
| 240 | kvm_targets = ['ppc-softmmu', 'ppc64-softmmu'] |
Huacai Chen | fbc5884 | 2020-10-07 16:39:28 +0800 | [diff] [blame] | 241 | elif cpu in ['mips', 'mips64'] |
| 242 | kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu'] |
Philippe Mathieu-Daudé | 4de8109 | 2023-06-27 16:32:35 +0200 | [diff] [blame] | 243 | elif cpu in ['riscv32'] |
| 244 | kvm_targets = ['riscv32-softmmu'] |
| 245 | elif cpu in ['riscv64'] |
| 246 | kvm_targets = ['riscv64-softmmu'] |
Tianrui Zhao | 714b03c | 2024-01-05 15:58:04 +0800 | [diff] [blame] | 247 | elif cpu in ['loongarch64'] |
| 248 | kvm_targets = ['loongarch64-softmmu'] |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 249 | else |
| 250 | kvm_targets = [] |
| 251 | endif |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 252 | accelerator_targets = { 'CONFIG_KVM': kvm_targets } |
Alexander Graf | 844a06b | 2021-09-16 17:54:02 +0200 | [diff] [blame] | 253 | |
Paolo Bonzini | 16b6273 | 2023-12-09 15:31:15 +0100 | [diff] [blame] | 254 | if cpu in ['x86', 'x86_64'] |
| 255 | xen_targets = ['i386-softmmu', 'x86_64-softmmu'] |
| 256 | elif cpu in ['arm', 'aarch64'] |
| 257 | # i386 emulator provides xenpv machine type for multiple architectures |
| 258 | xen_targets = ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu'] |
| 259 | else |
| 260 | xen_targets = [] |
| 261 | endif |
| 262 | accelerator_targets += { 'CONFIG_XEN': xen_targets } |
| 263 | |
Alexander Graf | 844a06b | 2021-09-16 17:54:02 +0200 | [diff] [blame] | 264 | if cpu in ['aarch64'] |
| 265 | accelerator_targets += { |
| 266 | 'CONFIG_HVF': ['aarch64-softmmu'] |
| 267 | } |
| 268 | endif |
| 269 | |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 270 | if cpu in ['x86', 'x86_64'] |
| 271 | accelerator_targets += { |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 272 | 'CONFIG_HVF': ['x86_64-softmmu'], |
Reinoud Zandijk | 74a414a | 2021-04-02 22:25:32 +0200 | [diff] [blame] | 273 | 'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'], |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 274 | 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'], |
| 275 | } |
| 276 | endif |
| 277 | |
Paolo Bonzini | a1b176f | 2021-07-12 14:22:08 +0200 | [diff] [blame] | 278 | modular_tcg = [] |
| 279 | # Darwin does not support references to thread-local variables in modules |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 280 | if host_os != 'darwin' |
Paolo Bonzini | a1b176f | 2021-07-12 14:22:08 +0200 | [diff] [blame] | 281 | modular_tcg = ['i386-softmmu', 'x86_64-softmmu'] |
| 282 | endif |
Gerd Hoffmann | dae0ec1 | 2021-06-24 12:38:31 +0200 | [diff] [blame] | 283 | |
Paolo Bonzini | 201e8ed | 2020-09-01 07:45:54 -0400 | [diff] [blame] | 284 | ################## |
| 285 | # Compiler flags # |
| 286 | ################## |
| 287 | |
Paolo Bonzini | 13f60de | 2022-10-20 14:34:27 +0200 | [diff] [blame] | 288 | foreach lang : all_languages |
| 289 | compiler = meson.get_compiler(lang) |
| 290 | if compiler.get_id() == 'gcc' and compiler.version().version_compare('>=7.4') |
| 291 | # ok |
| 292 | elif compiler.get_id() == 'clang' and compiler.compiles(''' |
| 293 | #ifdef __apple_build_version__ |
| 294 | # if __clang_major__ < 12 || (__clang_major__ == 12 && __clang_minor__ < 0) |
| 295 | # error You need at least XCode Clang v12.0 to compile QEMU |
| 296 | # endif |
| 297 | #else |
| 298 | # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) |
| 299 | # error You need at least Clang v10.0 to compile QEMU |
| 300 | # endif |
| 301 | #endif''') |
| 302 | # ok |
| 303 | else |
| 304 | error('You either need GCC v7.4 or Clang v10.0 (or XCode Clang v12.0) to compile QEMU') |
| 305 | endif |
| 306 | endforeach |
| 307 | |
Paolo Bonzini | a988b4c | 2022-10-20 14:20:30 +0200 | [diff] [blame] | 308 | # default flags for all hosts |
| 309 | # We use -fwrapv to tell the compiler that we require a C dialect where |
| 310 | # left shift of signed integers is well defined and has the expected |
| 311 | # 2s-complement style results. (Both clang and gcc agree that it |
| 312 | # provides these semantics.) |
| 313 | |
| 314 | qemu_common_flags = [ |
| 315 | '-D_GNU_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', |
| 316 | '-fno-strict-aliasing', '-fno-common', '-fwrapv' ] |
Paolo Bonzini | d67212d | 2022-10-12 17:13:23 +0200 | [diff] [blame] | 317 | qemu_cflags = [] |
Paolo Bonzini | 911d4ca | 2022-10-12 12:46:23 +0200 | [diff] [blame] | 318 | qemu_ldflags = [] |
Paolo Bonzini | 8cc2d23 | 2021-11-08 12:36:29 +0100 | [diff] [blame] | 319 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 320 | if host_os == 'darwin' |
Paolo Bonzini | a988b4c | 2022-10-20 14:20:30 +0200 | [diff] [blame] | 321 | # Disable attempts to use ObjectiveC features in os/object.h since they |
| 322 | # won't work when we're compiling with gcc as a C compiler. |
Alexander Graf | 2fc3653 | 2023-08-30 16:14:14 +0000 | [diff] [blame] | 323 | if compiler.get_id() == 'gcc' |
| 324 | qemu_common_flags += '-DOS_OBJECT_USE_OBJC=0' |
| 325 | endif |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 326 | elif host_os == 'sunos' |
Paolo Bonzini | a988b4c | 2022-10-20 14:20:30 +0200 | [diff] [blame] | 327 | # needed for CMSG_ macros in sys/socket.h |
| 328 | qemu_common_flags += '-D_XOPEN_SOURCE=600' |
| 329 | # needed for TIOCWIN* defines in termios.h |
| 330 | qemu_common_flags += '-D__EXTENSIONS__' |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 331 | elif host_os == 'haiku' |
Paolo Bonzini | a988b4c | 2022-10-20 14:20:30 +0200 | [diff] [blame] | 332 | qemu_common_flags += ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE', '-fPIC'] |
Thomas Huth | e25264f | 2024-08-15 14:27:19 +0200 | [diff] [blame] | 333 | elif host_os == 'windows' |
| 334 | if not compiler.compiles('struct x { int y; } __attribute__((gcc_struct));', |
| 335 | args: '-Werror') |
| 336 | error('Your compiler does not support __attribute__((gcc_struct)) - please use GCC instead of Clang') |
| 337 | endif |
Paolo Bonzini | a988b4c | 2022-10-20 14:20:30 +0200 | [diff] [blame] | 338 | endif |
| 339 | |
Paolo Bonzini | 6ae8c53 | 2024-10-07 10:31:28 +0200 | [diff] [blame] | 340 | # Choose instruction set (currently x86-only) |
| 341 | |
| 342 | qemu_isa_flags = [] |
| 343 | |
Paolo Bonzini | a988b4c | 2022-10-20 14:20:30 +0200 | [diff] [blame] | 344 | # __sync_fetch_and_and requires at least -march=i486. Many toolchains |
| 345 | # use i686 as default anyway, but for those that don't, an explicit |
| 346 | # specification is necessary |
| 347 | if host_arch == 'i386' and not cc.links(''' |
| 348 | static int sfaa(int *ptr) |
| 349 | { |
| 350 | return __sync_fetch_and_and(ptr, 0); |
| 351 | } |
| 352 | |
| 353 | int main(void) |
| 354 | { |
| 355 | int val = 42; |
| 356 | val = __sync_val_compare_and_swap(&val, 0, 1); |
| 357 | sfaa(&val); |
| 358 | return val; |
| 359 | }''') |
Paolo Bonzini | 6ae8c53 | 2024-10-07 10:31:28 +0200 | [diff] [blame] | 360 | qemu_isa_flags += ['-march=i486'] |
Paolo Bonzini | a988b4c | 2022-10-20 14:20:30 +0200 | [diff] [blame] | 361 | endif |
| 362 | |
Paolo Bonzini | ef7d1ad | 2024-06-18 17:32:52 +0200 | [diff] [blame] | 363 | # Pick x86-64 baseline version |
Paolo Bonzini | 294ac64 | 2024-05-31 10:37:06 +0200 | [diff] [blame] | 364 | if host_arch in ['i386', 'x86_64'] |
Paolo Bonzini | ef7d1ad | 2024-06-18 17:32:52 +0200 | [diff] [blame] | 365 | if get_option('x86_version') == '0' and host_arch == 'x86_64' |
| 366 | error('x86_64-v1 required for x86-64 hosts') |
| 367 | endif |
| 368 | |
| 369 | # add flags for individual instruction set extensions |
| 370 | if get_option('x86_version') >= '1' |
| 371 | if host_arch == 'i386' |
| 372 | qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags |
| 373 | else |
| 374 | # present on basically all processors but technically not part of |
| 375 | # x86-64-v1, so only include -mneeded for x86-64 version 2 and above |
Paolo Bonzini | 6ae8c53 | 2024-10-07 10:31:28 +0200 | [diff] [blame] | 376 | qemu_isa_flags += ['-mcx16'] |
Paolo Bonzini | ef7d1ad | 2024-06-18 17:32:52 +0200 | [diff] [blame] | 377 | endif |
| 378 | endif |
| 379 | if get_option('x86_version') >= '2' |
Paolo Bonzini | 6ae8c53 | 2024-10-07 10:31:28 +0200 | [diff] [blame] | 380 | qemu_isa_flags += ['-mpopcnt'] |
| 381 | qemu_isa_flags += cc.get_supported_arguments('-mneeded') |
Paolo Bonzini | ef7d1ad | 2024-06-18 17:32:52 +0200 | [diff] [blame] | 382 | endif |
| 383 | if get_option('x86_version') >= '3' |
Paolo Bonzini | 6ae8c53 | 2024-10-07 10:31:28 +0200 | [diff] [blame] | 384 | qemu_isa_flags += ['-mmovbe', '-mabm', '-mbmi', '-mbmi2', '-mfma', '-mf16c'] |
Paolo Bonzini | ef7d1ad | 2024-06-18 17:32:52 +0200 | [diff] [blame] | 385 | endif |
| 386 | |
| 387 | # add required vector instruction set (each level implies those below) |
| 388 | if get_option('x86_version') == '1' |
Paolo Bonzini | 6ae8c53 | 2024-10-07 10:31:28 +0200 | [diff] [blame] | 389 | qemu_isa_flags += ['-msse2'] |
Paolo Bonzini | ef7d1ad | 2024-06-18 17:32:52 +0200 | [diff] [blame] | 390 | elif get_option('x86_version') == '2' |
Paolo Bonzini | 6ae8c53 | 2024-10-07 10:31:28 +0200 | [diff] [blame] | 391 | qemu_isa_flags += ['-msse4.2'] |
Paolo Bonzini | ef7d1ad | 2024-06-18 17:32:52 +0200 | [diff] [blame] | 392 | elif get_option('x86_version') == '3' |
Paolo Bonzini | 6ae8c53 | 2024-10-07 10:31:28 +0200 | [diff] [blame] | 393 | qemu_isa_flags += ['-mavx2'] |
Paolo Bonzini | ef7d1ad | 2024-06-18 17:32:52 +0200 | [diff] [blame] | 394 | elif get_option('x86_version') == '4' |
Paolo Bonzini | 6ae8c53 | 2024-10-07 10:31:28 +0200 | [diff] [blame] | 395 | qemu_isa_flags += ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl'] |
Paolo Bonzini | ef7d1ad | 2024-06-18 17:32:52 +0200 | [diff] [blame] | 396 | endif |
Artyom Kunakovsky | c2bf2cc | 2024-05-23 08:11:18 +0300 | [diff] [blame] | 397 | endif |
| 398 | |
Paolo Bonzini | 6ae8c53 | 2024-10-07 10:31:28 +0200 | [diff] [blame] | 399 | qemu_common_flags = qemu_isa_flags + qemu_common_flags |
| 400 | |
Paolo Bonzini | a0cbd2e | 2022-07-14 14:33:49 +0200 | [diff] [blame] | 401 | if get_option('prefer_static') |
Paolo Bonzini | e4333d1 | 2022-03-15 15:57:15 +0100 | [diff] [blame] | 402 | qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static' |
| 403 | endif |
| 404 | |
Paolo Bonzini | a988b4c | 2022-10-20 14:20:30 +0200 | [diff] [blame] | 405 | # Meson currently only handles pie as a boolean for now, so if the user |
| 406 | # has explicitly disabled PIE we need to extend our cflags. |
Paolo Bonzini | b03fcd6 | 2023-05-22 10:05:33 +0200 | [diff] [blame] | 407 | # |
| 408 | # -no-pie is supposedly a linker flag that has no effect on the compiler |
| 409 | # command line, but some distros, that didn't quite know what they were |
| 410 | # doing, made local changes to gcc's specs file that turned it into |
| 411 | # a compiler command-line flag. |
| 412 | # |
| 413 | # What about linker flags? For a static build, no PIE is implied by -static |
| 414 | # which we added above (and if it's not because of the same specs patching, |
| 415 | # there's nothing we can do: compilation will fail, report a bug to your |
| 416 | # distro and do not use --disable-pie in the meanwhile). For dynamic linking, |
| 417 | # instead, we can't add -no-pie because it overrides -shared: the linker then |
| 418 | # tries to build an executable instead of a shared library and fails. So |
| 419 | # don't add -no-pie anywhere and cross fingers. :( |
Paolo Bonzini | a988b4c | 2022-10-20 14:20:30 +0200 | [diff] [blame] | 420 | if not get_option('b_pie') |
Paolo Bonzini | b03fcd6 | 2023-05-22 10:05:33 +0200 | [diff] [blame] | 421 | qemu_common_flags += cc.get_supported_arguments('-fno-pie', '-no-pie') |
Paolo Bonzini | a988b4c | 2022-10-20 14:20:30 +0200 | [diff] [blame] | 422 | endif |
| 423 | |
Paolo Bonzini | 911d4ca | 2022-10-12 12:46:23 +0200 | [diff] [blame] | 424 | if not get_option('stack_protector').disabled() |
| 425 | stack_protector_probe = ''' |
| 426 | int main(int argc, char *argv[]) |
| 427 | { |
| 428 | char arr[64], *p = arr, *c = argv[argc - 1]; |
| 429 | while (*c) { |
| 430 | *p++ = *c++; |
| 431 | } |
| 432 | return 0; |
| 433 | }''' |
| 434 | have_stack_protector = false |
| 435 | foreach arg : ['-fstack-protector-strong', '-fstack-protector-all'] |
| 436 | # We need to check both a compile and a link, since some compiler |
| 437 | # setups fail only on a .c->.o compile and some only at link time |
| 438 | if cc.compiles(stack_protector_probe, args: ['-Werror', arg]) and \ |
| 439 | cc.links(stack_protector_probe, args: ['-Werror', arg]) |
| 440 | have_stack_protector = true |
| 441 | qemu_cflags += arg |
| 442 | qemu_ldflags += arg |
| 443 | break |
| 444 | endif |
| 445 | endforeach |
| 446 | get_option('stack_protector') \ |
| 447 | .require(have_stack_protector, error_message: 'Stack protector not supported') |
| 448 | endif |
| 449 | |
Paolo Bonzini | 6739825 | 2022-10-12 13:19:35 +0200 | [diff] [blame] | 450 | coroutine_backend = get_option('coroutine_backend') |
| 451 | ucontext_probe = ''' |
| 452 | #include <ucontext.h> |
| 453 | #ifdef __stub_makecontext |
| 454 | #error Ignoring glibc stub makecontext which will always fail |
| 455 | #endif |
| 456 | int main(void) { makecontext(0, 0, 0); return 0; }''' |
| 457 | |
| 458 | # On Windows the only valid backend is the Windows specific one. |
| 459 | # For POSIX prefer ucontext, but it's not always possible. The fallback |
| 460 | # is sigcontext. |
| 461 | supported_backends = [] |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 462 | if host_os == 'windows' |
Paolo Bonzini | 6739825 | 2022-10-12 13:19:35 +0200 | [diff] [blame] | 463 | supported_backends += ['windows'] |
| 464 | else |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 465 | if host_os != 'darwin' and cc.links(ucontext_probe) |
Paolo Bonzini | 6739825 | 2022-10-12 13:19:35 +0200 | [diff] [blame] | 466 | supported_backends += ['ucontext'] |
| 467 | endif |
| 468 | supported_backends += ['sigaltstack'] |
| 469 | endif |
| 470 | |
| 471 | if coroutine_backend == 'auto' |
| 472 | coroutine_backend = supported_backends[0] |
| 473 | elif coroutine_backend not in supported_backends |
| 474 | error('"@0@" backend requested but not available. Available backends: @1@' \ |
| 475 | .format(coroutine_backend, ', '.join(supported_backends))) |
| 476 | endif |
| 477 | |
Paolo Bonzini | 721fa5e | 2022-10-12 11:59:51 +0200 | [diff] [blame] | 478 | # Compiles if SafeStack *not* enabled |
| 479 | safe_stack_probe = ''' |
| 480 | int main(void) |
| 481 | { |
| 482 | #if defined(__has_feature) |
| 483 | #if __has_feature(safe_stack) |
| 484 | #error SafeStack Enabled |
| 485 | #endif |
| 486 | #endif |
| 487 | return 0; |
| 488 | }''' |
| 489 | if get_option('safe_stack') != not cc.compiles(safe_stack_probe) |
| 490 | safe_stack_arg = get_option('safe_stack') ? '-fsanitize=safe-stack' : '-fno-sanitize=safe-stack' |
| 491 | if get_option('safe_stack') != not cc.compiles(safe_stack_probe, args: safe_stack_arg) |
| 492 | error(get_option('safe_stack') \ |
| 493 | ? 'SafeStack not supported by your compiler' \ |
| 494 | : 'Cannot disable SafeStack') |
| 495 | endif |
| 496 | qemu_cflags += safe_stack_arg |
| 497 | qemu_ldflags += safe_stack_arg |
| 498 | endif |
Paolo Bonzini | 6739825 | 2022-10-12 13:19:35 +0200 | [diff] [blame] | 499 | if get_option('safe_stack') and coroutine_backend != 'ucontext' |
Paolo Bonzini | 721fa5e | 2022-10-12 11:59:51 +0200 | [diff] [blame] | 500 | error('SafeStack is only supported with the ucontext coroutine backend') |
| 501 | endif |
| 502 | |
Richard Henderson | cb771ac | 2024-08-13 19:52:15 +1000 | [diff] [blame] | 503 | if get_option('asan') |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 504 | if cc.has_argument('-fsanitize=address') |
| 505 | qemu_cflags = ['-fsanitize=address'] + qemu_cflags |
| 506 | qemu_ldflags = ['-fsanitize=address'] + qemu_ldflags |
Richard Henderson | cb771ac | 2024-08-13 19:52:15 +1000 | [diff] [blame] | 507 | else |
| 508 | error('Your compiler does not support -fsanitize=address') |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 509 | endif |
Richard Henderson | cb771ac | 2024-08-13 19:52:15 +1000 | [diff] [blame] | 510 | endif |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 511 | |
Richard Henderson | cb771ac | 2024-08-13 19:52:15 +1000 | [diff] [blame] | 512 | if get_option('ubsan') |
| 513 | # Detect static linking issue with ubsan: |
| 514 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 515 | if cc.links('int main(int argc, char **argv) { return argc + 1; }', |
| 516 | args: [qemu_ldflags, '-fsanitize=undefined']) |
Richard Henderson | db770a2 | 2024-08-13 19:52:16 +1000 | [diff] [blame] | 517 | qemu_cflags += ['-fsanitize=undefined'] |
| 518 | qemu_ldflags += ['-fsanitize=undefined'] |
| 519 | |
| 520 | # Suppress undefined behaviour from function call to mismatched type. |
| 521 | # In addition, tcg prologue does not emit function type prefix |
| 522 | # required by function call sanitizer. |
| 523 | if cc.has_argument('-fno-sanitize=function') |
| 524 | qemu_cflags += ['-fno-sanitize=function'] |
| 525 | endif |
Richard Henderson | cb771ac | 2024-08-13 19:52:15 +1000 | [diff] [blame] | 526 | else |
| 527 | error('Your compiler does not support -fsanitize=undefined') |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 528 | endif |
| 529 | endif |
| 530 | |
| 531 | # Thread sanitizer is, for now, much noisier than the other sanitizers; |
| 532 | # keep it separate until that is not the case. |
| 533 | if get_option('tsan') |
Richard Henderson | cb771ac | 2024-08-13 19:52:15 +1000 | [diff] [blame] | 534 | if get_option('asan') or get_option('ubsan') |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 535 | error('TSAN is not supported with other sanitizers') |
| 536 | endif |
| 537 | if not cc.has_function('__tsan_create_fiber', |
| 538 | args: '-fsanitize=thread', |
| 539 | prefix: '#include <sanitizer/tsan_interface.h>') |
| 540 | error('Cannot enable TSAN due to missing fiber annotation interface') |
| 541 | endif |
Pierrick Bouvier | cf6fbba | 2024-10-23 12:33:52 +0100 | [diff] [blame] | 542 | tsan_warn_suppress = [] |
| 543 | # gcc (>=11) will report constructions not supported by tsan: |
| 544 | # "error: ‘atomic_thread_fence’ is not supported with ‘-fsanitize=thread’" |
| 545 | # https://gcc.gnu.org/gcc-11/changes.html |
| 546 | # However, clang does not support this warning and this triggers an error. |
| 547 | if cc.has_argument('-Wno-tsan') |
| 548 | tsan_warn_suppress = ['-Wno-tsan'] |
| 549 | endif |
| 550 | qemu_cflags = ['-fsanitize=thread'] + tsan_warn_suppress + qemu_cflags |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 551 | qemu_ldflags = ['-fsanitize=thread'] + qemu_ldflags |
| 552 | endif |
| 553 | |
Paolo Bonzini | e4333d1 | 2022-03-15 15:57:15 +0100 | [diff] [blame] | 554 | # Detect support for PT_GNU_RELRO + DT_BIND_NOW. |
| 555 | # The combination is known as "full relro", because .got.plt is read-only too. |
| 556 | qemu_ldflags += cc.get_supported_link_arguments('-Wl,-z,relro', '-Wl,-z,now') |
| 557 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 558 | if host_os == 'windows' |
Paolo Bonzini | d2147e0 | 2022-04-20 17:33:50 +0200 | [diff] [blame] | 559 | qemu_ldflags += cc.get_supported_link_arguments('-Wl,--no-seh', '-Wl,--nxcompat') |
Paolo Bonzini | 2d73fa7 | 2022-11-02 13:03:51 +0100 | [diff] [blame] | 560 | qemu_ldflags += cc.get_supported_link_arguments('-Wl,--dynamicbase', '-Wl,--high-entropy-va') |
Paolo Bonzini | d2147e0 | 2022-04-20 17:33:50 +0200 | [diff] [blame] | 561 | endif |
| 562 | |
Paolo Bonzini | 537b724 | 2021-10-07 15:08:12 +0200 | [diff] [blame] | 563 | if get_option('fuzzing') |
Paolo Bonzini | 537b724 | 2021-10-07 15:08:12 +0200 | [diff] [blame] | 564 | # Specify a filter to only instrument code that is directly related to |
| 565 | # virtual-devices. |
| 566 | configure_file(output: 'instrumentation-filter', |
| 567 | input: 'scripts/oss-fuzz/instrumentation-filter-template', |
| 568 | copy: true) |
Alexander Bulekov | aa4f3a3 | 2022-06-14 11:54:15 -0400 | [diff] [blame] | 569 | |
| 570 | if cc.compiles('int main () { return 0; }', |
| 571 | name: '-fsanitize-coverage-allowlist=/dev/null', |
Alexander Bulekov | e56d097 | 2022-06-21 16:45:07 -0400 | [diff] [blame] | 572 | args: ['-fsanitize-coverage-allowlist=/dev/null', |
| 573 | '-fsanitize-coverage=trace-pc'] ) |
Paolo Bonzini | d67212d | 2022-10-12 17:13:23 +0200 | [diff] [blame] | 574 | qemu_common_flags += ['-fsanitize-coverage-allowlist=instrumentation-filter'] |
Alexander Bulekov | aa4f3a3 | 2022-06-14 11:54:15 -0400 | [diff] [blame] | 575 | endif |
Paolo Bonzini | 537b724 | 2021-10-07 15:08:12 +0200 | [diff] [blame] | 576 | |
| 577 | if get_option('fuzzing_engine') == '' |
| 578 | # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the |
| 579 | # compiled code. To build non-fuzzer binaries with --enable-fuzzing, link |
| 580 | # everything with fsanitize=fuzzer-no-link. Otherwise, the linker will be |
| 581 | # unable to bind the fuzzer-related callbacks added by instrumentation. |
Paolo Bonzini | d67212d | 2022-10-12 17:13:23 +0200 | [diff] [blame] | 582 | qemu_common_flags += ['-fsanitize=fuzzer-no-link'] |
| 583 | qemu_ldflags += ['-fsanitize=fuzzer-no-link'] |
Paolo Bonzini | 537b724 | 2021-10-07 15:08:12 +0200 | [diff] [blame] | 584 | # For the actual fuzzer binaries, we need to link against the libfuzzer |
| 585 | # library. They need to be configurable, to support OSS-Fuzz |
| 586 | fuzz_exe_ldflags = ['-fsanitize=fuzzer'] |
| 587 | else |
| 588 | # LIB_FUZZING_ENGINE was set; assume we are running on OSS-Fuzz, and |
| 589 | # the needed CFLAGS have already been provided |
| 590 | fuzz_exe_ldflags = get_option('fuzzing_engine').split() |
| 591 | endif |
Alexander Bulekov | ff9ed62 | 2020-09-09 18:05:16 -0400 | [diff] [blame] | 592 | endif |
| 593 | |
Paolo Bonzini | 8276129 | 2023-05-10 14:54:30 +0200 | [diff] [blame] | 594 | if get_option('cfi') |
| 595 | cfi_flags=[] |
| 596 | # Check for dependency on LTO |
| 597 | if not get_option('b_lto') |
| 598 | error('Selected Control-Flow Integrity but LTO is disabled') |
| 599 | endif |
| 600 | if enable_modules |
| 601 | error('Selected Control-Flow Integrity is not compatible with modules') |
| 602 | endif |
| 603 | # Check for cfi flags. CFI requires LTO so we can't use |
| 604 | # get_supported_arguments, but need a more complex "compiles" which allows |
| 605 | # custom arguments |
| 606 | if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall', |
| 607 | args: ['-flto', '-fsanitize=cfi-icall'] ) |
| 608 | cfi_flags += '-fsanitize=cfi-icall' |
| 609 | else |
| 610 | error('-fsanitize=cfi-icall is not supported by the compiler') |
| 611 | endif |
| 612 | if cc.compiles('int main () { return 0; }', |
| 613 | name: '-fsanitize-cfi-icall-generalize-pointers', |
| 614 | args: ['-flto', '-fsanitize=cfi-icall', |
| 615 | '-fsanitize-cfi-icall-generalize-pointers'] ) |
| 616 | cfi_flags += '-fsanitize-cfi-icall-generalize-pointers' |
| 617 | else |
| 618 | error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler') |
| 619 | endif |
| 620 | if get_option('cfi_debug') |
| 621 | if cc.compiles('int main () { return 0; }', |
| 622 | name: '-fno-sanitize-trap=cfi-icall', |
| 623 | args: ['-flto', '-fsanitize=cfi-icall', |
| 624 | '-fno-sanitize-trap=cfi-icall'] ) |
| 625 | cfi_flags += '-fno-sanitize-trap=cfi-icall' |
| 626 | else |
| 627 | error('-fno-sanitize-trap=cfi-icall is not supported by the compiler') |
| 628 | endif |
| 629 | endif |
| 630 | add_global_arguments(cfi_flags, native: false, language: all_languages) |
| 631 | add_global_link_arguments(cfi_flags, native: false, language: all_languages) |
| 632 | endif |
| 633 | |
Daniel P. Berrangé | 043eaa0 | 2024-01-03 12:34:13 +0000 | [diff] [blame] | 634 | # Check further flags that make QEMU more robust against malicious parties |
| 635 | |
| 636 | hardening_flags = [ |
Daniel P. Berrangé | 7ff9ff03 | 2024-01-03 12:34:14 +0000 | [diff] [blame] | 637 | # Initialize all stack variables to zero. This makes |
| 638 | # it harder to take advantage of uninitialized stack |
| 639 | # data to drive exploits |
| 640 | '-ftrivial-auto-var-init=zero', |
Daniel P. Berrangé | 043eaa0 | 2024-01-03 12:34:13 +0000 | [diff] [blame] | 641 | ] |
| 642 | |
Daniel P. Berrangé | 9563311 | 2024-03-04 14:44:55 +0000 | [diff] [blame] | 643 | # Zero out registers used during a function call |
| 644 | # upon its return. This makes it harder to assemble |
| 645 | # ROP gadgets into something usable |
| 646 | # |
| 647 | # NB: Clang 17 is broken and SEGVs |
| 648 | # https://github.com/llvm/llvm-project/issues/75168 |
Thomas Huth | 2d6d995 | 2024-04-11 14:08:19 +0200 | [diff] [blame] | 649 | # |
| 650 | # NB2: This clashes with the "retguard" extension of OpenBSD's Clang |
| 651 | # https://gitlab.com/qemu-project/qemu/-/issues/2278 |
| 652 | if host_os != 'openbsd' and \ |
| 653 | cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }', |
Daniel P. Berrangé | 9563311 | 2024-03-04 14:44:55 +0000 | [diff] [blame] | 654 | name: '-fzero-call-used-regs=used-gpr', |
| 655 | args: ['-O2', '-fzero-call-used-regs=used-gpr']) |
| 656 | hardening_flags += '-fzero-call-used-regs=used-gpr' |
| 657 | endif |
| 658 | |
Daniel P. Berrangé | 043eaa0 | 2024-01-03 12:34:13 +0000 | [diff] [blame] | 659 | qemu_common_flags += cc.get_supported_arguments(hardening_flags) |
| 660 | |
Paolo Bonzini | d67212d | 2022-10-12 17:13:23 +0200 | [diff] [blame] | 661 | add_global_arguments(qemu_common_flags, native: false, language: all_languages) |
| 662 | add_global_link_arguments(qemu_ldflags, native: false, language: all_languages) |
| 663 | |
Daniel P. Berrangé | fdd5140 | 2023-09-21 10:12:51 +0100 | [diff] [blame] | 664 | # Collect warning flags we want to set, sorted alphabetically |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 665 | warn_flags = [ |
Daniel P. Berrangé | fdd5140 | 2023-09-21 10:12:51 +0100 | [diff] [blame] | 666 | # First enable interesting warnings |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 667 | '-Wempty-body', |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 668 | '-Wendif-labels', |
| 669 | '-Wexpansion-to-defined', |
Daniel P. Berrangé | fdd5140 | 2023-09-21 10:12:51 +0100 | [diff] [blame] | 670 | '-Wformat-security', |
| 671 | '-Wformat-y2k', |
| 672 | '-Wignored-qualifiers', |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 673 | '-Wimplicit-fallthrough=2', |
Daniel P. Berrangé | fdd5140 | 2023-09-21 10:12:51 +0100 | [diff] [blame] | 674 | '-Winit-self', |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 675 | '-Wmissing-format-attribute', |
Daniel P. Berrangé | fdd5140 | 2023-09-21 10:12:51 +0100 | [diff] [blame] | 676 | '-Wmissing-prototypes', |
| 677 | '-Wnested-externs', |
| 678 | '-Wold-style-declaration', |
| 679 | '-Wold-style-definition', |
| 680 | '-Wredundant-decls', |
| 681 | '-Wshadow=local', |
| 682 | '-Wstrict-prototypes', |
| 683 | '-Wtype-limits', |
| 684 | '-Wundef', |
Peter Maydell | 64c1a54 | 2024-02-21 17:26:36 +0100 | [diff] [blame] | 685 | '-Wvla', |
Daniel P. Berrangé | fdd5140 | 2023-09-21 10:12:51 +0100 | [diff] [blame] | 686 | '-Wwrite-strings', |
| 687 | |
| 688 | # Then disable some undesirable warnings |
| 689 | '-Wno-gnu-variable-sized-type-not-at-end', |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 690 | '-Wno-initializer-overrides', |
| 691 | '-Wno-missing-include-dirs', |
Daniel P. Berrangé | fdd5140 | 2023-09-21 10:12:51 +0100 | [diff] [blame] | 692 | '-Wno-psabi', |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 693 | '-Wno-shift-negative-value', |
| 694 | '-Wno-string-plus-int', |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 695 | '-Wno-tautological-type-limit-compare', |
Daniel P. Berrangé | fdd5140 | 2023-09-21 10:12:51 +0100 | [diff] [blame] | 696 | '-Wno-typedef-redefinition', |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 697 | ] |
| 698 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 699 | if host_os != 'darwin' |
Kevin Wolf | 7e17111 | 2024-06-27 20:12:45 +0200 | [diff] [blame] | 700 | tsa_has_cleanup = cc.compiles(''' |
| 701 | struct __attribute__((capability("mutex"))) mutex {}; |
| 702 | void lock(struct mutex *m) __attribute__((acquire_capability(m))); |
| 703 | void unlock(struct mutex *m) __attribute__((release_capability(m))); |
| 704 | |
| 705 | void test(void) { |
| 706 | struct mutex __attribute__((cleanup(unlock))) m; |
| 707 | lock(&m); |
| 708 | } |
| 709 | ''', args: ['-Wthread-safety', '-Werror']) |
| 710 | if tsa_has_cleanup |
| 711 | warn_flags += ['-Wthread-safety'] |
| 712 | endif |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 713 | endif |
| 714 | |
Thomas Huth | 785abf0 | 2023-07-06 08:47:36 +0200 | [diff] [blame] | 715 | # Set up C++ compiler flags |
Paolo Bonzini | b485458 | 2021-11-08 12:31:52 +0100 | [diff] [blame] | 716 | qemu_cxxflags = [] |
Paolo Bonzini | e513402 | 2022-10-12 14:15:06 +0200 | [diff] [blame] | 717 | if 'cpp' in all_languages |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 718 | qemu_cxxflags = ['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'] + qemu_cflags |
Paolo Bonzini | b485458 | 2021-11-08 12:31:52 +0100 | [diff] [blame] | 719 | endif |
| 720 | |
Paolo Bonzini | d67212d | 2022-10-12 17:13:23 +0200 | [diff] [blame] | 721 | add_project_arguments(qemu_cflags, native: false, language: 'c') |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 722 | add_project_arguments(cc.get_supported_arguments(warn_flags), native: false, language: 'c') |
| 723 | if 'cpp' in all_languages |
| 724 | add_project_arguments(qemu_cxxflags, native: false, language: 'cpp') |
| 725 | add_project_arguments(cxx.get_supported_arguments(warn_flags), native: false, language: 'cpp') |
| 726 | endif |
| 727 | if 'objc' in all_languages |
| 728 | # Note sanitizer flags are not applied to Objective-C sources! |
| 729 | add_project_arguments(objc.get_supported_arguments(warn_flags), native: false, language: 'objc') |
| 730 | endif |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 731 | if host_os == 'linux' |
Paolo Bonzini | 1e6e616 | 2020-10-14 08:45:42 -0400 | [diff] [blame] | 732 | add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers', |
| 733 | '-isystem', 'linux-headers', |
Paolo Bonzini | e513402 | 2022-10-12 14:15:06 +0200 | [diff] [blame] | 734 | language: all_languages) |
Paolo Bonzini | 1e6e616 | 2020-10-14 08:45:42 -0400 | [diff] [blame] | 735 | endif |
| 736 | |
Paolo Bonzini | 23a77b2 | 2020-12-14 12:01:45 +0100 | [diff] [blame] | 737 | add_project_arguments('-iquote', '.', |
Paolo Bonzini | 1e6e616 | 2020-10-14 08:45:42 -0400 | [diff] [blame] | 738 | '-iquote', meson.current_source_dir(), |
Paolo Bonzini | 1e6e616 | 2020-10-14 08:45:42 -0400 | [diff] [blame] | 739 | '-iquote', meson.current_source_dir() / 'include', |
Paolo Bonzini | e513402 | 2022-10-12 14:15:06 +0200 | [diff] [blame] | 740 | language: all_languages) |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 741 | |
Richard Henderson | 44fc716 | 2023-05-17 17:48:34 -0700 | [diff] [blame] | 742 | # If a host-specific include directory exists, list that first... |
| 743 | host_include = meson.current_source_dir() / 'host/include/' |
| 744 | if fs.is_dir(host_include / host_arch) |
| 745 | add_project_arguments('-iquote', host_include / host_arch, |
| 746 | language: all_languages) |
| 747 | endif |
| 748 | # ... followed by the generic fallback. |
| 749 | add_project_arguments('-iquote', host_include / 'generic', |
| 750 | language: all_languages) |
| 751 | |
Paolo Bonzini | deb6237 | 2020-09-01 07:51:16 -0400 | [diff] [blame] | 752 | sparse = find_program('cgcc', required: get_option('sparse')) |
| 753 | if sparse.found() |
Paolo Bonzini | 968b4db | 2020-02-03 14:45:33 +0100 | [diff] [blame] | 754 | run_target('sparse', |
| 755 | command: [find_program('scripts/check_sparse.py'), |
Paolo Bonzini | deb6237 | 2020-09-01 07:51:16 -0400 | [diff] [blame] | 756 | 'compile_commands.json', sparse.full_path(), '-Wbitwise', |
| 757 | '-Wno-transparent-union', '-Wno-old-initializer', |
| 758 | '-Wno-non-pointer-null']) |
Paolo Bonzini | 968b4db | 2020-02-03 14:45:33 +0100 | [diff] [blame] | 759 | endif |
| 760 | |
Paolo Bonzini | 0f63d96 | 2023-09-08 12:08:53 +0200 | [diff] [blame] | 761 | ##################################### |
| 762 | # Host-specific libraries and flags # |
| 763 | ##################################### |
| 764 | |
Paolo Bonzini | 7fa1c63 | 2021-06-01 10:00:48 +0200 | [diff] [blame] | 765 | libm = cc.find_library('m', required: false) |
Paolo Bonzini | 6d7c7c2 | 2021-06-03 15:01:35 +0200 | [diff] [blame] | 766 | threads = dependency('threads') |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 767 | util = cc.find_library('util', required: false) |
Paolo Bonzini | 4a96337 | 2020-08-03 16:22:28 +0200 | [diff] [blame] | 768 | winmm = [] |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 769 | socket = [] |
Marc-André Lureau | 04c6f1e | 2019-07-18 00:31:05 +0400 | [diff] [blame] | 770 | version_res = [] |
Marc-André Lureau | d92989a | 2019-08-20 19:48:59 +0400 | [diff] [blame] | 771 | coref = [] |
| 772 | iokit = [] |
Paolo Bonzini | b6c7cfd | 2020-09-21 04:49:50 -0400 | [diff] [blame] | 773 | emulator_link_args = [] |
Marc-André Lureau | 23011f4 | 2022-02-01 12:55:21 +0400 | [diff] [blame] | 774 | midl = not_found |
| 775 | widl = not_found |
Akihiko Odaki | cf60ccc | 2022-06-24 23:50:37 +0900 | [diff] [blame] | 776 | pathcch = not_found |
Paolo Bonzini | a630508 | 2021-10-07 15:08:15 +0200 | [diff] [blame] | 777 | host_dsosuf = '.so' |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 778 | if host_os == 'windows' |
Marc-André Lureau | 23011f4 | 2022-02-01 12:55:21 +0400 | [diff] [blame] | 779 | midl = find_program('midl', required: false) |
| 780 | widl = find_program('widl', required: false) |
Akihiko Odaki | cf60ccc | 2022-06-24 23:50:37 +0900 | [diff] [blame] | 781 | pathcch = cc.find_library('pathcch') |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 782 | socket = cc.find_library('ws2_32') |
Paolo Bonzini | 4a96337 | 2020-08-03 16:22:28 +0200 | [diff] [blame] | 783 | winmm = cc.find_library('winmm') |
Marc-André Lureau | 04c6f1e | 2019-07-18 00:31:05 +0400 | [diff] [blame] | 784 | |
| 785 | win = import('windows') |
| 786 | version_res = win.compile_resources('version.rc', |
| 787 | depend_files: files('pc-bios/qemu-nsis.ico'), |
| 788 | include_directories: include_directories('.')) |
Paolo Bonzini | a630508 | 2021-10-07 15:08:15 +0200 | [diff] [blame] | 789 | host_dsosuf = '.dll' |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 790 | elif host_os == 'darwin' |
Marc-André Lureau | d92989a | 2019-08-20 19:48:59 +0400 | [diff] [blame] | 791 | coref = dependency('appleframeworks', modules: 'CoreFoundation') |
Joelle van Dyne | 14176c8 | 2021-03-15 11:03:38 -0700 | [diff] [blame] | 792 | iokit = dependency('appleframeworks', modules: 'IOKit', required: false) |
Paolo Bonzini | a630508 | 2021-10-07 15:08:15 +0200 | [diff] [blame] | 793 | host_dsosuf = '.dylib' |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 794 | elif host_os == 'sunos' |
Paolo Bonzini | cfad62f | 2020-08-09 23:47:45 +0200 | [diff] [blame] | 795 | socket = [cc.find_library('socket'), |
| 796 | cc.find_library('nsl'), |
| 797 | cc.find_library('resolv')] |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 798 | elif host_os == 'haiku' |
Paolo Bonzini | cfad62f | 2020-08-09 23:47:45 +0200 | [diff] [blame] | 799 | socket = [cc.find_library('posix_error_mapper'), |
| 800 | cc.find_library('network'), |
| 801 | cc.find_library('bsd')] |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 802 | elif host_os == 'openbsd' |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 803 | if get_option('tcg').allowed() and target_dirs.length() > 0 |
Paolo Bonzini | b6c7cfd | 2020-09-21 04:49:50 -0400 | [diff] [blame] | 804 | # Disable OpenBSD W^X if available |
| 805 | emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded') |
| 806 | endif |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 807 | endif |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 808 | |
Paolo Bonzini | 0f63d96 | 2023-09-08 12:08:53 +0200 | [diff] [blame] | 809 | ############################################### |
| 810 | # Host-specific configuration of accelerators # |
| 811 | ############################################### |
| 812 | |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 813 | accelerators = [] |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 814 | if get_option('kvm').allowed() and host_os == 'linux' |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 815 | accelerators += 'CONFIG_KVM' |
| 816 | endif |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 817 | if get_option('whpx').allowed() and host_os == 'windows' |
Sunil Muthuswamy | 57e2a1f | 2020-10-22 00:27:55 +0000 | [diff] [blame] | 818 | if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64' |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 819 | error('WHPX requires 64-bit host') |
Philippe Mathieu-Daudé | 641b841 | 2023-06-24 15:31:44 +0200 | [diff] [blame] | 820 | elif cc.has_header('winhvplatform.h', required: get_option('whpx')) and \ |
| 821 | cc.has_header('winhvemulation.h', required: get_option('whpx')) |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 822 | accelerators += 'CONFIG_WHPX' |
| 823 | endif |
| 824 | endif |
Paolo Bonzini | 0f63d96 | 2023-09-08 12:08:53 +0200 | [diff] [blame] | 825 | |
| 826 | hvf = not_found |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 827 | if get_option('hvf').allowed() |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 828 | hvf = dependency('appleframeworks', modules: 'Hypervisor', |
| 829 | required: get_option('hvf')) |
| 830 | if hvf.found() |
| 831 | accelerators += 'CONFIG_HVF' |
| 832 | endif |
| 833 | endif |
Paolo Bonzini | 0f63d96 | 2023-09-08 12:08:53 +0200 | [diff] [blame] | 834 | |
| 835 | nvmm = not_found |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 836 | if host_os == 'netbsd' |
nia | 0cc4965 | 2021-10-13 13:54:17 +0000 | [diff] [blame] | 837 | nvmm = cc.find_library('nvmm', required: get_option('nvmm')) |
Reinoud Zandijk | 74a414a | 2021-04-02 22:25:32 +0200 | [diff] [blame] | 838 | if nvmm.found() |
| 839 | accelerators += 'CONFIG_NVMM' |
| 840 | endif |
| 841 | endif |
Paolo Bonzini | 23a77b2 | 2020-12-14 12:01:45 +0100 | [diff] [blame] | 842 | |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 843 | tcg_arch = host_arch |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 844 | if get_option('tcg').allowed() |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 845 | if host_arch == 'unknown' |
Paolo Bonzini | a24f15d | 2023-08-04 11:29:05 +0200 | [diff] [blame] | 846 | if not get_option('tcg_interpreter') |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 847 | error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu)) |
| 848 | endif |
Philippe Mathieu-Daudé | fa2f7b0 | 2021-01-25 15:45:30 +0100 | [diff] [blame] | 849 | elif get_option('tcg_interpreter') |
Philippe Mathieu-Daudé | 1c282da | 2021-05-21 12:34:23 +0200 | [diff] [blame] | 850 | warning('Use of the TCG interpreter is not recommended on this host') |
Philippe Mathieu-Daudé | fa2f7b0 | 2021-01-25 15:45:30 +0100 | [diff] [blame] | 851 | warning('architecture. There is a native TCG execution backend available') |
| 852 | warning('which provides substantially better performance and reliability.') |
| 853 | warning('It is strongly recommended to remove the --enable-tcg-interpreter') |
| 854 | warning('configuration option on this architecture to use the native') |
| 855 | warning('backend.') |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 856 | endif |
Paolo Bonzini | 23a77b2 | 2020-12-14 12:01:45 +0100 | [diff] [blame] | 857 | if get_option('tcg_interpreter') |
| 858 | tcg_arch = 'tci' |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 859 | elif host_arch == 'x86_64' |
Paolo Bonzini | 23a77b2 | 2020-12-14 12:01:45 +0100 | [diff] [blame] | 860 | tcg_arch = 'i386' |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 861 | elif host_arch == 'ppc64' |
Paolo Bonzini | 23a77b2 | 2020-12-14 12:01:45 +0100 | [diff] [blame] | 862 | tcg_arch = 'ppc' |
Paolo Bonzini | 23a77b2 | 2020-12-14 12:01:45 +0100 | [diff] [blame] | 863 | endif |
| 864 | add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch, |
Paolo Bonzini | e513402 | 2022-10-12 14:15:06 +0200 | [diff] [blame] | 865 | language: all_languages) |
Paolo Bonzini | 23a77b2 | 2020-12-14 12:01:45 +0100 | [diff] [blame] | 866 | |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 867 | accelerators += 'CONFIG_TCG' |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 868 | endif |
| 869 | |
| 870 | if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled() |
| 871 | error('KVM not available on this platform') |
| 872 | endif |
| 873 | if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled() |
| 874 | error('HVF not available on this platform') |
| 875 | endif |
Reinoud Zandijk | 74a414a | 2021-04-02 22:25:32 +0200 | [diff] [blame] | 876 | if 'CONFIG_NVMM' not in accelerators and get_option('nvmm').enabled() |
| 877 | error('NVMM not available on this platform') |
| 878 | endif |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 879 | if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled() |
| 880 | error('WHPX not available on this platform') |
| 881 | endif |
Paolo Bonzini | b4e312e | 2020-09-01 11:28:59 -0400 | [diff] [blame] | 882 | |
Paolo Bonzini | 0f63d96 | 2023-09-08 12:08:53 +0200 | [diff] [blame] | 883 | xen = not_found |
| 884 | if get_option('xen').enabled() or (get_option('xen').auto() and have_system) |
| 885 | xencontrol = dependency('xencontrol', required: false, |
| 886 | method: 'pkg-config') |
| 887 | if xencontrol.found() |
| 888 | xen_pc = declare_dependency(version: xencontrol.version(), |
| 889 | dependencies: [ |
| 890 | xencontrol, |
| 891 | # disabler: true makes xen_pc.found() return false if any is not found |
| 892 | dependency('xenstore', required: false, |
| 893 | method: 'pkg-config', |
| 894 | disabler: true), |
| 895 | dependency('xenforeignmemory', required: false, |
| 896 | method: 'pkg-config', |
| 897 | disabler: true), |
| 898 | dependency('xengnttab', required: false, |
| 899 | method: 'pkg-config', |
| 900 | disabler: true), |
| 901 | dependency('xenevtchn', required: false, |
| 902 | method: 'pkg-config', |
| 903 | disabler: true), |
| 904 | dependency('xendevicemodel', required: false, |
| 905 | method: 'pkg-config', |
| 906 | disabler: true), |
| 907 | # optional, no "disabler: true" |
| 908 | dependency('xentoolcore', required: false, |
| 909 | method: 'pkg-config')]) |
| 910 | if xen_pc.found() |
| 911 | xen = xen_pc |
| 912 | endif |
| 913 | endif |
| 914 | if not xen.found() |
| 915 | xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1' ] |
| 916 | xen_libs = { |
| 917 | '4.11.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ], |
| 918 | '4.10.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ], |
| 919 | '4.9.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ], |
| 920 | '4.8.0': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ], |
| 921 | '4.7.1': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ], |
| 922 | } |
| 923 | xen_deps = {} |
| 924 | foreach ver: xen_tests |
| 925 | # cache the various library tests to avoid polluting the logs |
| 926 | xen_test_deps = [] |
| 927 | foreach l: xen_libs[ver] |
| 928 | if l not in xen_deps |
| 929 | xen_deps += { l: cc.find_library(l, required: false) } |
| 930 | endif |
| 931 | xen_test_deps += xen_deps[l] |
| 932 | endforeach |
| 933 | |
| 934 | # Use -D to pick just one of the test programs in scripts/xen-detect.c |
| 935 | xen_version = ver.split('.') |
| 936 | xen_ctrl_version = xen_version[0] + \ |
| 937 | ('0' + xen_version[1]).substring(-2) + \ |
| 938 | ('0' + xen_version[2]).substring(-2) |
| 939 | if cc.links(files('scripts/xen-detect.c'), |
| 940 | args: '-DCONFIG_XEN_CTRL_INTERFACE_VERSION=' + xen_ctrl_version, |
| 941 | dependencies: xen_test_deps) |
| 942 | xen = declare_dependency(version: ver, dependencies: xen_test_deps) |
| 943 | break |
| 944 | endif |
| 945 | endforeach |
| 946 | endif |
| 947 | if xen.found() |
| 948 | accelerators += 'CONFIG_XEN' |
| 949 | elif get_option('xen').enabled() |
| 950 | error('could not compile and link Xen test program') |
| 951 | endif |
| 952 | endif |
| 953 | have_xen_pci_passthrough = get_option('xen_pci_passthrough') \ |
| 954 | .require(xen.found(), |
| 955 | error_message: 'Xen PCI passthrough requested but Xen not enabled') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 956 | .require(host_os == 'linux', |
Paolo Bonzini | 0f63d96 | 2023-09-08 12:08:53 +0200 | [diff] [blame] | 957 | error_message: 'Xen PCI passthrough not available on this platform') \ |
| 958 | .require(cpu == 'x86' or cpu == 'x86_64', |
| 959 | error_message: 'Xen PCI passthrough not available on this platform') \ |
| 960 | .allowed() |
| 961 | |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 962 | ################ |
| 963 | # Dependencies # |
| 964 | ################ |
| 965 | |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 966 | # When bumping glib minimum version, please check also whether to increase |
Manos Pitsidianakis | dc43b18 | 2024-10-03 16:28:48 +0300 | [diff] [blame] | 967 | # the _WIN32_WINNT setting in osdep.h according to the value from glib. |
| 968 | # You should also check if any of the glib.version() checks |
| 969 | # below can also be removed. |
Thomas Huth | 0d8caac | 2024-04-18 12:10:50 +0200 | [diff] [blame] | 970 | glib_req_ver = '>=2.66.0' |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 971 | glib_pc = dependency('glib-2.0', version: glib_req_ver, required: true, |
| 972 | method: 'pkg-config') |
| 973 | glib_cflags = [] |
Paolo Bonzini | 6002711 | 2022-10-20 14:53:10 +0200 | [diff] [blame] | 974 | if enable_modules |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 975 | gmodule = dependency('gmodule-export-2.0', version: glib_req_ver, required: true, |
| 976 | method: 'pkg-config') |
Paolo Bonzini | 2c13c57 | 2023-08-30 12:20:53 +0200 | [diff] [blame] | 977 | elif get_option('plugins') |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 978 | gmodule = dependency('gmodule-no-export-2.0', version: glib_req_ver, required: true, |
| 979 | method: 'pkg-config') |
| 980 | else |
| 981 | gmodule = not_found |
Emilio Cota | e3feb2c | 2023-02-05 11:37:57 -0500 | [diff] [blame] | 982 | endif |
Marc-André Lureau | 953d5a9 | 2020-12-15 12:03:19 +0400 | [diff] [blame] | 983 | |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 984 | # This workaround is required due to a bug in pkg-config file for glib as it |
| 985 | # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 986 | if host_os == 'windows' and get_option('prefer_static') |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 987 | glib_cflags += ['-DGLIB_STATIC_COMPILATION'] |
| 988 | endif |
| 989 | |
| 990 | # Sanity check that the current size_t matches the |
| 991 | # size that glib thinks it should be. This catches |
| 992 | # problems on multi-arch where people try to build |
| 993 | # 32-bit QEMU while pointing at 64-bit glib headers |
| 994 | |
| 995 | if not cc.compiles(''' |
| 996 | #include <glib.h> |
| 997 | #include <unistd.h> |
| 998 | |
| 999 | #define QEMU_BUILD_BUG_ON(x) \ |
| 1000 | typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); |
| 1001 | |
| 1002 | int main(void) { |
| 1003 | QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); |
| 1004 | return 0; |
| 1005 | }''', dependencies: glib_pc, args: glib_cflags) |
| 1006 | error('''sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T. |
| 1007 | You probably need to set PKG_CONFIG_LIBDIR" to point |
| 1008 | to the right pkg-config files for your build target.''') |
| 1009 | endif |
| 1010 | |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 1011 | glib = declare_dependency(dependencies: [glib_pc, gmodule], |
| 1012 | compile_args: glib_cflags, |
| 1013 | version: glib_pc.version()) |
| 1014 | |
| 1015 | # Check whether glib has gslice, which we have to avoid for correctness. |
| 1016 | # TODO: remove this check and the corresponding workaround (qtree) when |
| 1017 | # the minimum supported glib is >= 2.75.3 |
| 1018 | glib_has_gslice = glib.version().version_compare('<2.75.3') |
Manos Pitsidianakis | dc43b18 | 2024-10-03 16:28:48 +0300 | [diff] [blame] | 1019 | # Check whether glib has the aligned_alloc family of functions. |
| 1020 | # <https://docs.gtk.org/glib/func.aligned_alloc.html> |
| 1021 | glib_has_aligned_alloc = glib.version().version_compare('>=2.72.0') |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 1022 | |
| 1023 | # override glib dep to include the above refinements |
| 1024 | meson.override_dependency('glib-2.0', glib) |
| 1025 | |
| 1026 | # The path to glib.h is added to all compilation commands. |
| 1027 | add_project_dependencies(glib.partial_dependency(compile_args: true, includes: true), |
| 1028 | native: false, language: all_languages) |
| 1029 | |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 1030 | gio = not_found |
Paolo Bonzini | 7544060 | 2022-04-20 17:33:44 +0200 | [diff] [blame] | 1031 | gdbus_codegen = not_found |
Paolo Bonzini | bb2dc4b | 2022-09-30 09:53:02 +0200 | [diff] [blame] | 1032 | gdbus_codegen_error = '@0@ requires gdbus-codegen, please install libgio' |
Paolo Bonzini | 7544060 | 2022-04-20 17:33:44 +0200 | [diff] [blame] | 1033 | if not get_option('gio').auto() or have_system |
| 1034 | gio = dependency('gio-2.0', required: get_option('gio'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1035 | method: 'pkg-config') |
Paolo Bonzini | 7544060 | 2022-04-20 17:33:44 +0200 | [diff] [blame] | 1036 | if gio.found() and not cc.links(''' |
| 1037 | #include <gio/gio.h> |
| 1038 | int main(void) |
| 1039 | { |
| 1040 | g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0); |
| 1041 | return 0; |
| 1042 | }''', dependencies: [glib, gio]) |
| 1043 | if get_option('gio').enabled() |
| 1044 | error('The installed libgio is broken for static linking') |
| 1045 | endif |
| 1046 | gio = not_found |
| 1047 | endif |
| 1048 | if gio.found() |
Marc-André Lureau | c118c8e | 2024-10-08 16:50:22 +0400 | [diff] [blame] | 1049 | gdbus_codegen = find_program('gdbus-codegen', |
Paolo Bonzini | 7544060 | 2022-04-20 17:33:44 +0200 | [diff] [blame] | 1050 | required: get_option('gio')) |
| 1051 | gio_unix = dependency('gio-unix-2.0', required: get_option('gio'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1052 | method: 'pkg-config') |
Paolo Bonzini | 7544060 | 2022-04-20 17:33:44 +0200 | [diff] [blame] | 1053 | gio = declare_dependency(dependencies: [gio, gio_unix], |
| 1054 | version: gio.version()) |
| 1055 | endif |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 1056 | endif |
Paolo Bonzini | bb2dc4b | 2022-09-30 09:53:02 +0200 | [diff] [blame] | 1057 | if gdbus_codegen.found() and get_option('cfi') |
| 1058 | gdbus_codegen = not_found |
| 1059 | gdbus_codegen_error = '@0@ uses gdbus-codegen, which does not support control flow integrity' |
| 1060 | endif |
Paolo Bonzini | 7544060 | 2022-04-20 17:33:44 +0200 | [diff] [blame] | 1061 | |
Marc-André Lureau | 6cc5a61 | 2023-06-06 15:56:42 +0400 | [diff] [blame] | 1062 | xml_pp = find_program('scripts/xml-preprocess.py') |
| 1063 | |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 1064 | lttng = not_found |
Paolo Bonzini | 9c29b74 | 2021-10-07 15:08:14 +0200 | [diff] [blame] | 1065 | if 'ust' in get_option('trace_backends') |
Marc-André Lureau | e32aaa5 | 2022-03-28 12:47:13 +0400 | [diff] [blame] | 1066 | lttng = dependency('lttng-ust', required: true, version: '>= 2.1', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1067 | method: 'pkg-config') |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 1068 | endif |
Paolo Bonzini | b7612f4 | 2020-08-26 08:22:58 +0200 | [diff] [blame] | 1069 | pixman = not_found |
Marc-André Lureau | cca1575 | 2023-08-30 13:38:25 +0400 | [diff] [blame] | 1070 | if not get_option('pixman').auto() or have_system or have_tools |
| 1071 | pixman = dependency('pixman-1', required: get_option('pixman'), version:'>=0.21.8', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1072 | method: 'pkg-config') |
Paolo Bonzini | b7612f4 | 2020-08-26 08:22:58 +0200 | [diff] [blame] | 1073 | endif |
Marc-André Lureau | cca1575 | 2023-08-30 13:38:25 +0400 | [diff] [blame] | 1074 | |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1075 | zlib = dependency('zlib', required: true) |
Paolo Bonzini | 53c22b6 | 2021-06-03 11:31:35 +0200 | [diff] [blame] | 1076 | |
Paolo Bonzini | ff66f3e | 2021-10-07 15:08:20 +0200 | [diff] [blame] | 1077 | libaio = not_found |
| 1078 | if not get_option('linux_aio').auto() or have_block |
| 1079 | libaio = cc.find_library('aio', has_headers: ['libaio.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1080 | required: get_option('linux_aio')) |
Paolo Bonzini | ff66f3e | 2021-10-07 15:08:20 +0200 | [diff] [blame] | 1081 | endif |
Leonardo Bras | 354081d | 2022-05-13 03:28:30 -0300 | [diff] [blame] | 1082 | |
| 1083 | linux_io_uring_test = ''' |
| 1084 | #include <liburing.h> |
| 1085 | #include <linux/errqueue.h> |
| 1086 | |
| 1087 | int main(void) { return 0; }''' |
| 1088 | |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1089 | linux_io_uring = not_found |
Paolo Bonzini | 53c22b6 | 2021-06-03 11:31:35 +0200 | [diff] [blame] | 1090 | if not get_option('linux_io_uring').auto() or have_block |
Daniel P. Berrangé | a41b4fd | 2022-01-05 13:49:38 +0000 | [diff] [blame] | 1091 | linux_io_uring = dependency('liburing', version: '>=0.3', |
| 1092 | required: get_option('linux_io_uring'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1093 | method: 'pkg-config') |
Leonardo Bras | 354081d | 2022-05-13 03:28:30 -0300 | [diff] [blame] | 1094 | if not cc.links(linux_io_uring_test) |
| 1095 | linux_io_uring = not_found |
| 1096 | endif |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1097 | endif |
Leonardo Bras | 354081d | 2022-05-13 03:28:30 -0300 | [diff] [blame] | 1098 | |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1099 | libnfs = not_found |
Paolo Bonzini | 30045c0 | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 1100 | if not get_option('libnfs').auto() or have_block |
| 1101 | libnfs = dependency('libnfs', version: '>=1.9.3', |
| 1102 | required: get_option('libnfs'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1103 | method: 'pkg-config') |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1104 | endif |
Paolo Bonzini | f7f2d65 | 2020-11-17 14:45:24 +0100 | [diff] [blame] | 1105 | |
| 1106 | libattr_test = ''' |
| 1107 | #include <stddef.h> |
| 1108 | #include <sys/types.h> |
| 1109 | #ifdef CONFIG_LIBATTR |
| 1110 | #include <attr/xattr.h> |
| 1111 | #else |
| 1112 | #include <sys/xattr.h> |
| 1113 | #endif |
| 1114 | int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }''' |
| 1115 | |
Marc-André Lureau | ec0d589 | 2019-07-15 15:04:49 +0400 | [diff] [blame] | 1116 | libattr = not_found |
Paolo Bonzini | f7f2d65 | 2020-11-17 14:45:24 +0100 | [diff] [blame] | 1117 | have_old_libattr = false |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 1118 | if get_option('attr').allowed() |
Paolo Bonzini | f7f2d65 | 2020-11-17 14:45:24 +0100 | [diff] [blame] | 1119 | if cc.links(libattr_test) |
| 1120 | libattr = declare_dependency() |
| 1121 | else |
| 1122 | libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1123 | required: get_option('attr')) |
Paolo Bonzini | f7f2d65 | 2020-11-17 14:45:24 +0100 | [diff] [blame] | 1124 | if libattr.found() and not \ |
| 1125 | cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR') |
| 1126 | libattr = not_found |
| 1127 | if get_option('attr').enabled() |
| 1128 | error('could not link libattr') |
| 1129 | else |
| 1130 | warning('could not link libattr, disabling') |
| 1131 | endif |
| 1132 | else |
| 1133 | have_old_libattr = libattr.found() |
| 1134 | endif |
| 1135 | endif |
Marc-André Lureau | ec0d589 | 2019-07-15 15:04:49 +0400 | [diff] [blame] | 1136 | endif |
Paolo Bonzini | f7f2d65 | 2020-11-17 14:45:24 +0100 | [diff] [blame] | 1137 | |
Akihiko Odaki | d2277f0 | 2024-07-15 14:25:44 +0900 | [diff] [blame] | 1138 | cocoa = dependency('appleframeworks', |
| 1139 | modules: ['Cocoa', 'CoreVideo', 'QuartzCore'], |
Akihiko Odaki | 52eaefd | 2022-07-02 23:25:19 +0900 | [diff] [blame] | 1140 | required: get_option('cocoa')) |
Paolo Bonzini | c1ec494 | 2021-01-07 14:04:00 +0100 | [diff] [blame] | 1141 | |
Vladislav Yaroshchuk | e2c1d78 | 2022-03-17 20:28:33 +0300 | [diff] [blame] | 1142 | vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet')) |
| 1143 | if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h', |
| 1144 | 'VMNET_BRIDGED_MODE', |
| 1145 | dependencies: vmnet) |
| 1146 | vmnet = not_found |
| 1147 | if get_option('vmnet').enabled() |
| 1148 | error('vmnet.framework API is outdated') |
| 1149 | else |
| 1150 | warning('vmnet.framework API is outdated, disabling') |
| 1151 | endif |
| 1152 | endif |
| 1153 | |
Paolo Bonzini | 3f99cf5 | 2020-02-05 09:45:39 +0100 | [diff] [blame] | 1154 | seccomp = not_found |
Michal Privoznik | 73422d9 | 2022-10-26 09:30:24 +0200 | [diff] [blame] | 1155 | seccomp_has_sysrawrc = false |
Paolo Bonzini | 90835c2 | 2020-11-17 14:22:24 +0100 | [diff] [blame] | 1156 | if not get_option('seccomp').auto() or have_system or have_tools |
| 1157 | seccomp = dependency('libseccomp', version: '>=2.3.0', |
| 1158 | required: get_option('seccomp'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1159 | method: 'pkg-config') |
Michal Privoznik | 73422d9 | 2022-10-26 09:30:24 +0200 | [diff] [blame] | 1160 | if seccomp.found() |
| 1161 | seccomp_has_sysrawrc = cc.has_header_symbol('seccomp.h', |
| 1162 | 'SCMP_FLTATR_API_SYSRAWRC', |
| 1163 | dependencies: seccomp) |
| 1164 | endif |
Paolo Bonzini | 3f99cf5 | 2020-02-05 09:45:39 +0100 | [diff] [blame] | 1165 | endif |
Paolo Bonzini | 727c8bb | 2020-11-17 14:46:58 +0100 | [diff] [blame] | 1166 | |
Paolo Bonzini | 3f99cf5 | 2020-02-05 09:45:39 +0100 | [diff] [blame] | 1167 | libcap_ng = not_found |
Paolo Bonzini | 727c8bb | 2020-11-17 14:46:58 +0100 | [diff] [blame] | 1168 | if not get_option('cap_ng').auto() or have_system or have_tools |
| 1169 | libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1170 | required: get_option('cap_ng')) |
Paolo Bonzini | 3f99cf5 | 2020-02-05 09:45:39 +0100 | [diff] [blame] | 1171 | endif |
Paolo Bonzini | 727c8bb | 2020-11-17 14:46:58 +0100 | [diff] [blame] | 1172 | if libcap_ng.found() and not cc.links(''' |
| 1173 | #include <cap-ng.h> |
| 1174 | int main(void) |
| 1175 | { |
| 1176 | capng_capability_to_name(CAPNG_EFFECTIVE); |
| 1177 | return 0; |
| 1178 | }''', dependencies: libcap_ng) |
| 1179 | libcap_ng = not_found |
| 1180 | if get_option('cap_ng').enabled() |
| 1181 | error('could not link libcap-ng') |
| 1182 | else |
| 1183 | warning('could not link libcap-ng, disabling') |
| 1184 | endif |
| 1185 | endif |
| 1186 | |
Paolo Bonzini | 1917ec6 | 2020-08-26 03:24:11 -0400 | [diff] [blame] | 1187 | if get_option('xkbcommon').auto() and not have_system and not have_tools |
| 1188 | xkbcommon = not_found |
| 1189 | else |
| 1190 | xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1191 | method: 'pkg-config') |
Marc-André Lureau | ade60d4 | 2019-07-15 14:48:31 +0400 | [diff] [blame] | 1192 | endif |
Paolo Bonzini | e172399 | 2021-10-07 15:08:21 +0200 | [diff] [blame] | 1193 | |
Thomas Huth | 5890258 | 2022-04-08 18:20:47 +0200 | [diff] [blame] | 1194 | slirp = not_found |
| 1195 | if not get_option('slirp').auto() or have_system |
| 1196 | slirp = dependency('slirp', required: get_option('slirp'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1197 | method: 'pkg-config') |
Thomas Huth | 5890258 | 2022-04-08 18:20:47 +0200 | [diff] [blame] | 1198 | # slirp < 4.7 is incompatible with CFI support in QEMU. This is because |
| 1199 | # it passes function pointers within libslirp as callbacks for timers. |
| 1200 | # When using a system-wide shared libslirp, the type information for the |
| 1201 | # callback is missing and the timer call produces a false positive with CFI. |
| 1202 | # Do not use the "version" keyword argument to produce a better error. |
| 1203 | # with control-flow integrity. |
| 1204 | if get_option('cfi') and slirp.found() and slirp.version().version_compare('<4.7') |
| 1205 | if get_option('slirp').enabled() |
| 1206 | error('Control-Flow Integrity requires libslirp 4.7.') |
| 1207 | else |
| 1208 | warning('Cannot use libslirp since Control-Flow Integrity requires libslirp >= 4.7.') |
| 1209 | slirp = not_found |
| 1210 | endif |
| 1211 | endif |
| 1212 | endif |
| 1213 | |
Marc-André Lureau | cdaf072 | 2019-07-22 23:47:50 +0400 | [diff] [blame] | 1214 | vde = not_found |
Paolo Bonzini | e172399 | 2021-10-07 15:08:21 +0200 | [diff] [blame] | 1215 | if not get_option('vde').auto() or have_system or have_tools |
| 1216 | vde = cc.find_library('vdeplug', has_headers: ['libvdeplug.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1217 | required: get_option('vde')) |
Paolo Bonzini | e172399 | 2021-10-07 15:08:21 +0200 | [diff] [blame] | 1218 | endif |
| 1219 | if vde.found() and not cc.links(''' |
| 1220 | #include <libvdeplug.h> |
| 1221 | int main(void) |
| 1222 | { |
| 1223 | struct vde_open_args a = {0, 0, 0}; |
| 1224 | char s[] = ""; |
| 1225 | vde_open(s, s, &a); |
| 1226 | return 0; |
| 1227 | }''', dependencies: vde) |
| 1228 | vde = not_found |
| 1229 | if get_option('cap_ng').enabled() |
| 1230 | error('could not link libvdeplug') |
| 1231 | else |
| 1232 | warning('could not link libvdeplug, disabling') |
| 1233 | endif |
Marc-André Lureau | cdaf072 | 2019-07-22 23:47:50 +0400 | [diff] [blame] | 1234 | endif |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1235 | |
Paolo Bonzini | 478e943 | 2020-08-17 12:47:55 +0200 | [diff] [blame] | 1236 | pulse = not_found |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1237 | if not get_option('pa').auto() or (host_os == 'linux' and have_system) |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1238 | pulse = dependency('libpulse', required: get_option('pa'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1239 | method: 'pkg-config') |
Paolo Bonzini | 478e943 | 2020-08-17 12:47:55 +0200 | [diff] [blame] | 1240 | endif |
| 1241 | alsa = not_found |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1242 | if not get_option('alsa').auto() or (host_os == 'linux' and have_system) |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1243 | alsa = dependency('alsa', required: get_option('alsa'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1244 | method: 'pkg-config') |
Paolo Bonzini | 478e943 | 2020-08-17 12:47:55 +0200 | [diff] [blame] | 1245 | endif |
| 1246 | jack = not_found |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1247 | if not get_option('jack').auto() or have_system |
| 1248 | jack = dependency('jack', required: get_option('jack'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1249 | method: 'pkg-config') |
Paolo Bonzini | 478e943 | 2020-08-17 12:47:55 +0200 | [diff] [blame] | 1250 | endif |
Dorinda Bassey | c2d3d1c | 2023-04-17 12:56:54 +0200 | [diff] [blame] | 1251 | pipewire = not_found |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1252 | if not get_option('pipewire').auto() or (host_os == 'linux' and have_system) |
Dorinda Bassey | c2d3d1c | 2023-04-17 12:56:54 +0200 | [diff] [blame] | 1253 | pipewire = dependency('libpipewire-0.3', version: '>=0.3.60', |
| 1254 | required: get_option('pipewire'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1255 | method: 'pkg-config') |
Dorinda Bassey | c2d3d1c | 2023-04-17 12:56:54 +0200 | [diff] [blame] | 1256 | endif |
Alexandre Ratchov | 663df1c | 2022-09-07 15:23:42 +0200 | [diff] [blame] | 1257 | sndio = not_found |
| 1258 | if not get_option('sndio').auto() or have_system |
| 1259 | sndio = dependency('sndio', required: get_option('sndio'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1260 | method: 'pkg-config') |
Alexandre Ratchov | 663df1c | 2022-09-07 15:23:42 +0200 | [diff] [blame] | 1261 | endif |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1262 | |
Gerd Hoffmann | 58d3f3f | 2021-05-19 07:39:32 +0200 | [diff] [blame] | 1263 | spice_protocol = not_found |
Marc-André Lureau | 3f0a5d5 | 2021-10-07 15:08:23 +0200 | [diff] [blame] | 1264 | if not get_option('spice_protocol').auto() or have_system |
Markus Armbruster | 5c167b5 | 2023-01-09 20:03:07 +0100 | [diff] [blame] | 1265 | spice_protocol = dependency('spice-protocol', version: '>=0.14.0', |
Marc-André Lureau | 3f0a5d5 | 2021-10-07 15:08:23 +0200 | [diff] [blame] | 1266 | required: get_option('spice_protocol'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1267 | method: 'pkg-config') |
Paolo Bonzini | 2634733 | 2019-07-29 15:40:07 +0200 | [diff] [blame] | 1268 | endif |
Marc-André Lureau | 3f0a5d5 | 2021-10-07 15:08:23 +0200 | [diff] [blame] | 1269 | spice = not_found |
Marc-André Lureau | c98791e | 2023-08-30 13:38:35 +0400 | [diff] [blame] | 1270 | if get_option('spice') \ |
| 1271 | .disable_auto_if(not have_system) \ |
| 1272 | .require(pixman.found(), |
| 1273 | error_message: 'cannot enable SPICE if pixman is not available') \ |
| 1274 | .allowed() |
Markus Armbruster | 34d5572 | 2023-01-09 20:03:09 +0100 | [diff] [blame] | 1275 | spice = dependency('spice-server', version: '>=0.14.0', |
Marc-André Lureau | 3f0a5d5 | 2021-10-07 15:08:23 +0200 | [diff] [blame] | 1276 | required: get_option('spice'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1277 | method: 'pkg-config') |
Gerd Hoffmann | 58d3f3f | 2021-05-19 07:39:32 +0200 | [diff] [blame] | 1278 | endif |
Marc-André Lureau | 3f0a5d5 | 2021-10-07 15:08:23 +0200 | [diff] [blame] | 1279 | spice_headers = spice.partial_dependency(compile_args: true, includes: true) |
| 1280 | |
Marc-André Lureau | 5ee24e7 | 2019-07-12 23:16:54 +0400 | [diff] [blame] | 1281 | rt = cc.find_library('rt', required: false) |
Paolo Bonzini | a399f91 | 2021-11-15 14:29:13 +0000 | [diff] [blame] | 1282 | |
Paolo Bonzini | 99650b6 | 2019-06-10 12:21:14 +0200 | [diff] [blame] | 1283 | libiscsi = not_found |
Paolo Bonzini | 9db405a | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 1284 | if not get_option('libiscsi').auto() or have_block |
| 1285 | libiscsi = dependency('libiscsi', version: '>=1.9.0', |
| 1286 | required: get_option('libiscsi'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1287 | method: 'pkg-config') |
Paolo Bonzini | 99650b6 | 2019-06-10 12:21:14 +0200 | [diff] [blame] | 1288 | endif |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1289 | zstd = not_found |
Paolo Bonzini | b1def33 | 2020-11-17 13:37:39 +0100 | [diff] [blame] | 1290 | if not get_option('zstd').auto() or have_block |
| 1291 | zstd = dependency('libzstd', version: '>=1.4.0', |
| 1292 | required: get_option('zstd'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1293 | method: 'pkg-config') |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1294 | endif |
Yuan Liu | b844a2c | 2024-06-10 18:21:06 +0800 | [diff] [blame] | 1295 | qpl = not_found |
| 1296 | if not get_option('qpl').auto() or have_system |
| 1297 | qpl = dependency('qpl', version: '>=1.5.0', |
| 1298 | required: get_option('qpl'), |
| 1299 | method: 'pkg-config') |
| 1300 | endif |
Shameer Kolothum | cfc589a | 2024-06-07 14:53:05 +0100 | [diff] [blame] | 1301 | uadk = not_found |
| 1302 | if not get_option('uadk').auto() or have_system |
| 1303 | libwd = dependency('libwd', version: '>=2.6', |
| 1304 | required: get_option('uadk'), |
| 1305 | method: 'pkg-config') |
| 1306 | libwd_comp = dependency('libwd_comp', version: '>=2.6', |
| 1307 | required: get_option('uadk'), |
| 1308 | method: 'pkg-config') |
| 1309 | if libwd.found() and libwd_comp.found() |
| 1310 | uadk = declare_dependency(dependencies: [libwd, libwd_comp]) |
| 1311 | endif |
| 1312 | endif |
Bryan Zhang | e28ed31 | 2024-08-30 16:27:19 -0700 | [diff] [blame] | 1313 | |
| 1314 | qatzip = not_found |
| 1315 | if not get_option('qatzip').auto() or have_system |
| 1316 | qatzip = dependency('qatzip', version: '>=1.1.2', |
| 1317 | required: get_option('qatzip'), |
| 1318 | method: 'pkg-config') |
| 1319 | endif |
| 1320 | |
Marc-André Lureau | ea45896 | 2019-07-12 22:23:46 +0400 | [diff] [blame] | 1321 | virgl = not_found |
Paolo Bonzini | 0265fe9 | 2021-12-17 12:36:26 +0100 | [diff] [blame] | 1322 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1323 | have_vhost_user_gpu = have_tools and host_os == 'linux' and pixman.found() |
Paolo Bonzini | 0265fe9 | 2021-12-17 12:36:26 +0100 | [diff] [blame] | 1324 | if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu |
Paolo Bonzini | 587d59d | 2021-06-03 11:31:35 +0200 | [diff] [blame] | 1325 | virgl = dependency('virglrenderer', |
| 1326 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1327 | required: get_option('virglrenderer')) |
Marc-André Lureau | ea45896 | 2019-07-12 22:23:46 +0400 | [diff] [blame] | 1328 | endif |
Gurchetan Singh | cd9adbe | 2023-03-21 09:47:36 -0700 | [diff] [blame] | 1329 | rutabaga = not_found |
| 1330 | if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu |
| 1331 | rutabaga = dependency('rutabaga_gfx_ffi', |
| 1332 | method: 'pkg-config', |
| 1333 | required: get_option('rutabaga_gfx')) |
| 1334 | endif |
Stefan Hajnoczi | fd66dbd | 2022-10-13 14:58:57 -0400 | [diff] [blame] | 1335 | blkio = not_found |
| 1336 | if not get_option('blkio').auto() or have_block |
| 1337 | blkio = dependency('blkio', |
| 1338 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1339 | required: get_option('blkio')) |
Stefan Hajnoczi | fd66dbd | 2022-10-13 14:58:57 -0400 | [diff] [blame] | 1340 | endif |
Marc-André Lureau | 1d7bb6a | 2019-07-12 23:47:06 +0400 | [diff] [blame] | 1341 | curl = not_found |
Paolo Bonzini | f9cd86f | 2020-11-17 12:43:15 +0100 | [diff] [blame] | 1342 | if not get_option('curl').auto() or have_block |
| 1343 | curl = dependency('libcurl', version: '>=7.29.0', |
| 1344 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1345 | required: get_option('curl')) |
Marc-André Lureau | 1d7bb6a | 2019-07-12 23:47:06 +0400 | [diff] [blame] | 1346 | endif |
Paolo Bonzini | f15bff2 | 2019-07-18 13:19:02 +0200 | [diff] [blame] | 1347 | libudev = not_found |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1348 | if host_os == 'linux' and (have_system or have_tools) |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 1349 | libudev = dependency('libudev', |
Paolo Bonzini | a0fbbb6 | 2020-11-17 12:36:15 +0100 | [diff] [blame] | 1350 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1351 | required: get_option('libudev')) |
Paolo Bonzini | f15bff2 | 2019-07-18 13:19:02 +0200 | [diff] [blame] | 1352 | endif |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 1353 | |
Paolo Bonzini | 5c53015 | 2020-10-15 06:09:27 -0400 | [diff] [blame] | 1354 | mpathlibs = [libudev] |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 1355 | mpathpersist = not_found |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1356 | if host_os == 'linux' and have_tools and get_option('mpath').allowed() |
Philippe Mathieu-Daudé | 6b40847 | 2023-06-05 19:41:45 +0200 | [diff] [blame] | 1357 | mpath_test_source = ''' |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 1358 | #include <libudev.h> |
| 1359 | #include <mpath_persist.h> |
| 1360 | unsigned mpath_mx_alloc_len = 1024; |
| 1361 | int logsink; |
| 1362 | static struct config *multipath_conf; |
| 1363 | extern struct udev *udev; |
| 1364 | extern struct config *get_multipath_config(void); |
| 1365 | extern void put_multipath_config(struct config *conf); |
| 1366 | struct udev *udev; |
| 1367 | struct config *get_multipath_config(void) { return multipath_conf; } |
| 1368 | void put_multipath_config(struct config *conf) { } |
| 1369 | int main(void) { |
| 1370 | udev = udev_new(); |
| 1371 | multipath_conf = mpath_lib_init(); |
| 1372 | return 0; |
| 1373 | }''' |
Paolo Bonzini | 5c53015 | 2020-10-15 06:09:27 -0400 | [diff] [blame] | 1374 | libmpathpersist = cc.find_library('mpathpersist', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1375 | required: get_option('mpath')) |
Paolo Bonzini | 5c53015 | 2020-10-15 06:09:27 -0400 | [diff] [blame] | 1376 | if libmpathpersist.found() |
| 1377 | mpathlibs += libmpathpersist |
Paolo Bonzini | a0cbd2e | 2022-07-14 14:33:49 +0200 | [diff] [blame] | 1378 | if get_option('prefer_static') |
Paolo Bonzini | 5c53015 | 2020-10-15 06:09:27 -0400 | [diff] [blame] | 1379 | mpathlibs += cc.find_library('devmapper', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1380 | required: get_option('mpath')) |
Paolo Bonzini | 43b43a4 | 2020-09-17 12:25:09 +0200 | [diff] [blame] | 1381 | endif |
Paolo Bonzini | 5c53015 | 2020-10-15 06:09:27 -0400 | [diff] [blame] | 1382 | mpathlibs += cc.find_library('multipath', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1383 | required: get_option('mpath')) |
Paolo Bonzini | 5c53015 | 2020-10-15 06:09:27 -0400 | [diff] [blame] | 1384 | foreach lib: mpathlibs |
| 1385 | if not lib.found() |
| 1386 | mpathlibs = [] |
| 1387 | break |
| 1388 | endif |
| 1389 | endforeach |
| 1390 | if mpathlibs.length() == 0 |
| 1391 | msg = 'Dependencies missing for libmpathpersist' |
Philippe Mathieu-Daudé | 6b40847 | 2023-06-05 19:41:45 +0200 | [diff] [blame] | 1392 | elif cc.links(mpath_test_source, dependencies: mpathlibs) |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 1393 | mpathpersist = declare_dependency(dependencies: mpathlibs) |
| 1394 | else |
Paolo Bonzini | 5c53015 | 2020-10-15 06:09:27 -0400 | [diff] [blame] | 1395 | msg = 'Cannot detect libmpathpersist API' |
| 1396 | endif |
| 1397 | if not mpathpersist.found() |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 1398 | if get_option('mpath').enabled() |
Paolo Bonzini | 5c53015 | 2020-10-15 06:09:27 -0400 | [diff] [blame] | 1399 | error(msg) |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 1400 | else |
Paolo Bonzini | 5c53015 | 2020-10-15 06:09:27 -0400 | [diff] [blame] | 1401 | warning(msg + ', disabling') |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 1402 | endif |
| 1403 | endif |
| 1404 | endif |
| 1405 | endif |
| 1406 | |
Yonggang Luo | 5285e59 | 2020-10-13 07:43:48 +0800 | [diff] [blame] | 1407 | iconv = not_found |
Yonggang Luo | 5285e59 | 2020-10-13 07:43:48 +0800 | [diff] [blame] | 1408 | curses = not_found |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 1409 | if have_system and get_option('curses').allowed() |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1410 | curses_test = ''' |
Brad Smith | f8d3116 | 2024-10-11 23:38:55 -0400 | [diff] [blame] | 1411 | #ifdef __APPLE__ |
Stefan Weil | fbab8cc | 2021-11-17 21:53:55 +0100 | [diff] [blame] | 1412 | #define _XOPEN_SOURCE_EXTENDED 1 |
| 1413 | #endif |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1414 | #include <locale.h> |
| 1415 | #include <curses.h> |
| 1416 | #include <wchar.h> |
| 1417 | int main(void) { |
| 1418 | wchar_t wch = L'w'; |
| 1419 | setlocale(LC_ALL, ""); |
| 1420 | resize_term(0, 0); |
| 1421 | addwstr(L"wide chars\n"); |
| 1422 | addnwstr(&wch, 1); |
| 1423 | add_wch(WACS_DEGREE); |
| 1424 | return 0; |
| 1425 | }''' |
| 1426 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1427 | curses_dep_list = host_os == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw'] |
Paolo Bonzini | 6d32263 | 2022-03-27 16:05:58 +0200 | [diff] [blame] | 1428 | curses = dependency(curses_dep_list, |
| 1429 | required: false, |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1430 | method: 'pkg-config') |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1431 | msg = get_option('curses').enabled() ? 'curses library not found' : '' |
Stefan Weil | fbab8cc | 2021-11-17 21:53:55 +0100 | [diff] [blame] | 1432 | curses_compile_args = ['-DNCURSES_WIDECHAR=1'] |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1433 | if curses.found() |
Paolo Bonzini | 0dbce6e | 2020-11-30 08:07:48 -0500 | [diff] [blame] | 1434 | if cc.links(curses_test, args: curses_compile_args, dependencies: [curses]) |
Paolo Bonzini | bd3615d | 2023-03-30 12:45:58 +0200 | [diff] [blame] | 1435 | curses = declare_dependency(compile_args: curses_compile_args, dependencies: [curses], |
| 1436 | version: curses.version()) |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1437 | else |
| 1438 | msg = 'curses package not usable' |
| 1439 | curses = not_found |
Yonggang Luo | 5285e59 | 2020-10-13 07:43:48 +0800 | [diff] [blame] | 1440 | endif |
| 1441 | endif |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1442 | if not curses.found() |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1443 | has_curses_h = cc.has_header('curses.h', args: curses_compile_args) |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1444 | if host_os != 'windows' and not has_curses_h |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1445 | message('Trying with /usr/include/ncursesw') |
| 1446 | curses_compile_args += ['-I/usr/include/ncursesw'] |
| 1447 | has_curses_h = cc.has_header('curses.h', args: curses_compile_args) |
| 1448 | endif |
| 1449 | if has_curses_h |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1450 | curses_libname_list = (host_os == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw']) |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1451 | foreach curses_libname : curses_libname_list |
Yonggang Luo | 5285e59 | 2020-10-13 07:43:48 +0800 | [diff] [blame] | 1452 | libcurses = cc.find_library(curses_libname, |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1453 | required: false) |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1454 | if libcurses.found() |
| 1455 | if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses) |
| 1456 | curses = declare_dependency(compile_args: curses_compile_args, |
| 1457 | dependencies: [libcurses]) |
| 1458 | break |
| 1459 | else |
| 1460 | msg = 'curses library not usable' |
| 1461 | endif |
Yonggang Luo | 5285e59 | 2020-10-13 07:43:48 +0800 | [diff] [blame] | 1462 | endif |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1463 | endforeach |
| 1464 | endif |
| 1465 | endif |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 1466 | if get_option('iconv').allowed() |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1467 | foreach link_args : [ ['-liconv'], [] ] |
| 1468 | # Programs will be linked with glib and this will bring in libiconv on FreeBSD. |
| 1469 | # We need to use libiconv if available because mixing libiconv's headers with |
| 1470 | # the system libc does not work. |
| 1471 | # However, without adding glib to the dependencies -L/usr/local/lib will not be |
| 1472 | # included in the command line and libiconv will not be found. |
| 1473 | if cc.links(''' |
| 1474 | #include <iconv.h> |
| 1475 | int main(void) { |
| 1476 | iconv_t conv = iconv_open("WCHAR_T", "UCS-2"); |
| 1477 | return conv != (iconv_t) -1; |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 1478 | }''', args: link_args, dependencies: glib) |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1479 | iconv = declare_dependency(link_args: link_args, dependencies: glib) |
| 1480 | break |
Yonggang Luo | 5285e59 | 2020-10-13 07:43:48 +0800 | [diff] [blame] | 1481 | endif |
Paolo Bonzini | 30fe76b | 2020-10-15 13:26:50 -0400 | [diff] [blame] | 1482 | endforeach |
| 1483 | endif |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1484 | if curses.found() and not iconv.found() |
| 1485 | if get_option('iconv').enabled() |
| 1486 | error('iconv not available') |
| 1487 | endif |
| 1488 | msg = 'iconv required for curses UI but not available' |
| 1489 | curses = not_found |
| 1490 | endif |
| 1491 | if not curses.found() and msg != '' |
| 1492 | if get_option('curses').enabled() |
| 1493 | error(msg) |
Paolo Bonzini | 30fe76b | 2020-10-15 13:26:50 -0400 | [diff] [blame] | 1494 | else |
Paolo Bonzini | 925a40d | 2020-10-19 04:42:11 -0400 | [diff] [blame] | 1495 | warning(msg + ', disabling') |
Paolo Bonzini | 30fe76b | 2020-10-15 13:26:50 -0400 | [diff] [blame] | 1496 | endif |
Yonggang Luo | 5285e59 | 2020-10-13 07:43:48 +0800 | [diff] [blame] | 1497 | endif |
| 1498 | endif |
| 1499 | |
Paolo Bonzini | 2634733 | 2019-07-29 15:40:07 +0200 | [diff] [blame] | 1500 | brlapi = not_found |
Paolo Bonzini | 8c6d4ff | 2020-11-17 13:02:17 +0100 | [diff] [blame] | 1501 | if not get_option('brlapi').auto() or have_system |
| 1502 | brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1503 | required: get_option('brlapi')) |
Paolo Bonzini | 8c6d4ff | 2020-11-17 13:02:17 +0100 | [diff] [blame] | 1504 | if brlapi.found() and not cc.links(''' |
| 1505 | #include <brlapi.h> |
| 1506 | #include <stddef.h> |
| 1507 | int main(void) { return brlapi__openConnection (NULL, NULL, NULL); }''', dependencies: brlapi) |
| 1508 | brlapi = not_found |
| 1509 | if get_option('brlapi').enabled() |
| 1510 | error('could not link brlapi') |
| 1511 | else |
| 1512 | warning('could not link brlapi, disabling') |
| 1513 | endif |
| 1514 | endif |
Paolo Bonzini | 2634733 | 2019-07-29 15:40:07 +0200 | [diff] [blame] | 1515 | endif |
Paolo Bonzini | 35be72b | 2020-02-06 14:17:15 +0100 | [diff] [blame] | 1516 | |
Paolo Bonzini | 760e432 | 2020-08-26 08:09:48 +0200 | [diff] [blame] | 1517 | sdl = not_found |
Akihiko Odaki | 64d3fec | 2022-08-19 22:27:56 +0900 | [diff] [blame] | 1518 | if not get_option('sdl').auto() or have_system |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1519 | sdl = dependency('sdl2', required: get_option('sdl')) |
Paolo Bonzini | 760e432 | 2020-08-26 08:09:48 +0200 | [diff] [blame] | 1520 | sdl_image = not_found |
| 1521 | endif |
Paolo Bonzini | 35be72b | 2020-02-06 14:17:15 +0100 | [diff] [blame] | 1522 | if sdl.found() |
Thomas Huth | 6da5f22 | 2023-06-05 13:45:23 +0200 | [diff] [blame] | 1523 | # Some versions of SDL have problems with -Wundef |
| 1524 | if not cc.compiles(''' |
| 1525 | #include <SDL.h> |
| 1526 | #include <SDL_syswm.h> |
| 1527 | int main(int argc, char *argv[]) { return 0; } |
| 1528 | ''', dependencies: sdl, args: '-Werror=undef') |
| 1529 | sdl = declare_dependency(compile_args: '-Wno-undef', |
| 1530 | dependencies: sdl, |
| 1531 | version: sdl.version()) |
| 1532 | endif |
Volker Rümelin | 7161a43 | 2020-08-29 12:41:58 +0200 | [diff] [blame] | 1533 | sdl_image = dependency('SDL2_image', required: get_option('sdl_image'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1534 | method: 'pkg-config') |
Paolo Bonzini | 35be72b | 2020-02-06 14:17:15 +0100 | [diff] [blame] | 1535 | else |
| 1536 | if get_option('sdl_image').enabled() |
Sergei Trofimovich | a8dc2ac | 2020-09-08 08:40:16 +0100 | [diff] [blame] | 1537 | error('sdl-image required, but SDL was @0@'.format( |
| 1538 | get_option('sdl').disabled() ? 'disabled' : 'not found')) |
Paolo Bonzini | 35be72b | 2020-02-06 14:17:15 +0100 | [diff] [blame] | 1539 | endif |
| 1540 | sdl_image = not_found |
Paolo Bonzini | 2634733 | 2019-07-29 15:40:07 +0200 | [diff] [blame] | 1541 | endif |
Paolo Bonzini | 35be72b | 2020-02-06 14:17:15 +0100 | [diff] [blame] | 1542 | |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1543 | rbd = not_found |
Paolo Bonzini | fabd1e9 | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 1544 | if not get_option('rbd').auto() or have_block |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1545 | librados = cc.find_library('rados', required: get_option('rbd')) |
Paolo Bonzini | fabd1e9 | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 1546 | librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1547 | required: get_option('rbd')) |
Paolo Bonzini | c518d6c | 2021-01-26 11:20:35 +0100 | [diff] [blame] | 1548 | if librados.found() and librbd.found() |
| 1549 | if cc.links(''' |
| 1550 | #include <stdio.h> |
| 1551 | #include <rbd/librbd.h> |
| 1552 | int main(void) { |
| 1553 | rados_t cluster; |
| 1554 | rados_create(&cluster, NULL); |
Peter Lieven | 48672ac | 2021-07-02 19:23:51 +0200 | [diff] [blame] | 1555 | #if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 12, 0) |
| 1556 | #error |
| 1557 | #endif |
Paolo Bonzini | c518d6c | 2021-01-26 11:20:35 +0100 | [diff] [blame] | 1558 | return 0; |
| 1559 | }''', dependencies: [librbd, librados]) |
| 1560 | rbd = declare_dependency(dependencies: [librbd, librados]) |
| 1561 | elif get_option('rbd').enabled() |
Peter Lieven | 48672ac | 2021-07-02 19:23:51 +0200 | [diff] [blame] | 1562 | error('librbd >= 1.12.0 required') |
Paolo Bonzini | c518d6c | 2021-01-26 11:20:35 +0100 | [diff] [blame] | 1563 | else |
Peter Lieven | 48672ac | 2021-07-02 19:23:51 +0200 | [diff] [blame] | 1564 | warning('librbd >= 1.12.0 not found, disabling') |
Paolo Bonzini | c518d6c | 2021-01-26 11:20:35 +0100 | [diff] [blame] | 1565 | endif |
Paolo Bonzini | fabd1e9 | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 1566 | endif |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1567 | endif |
Paolo Bonzini | fabd1e9 | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 1568 | |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1569 | glusterfs = not_found |
Paolo Bonzini | 08821ca | 2020-11-17 13:01:26 +0100 | [diff] [blame] | 1570 | glusterfs_ftruncate_has_stat = false |
| 1571 | glusterfs_iocb_has_stat = false |
| 1572 | if not get_option('glusterfs').auto() or have_block |
| 1573 | glusterfs = dependency('glusterfs-api', version: '>=3', |
| 1574 | required: get_option('glusterfs'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1575 | method: 'pkg-config') |
Paolo Bonzini | 08821ca | 2020-11-17 13:01:26 +0100 | [diff] [blame] | 1576 | if glusterfs.found() |
| 1577 | glusterfs_ftruncate_has_stat = cc.links(''' |
| 1578 | #include <glusterfs/api/glfs.h> |
| 1579 | |
| 1580 | int |
| 1581 | main(void) |
| 1582 | { |
| 1583 | /* new glfs_ftruncate() passes two additional args */ |
| 1584 | return glfs_ftruncate(NULL, 0, NULL, NULL); |
| 1585 | } |
| 1586 | ''', dependencies: glusterfs) |
| 1587 | glusterfs_iocb_has_stat = cc.links(''' |
| 1588 | #include <glusterfs/api/glfs.h> |
| 1589 | |
| 1590 | /* new glfs_io_cbk() passes two additional glfs_stat structs */ |
| 1591 | static void |
| 1592 | glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data) |
| 1593 | {} |
| 1594 | |
| 1595 | int |
| 1596 | main(void) |
| 1597 | { |
| 1598 | glfs_io_cbk iocb = &glusterfs_iocb; |
| 1599 | iocb(NULL, 0 , NULL, NULL, NULL); |
| 1600 | return 0; |
| 1601 | } |
| 1602 | ''', dependencies: glusterfs) |
| 1603 | endif |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1604 | endif |
Thomas Huth | e6a52b3 | 2021-12-09 15:48:01 +0100 | [diff] [blame] | 1605 | |
Maciej S. Szmigiero | 0d9e8c0 | 2023-06-12 16:00:54 +0200 | [diff] [blame] | 1606 | hv_balloon = false |
| 1607 | if get_option('hv_balloon').allowed() and have_system |
| 1608 | if cc.links(''' |
| 1609 | #include <string.h> |
| 1610 | #include <gmodule.h> |
| 1611 | int main(void) { |
| 1612 | GTree *tree; |
| 1613 | |
| 1614 | tree = g_tree_new((GCompareFunc)strcmp); |
| 1615 | (void)g_tree_node_first(tree); |
| 1616 | g_tree_destroy(tree); |
| 1617 | return 0; |
| 1618 | } |
| 1619 | ''', dependencies: glib) |
| 1620 | hv_balloon = true |
| 1621 | else |
| 1622 | if get_option('hv_balloon').enabled() |
| 1623 | error('could not enable hv-balloon, update your glib') |
| 1624 | else |
| 1625 | warning('could not find glib support for hv-balloon, disabling') |
| 1626 | endif |
| 1627 | endif |
| 1628 | endif |
| 1629 | |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1630 | libssh = not_found |
Thomas Huth | e6a52b3 | 2021-12-09 15:48:01 +0100 | [diff] [blame] | 1631 | if not get_option('libssh').auto() or have_block |
| 1632 | libssh = dependency('libssh', version: '>=0.8.7', |
| 1633 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1634 | required: get_option('libssh')) |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1635 | endif |
Thomas Huth | e6a52b3 | 2021-12-09 15:48:01 +0100 | [diff] [blame] | 1636 | |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1637 | libbzip2 = not_found |
Paolo Bonzini | 29ba611 | 2020-11-17 13:07:52 +0100 | [diff] [blame] | 1638 | if not get_option('bzip2').auto() or have_block |
| 1639 | libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1640 | required: get_option('bzip2')) |
Paolo Bonzini | 29ba611 | 2020-11-17 13:07:52 +0100 | [diff] [blame] | 1641 | if libbzip2.found() and not cc.links(''' |
| 1642 | #include <bzlib.h> |
| 1643 | int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2) |
| 1644 | libbzip2 = not_found |
| 1645 | if get_option('bzip2').enabled() |
| 1646 | error('could not link libbzip2') |
| 1647 | else |
| 1648 | warning('could not link libbzip2, disabling') |
| 1649 | endif |
| 1650 | endif |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1651 | endif |
Paolo Bonzini | ecea369 | 2020-11-17 13:35:28 +0100 | [diff] [blame] | 1652 | |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1653 | liblzfse = not_found |
Paolo Bonzini | ecea369 | 2020-11-17 13:35:28 +0100 | [diff] [blame] | 1654 | if not get_option('lzfse').auto() or have_block |
| 1655 | liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1656 | required: get_option('lzfse')) |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 1657 | endif |
Paolo Bonzini | ecea369 | 2020-11-17 13:35:28 +0100 | [diff] [blame] | 1658 | if liblzfse.found() and not cc.links(''' |
| 1659 | #include <lzfse.h> |
| 1660 | int main(void) { lzfse_decode_scratch_size(); return 0; }''', dependencies: liblzfse) |
| 1661 | liblzfse = not_found |
| 1662 | if get_option('lzfse').enabled() |
| 1663 | error('could not link liblzfse') |
| 1664 | else |
| 1665 | warning('could not link liblzfse, disabling') |
| 1666 | endif |
| 1667 | endif |
| 1668 | |
Paolo Bonzini | 478e943 | 2020-08-17 12:47:55 +0200 | [diff] [blame] | 1669 | oss = not_found |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 1670 | if get_option('oss').allowed() and have_system |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1671 | if not cc.has_header('sys/soundcard.h') |
| 1672 | # not found |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1673 | elif host_os == 'netbsd' |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1674 | oss = cc.find_library('ossaudio', required: get_option('oss')) |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1675 | else |
| 1676 | oss = declare_dependency() |
| 1677 | endif |
| 1678 | |
| 1679 | if not oss.found() |
| 1680 | if get_option('oss').enabled() |
| 1681 | error('OSS not found') |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1682 | endif |
| 1683 | endif |
Paolo Bonzini | 478e943 | 2020-08-17 12:47:55 +0200 | [diff] [blame] | 1684 | endif |
| 1685 | dsound = not_found |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1686 | if not get_option('dsound').auto() or (host_os == 'windows' and have_system) |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1687 | if cc.has_header('dsound.h') |
| 1688 | dsound = declare_dependency(link_args: ['-lole32', '-ldxguid']) |
| 1689 | endif |
| 1690 | |
| 1691 | if not dsound.found() |
| 1692 | if get_option('dsound').enabled() |
| 1693 | error('DirectSound not found') |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1694 | endif |
| 1695 | endif |
Paolo Bonzini | 478e943 | 2020-08-17 12:47:55 +0200 | [diff] [blame] | 1696 | endif |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1697 | |
Paolo Bonzini | 478e943 | 2020-08-17 12:47:55 +0200 | [diff] [blame] | 1698 | coreaudio = not_found |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 1699 | if not get_option('coreaudio').auto() or (host_os == 'darwin' and have_system) |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 1700 | coreaudio = dependency('appleframeworks', modules: 'CoreAudio', |
| 1701 | required: get_option('coreaudio')) |
Paolo Bonzini | 478e943 | 2020-08-17 12:47:55 +0200 | [diff] [blame] | 1702 | endif |
Thomas Huth | 8bc5184 | 2021-07-13 13:09:02 +0200 | [diff] [blame] | 1703 | |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1704 | opengl = not_found |
Paolo Bonzini | 88b6e61 | 2022-04-20 17:33:40 +0200 | [diff] [blame] | 1705 | if not get_option('opengl').auto() or have_system or have_vhost_user_gpu |
| 1706 | epoxy = dependency('epoxy', method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1707 | required: get_option('opengl')) |
Paolo Bonzini | 88b6e61 | 2022-04-20 17:33:40 +0200 | [diff] [blame] | 1708 | if cc.has_header('epoxy/egl.h', dependencies: epoxy) |
| 1709 | opengl = epoxy |
| 1710 | elif get_option('opengl').enabled() |
| 1711 | error('epoxy/egl.h not found') |
| 1712 | endif |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1713 | endif |
Thomas Huth | 8bc5184 | 2021-07-13 13:09:02 +0200 | [diff] [blame] | 1714 | gbm = not_found |
| 1715 | if (have_system or have_tools) and (virgl.found() or opengl.found()) |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1716 | gbm = dependency('gbm', method: 'pkg-config', required: false) |
Thomas Huth | 8bc5184 | 2021-07-13 13:09:02 +0200 | [diff] [blame] | 1717 | endif |
Marc-André Lureau | f0caba4 | 2022-06-28 17:23:15 +0400 | [diff] [blame] | 1718 | have_vhost_user_gpu = have_vhost_user_gpu and virgl.found() and opengl.found() and gbm.found() |
Paolo Bonzini | 1b69547 | 2021-01-07 14:02:29 +0100 | [diff] [blame] | 1719 | |
Dorjoy Chowdhury | bb154e3 | 2024-10-09 03:17:23 +0600 | [diff] [blame] | 1720 | libcbor = not_found |
| 1721 | if not get_option('libcbor').auto() or have_system |
| 1722 | libcbor = dependency('libcbor', version: '>=0.7.0', |
| 1723 | required: get_option('libcbor')) |
| 1724 | endif |
| 1725 | |
Paolo Bonzini | 5761251 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 1726 | gnutls = not_found |
Daniel P. Berrangé | cc4c7c7 | 2021-06-30 17:20:02 +0100 | [diff] [blame] | 1727 | gnutls_crypto = not_found |
Alyssa Ross | abc14fd | 2021-08-06 14:49:47 +0000 | [diff] [blame] | 1728 | if get_option('gnutls').enabled() or (get_option('gnutls').auto() and have_system) |
Daniel P. Berrangé | cc4c7c7 | 2021-06-30 17:20:02 +0100 | [diff] [blame] | 1729 | # For general TLS support our min gnutls matches |
| 1730 | # that implied by our platform support matrix |
| 1731 | # |
| 1732 | # For the crypto backends, we look for a newer |
| 1733 | # gnutls: |
| 1734 | # |
| 1735 | # Version 3.6.8 is needed to get XTS |
| 1736 | # Version 3.6.13 is needed to get PBKDF |
| 1737 | # Version 3.6.14 is needed to get HW accelerated XTS |
| 1738 | # |
| 1739 | # If newer enough gnutls isn't available, we can |
| 1740 | # still use a different crypto backend to satisfy |
| 1741 | # the platform support requirements |
| 1742 | gnutls_crypto = dependency('gnutls', version: '>=3.6.14', |
| 1743 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1744 | required: false) |
Daniel P. Berrangé | cc4c7c7 | 2021-06-30 17:20:02 +0100 | [diff] [blame] | 1745 | if gnutls_crypto.found() |
| 1746 | gnutls = gnutls_crypto |
| 1747 | else |
| 1748 | # Our min version if all we need is TLS |
| 1749 | gnutls = dependency('gnutls', version: '>=3.5.18', |
| 1750 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1751 | required: get_option('gnutls')) |
Daniel P. Berrangé | cc4c7c7 | 2021-06-30 17:20:02 +0100 | [diff] [blame] | 1752 | endif |
Paolo Bonzini | 5761251 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 1753 | endif |
| 1754 | |
Daniel P. Berrangé | 8bd0931 | 2021-07-02 17:38:33 +0100 | [diff] [blame] | 1755 | # We prefer use of gnutls for crypto, unless the options |
| 1756 | # explicitly asked for nettle or gcrypt. |
| 1757 | # |
| 1758 | # If gnutls isn't available for crypto, then we'll prefer |
| 1759 | # gcrypt over nettle for performance reasons. |
Paolo Bonzini | 5761251 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 1760 | gcrypt = not_found |
| 1761 | nettle = not_found |
Lei He | 4c5e512 | 2022-05-25 17:01:14 +0800 | [diff] [blame] | 1762 | hogweed = not_found |
Hyman Huang | 52ed9f4 | 2023-12-07 23:47:35 +0800 | [diff] [blame] | 1763 | crypto_sm4 = not_found |
Daniel P. Berrangé | 6801404 | 2021-07-02 17:00:32 +0100 | [diff] [blame] | 1764 | xts = 'none' |
Daniel P. Berrangé | 8bd0931 | 2021-07-02 17:38:33 +0100 | [diff] [blame] | 1765 | |
Paolo Bonzini | 5761251 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 1766 | if get_option('nettle').enabled() and get_option('gcrypt').enabled() |
| 1767 | error('Only one of gcrypt & nettle can be enabled') |
Paolo Bonzini | 5761251 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 1768 | endif |
Daniel P. Berrangé | 8bd0931 | 2021-07-02 17:38:33 +0100 | [diff] [blame] | 1769 | |
| 1770 | # Explicit nettle/gcrypt request, so ignore gnutls for crypto |
| 1771 | if get_option('nettle').enabled() or get_option('gcrypt').enabled() |
Daniel P. Berrangé | cc4c7c7 | 2021-06-30 17:20:02 +0100 | [diff] [blame] | 1772 | gnutls_crypto = not_found |
| 1773 | endif |
Paolo Bonzini | 5761251 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 1774 | |
Daniel P. Berrangé | 8bd0931 | 2021-07-02 17:38:33 +0100 | [diff] [blame] | 1775 | if not gnutls_crypto.found() |
| 1776 | if (not get_option('gcrypt').auto() or have_system) and not get_option('nettle').enabled() |
| 1777 | gcrypt = dependency('libgcrypt', version: '>=1.8', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1778 | required: get_option('gcrypt')) |
Daniel P. Berrangé | 8bd0931 | 2021-07-02 17:38:33 +0100 | [diff] [blame] | 1779 | # Debian has removed -lgpg-error from libgcrypt-config |
| 1780 | # as it "spreads unnecessary dependencies" which in |
| 1781 | # turn breaks static builds... |
Paolo Bonzini | a0cbd2e | 2022-07-14 14:33:49 +0200 | [diff] [blame] | 1782 | if gcrypt.found() and get_option('prefer_static') |
Paolo Bonzini | bd3615d | 2023-03-30 12:45:58 +0200 | [diff] [blame] | 1783 | gcrypt = declare_dependency(dependencies: |
| 1784 | [gcrypt, |
| 1785 | cc.find_library('gpg-error', required: true)], |
| 1786 | version: gcrypt.version()) |
Daniel P. Berrangé | 8bd0931 | 2021-07-02 17:38:33 +0100 | [diff] [blame] | 1787 | endif |
Hyman Huang | 52ed9f4 | 2023-12-07 23:47:35 +0800 | [diff] [blame] | 1788 | crypto_sm4 = gcrypt |
| 1789 | # SM4 ALG is available in libgcrypt >= 1.9 |
| 1790 | if gcrypt.found() and not cc.links(''' |
| 1791 | #include <gcrypt.h> |
| 1792 | int main(void) { |
| 1793 | gcry_cipher_hd_t handler; |
| 1794 | gcry_cipher_open(&handler, GCRY_CIPHER_SM4, GCRY_CIPHER_MODE_ECB, 0); |
| 1795 | return 0; |
| 1796 | }''', dependencies: gcrypt) |
| 1797 | crypto_sm4 = not_found |
| 1798 | endif |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 1799 | endif |
Daniel P. Berrangé | 8bd0931 | 2021-07-02 17:38:33 +0100 | [diff] [blame] | 1800 | if (not get_option('nettle').auto() or have_system) and not gcrypt.found() |
| 1801 | nettle = dependency('nettle', version: '>=3.4', |
| 1802 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1803 | required: get_option('nettle')) |
Daniel P. Berrangé | 8bd0931 | 2021-07-02 17:38:33 +0100 | [diff] [blame] | 1804 | if nettle.found() and not cc.has_header('nettle/xts.h', dependencies: nettle) |
| 1805 | xts = 'private' |
| 1806 | endif |
Hyman Huang | 52ed9f4 | 2023-12-07 23:47:35 +0800 | [diff] [blame] | 1807 | crypto_sm4 = nettle |
| 1808 | # SM4 ALG is available in nettle >= 3.9 |
| 1809 | if nettle.found() and not cc.links(''' |
| 1810 | #include <nettle/sm4.h> |
| 1811 | int main(void) { |
| 1812 | struct sm4_ctx ctx; |
| 1813 | unsigned char key[16] = {0}; |
| 1814 | sm4_set_encrypt_key(&ctx, key); |
| 1815 | return 0; |
| 1816 | }''', dependencies: nettle) |
| 1817 | crypto_sm4 = not_found |
| 1818 | endif |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1819 | endif |
| 1820 | endif |
| 1821 | |
Paolo Bonzini | a775c71 | 2023-09-08 12:09:22 +0200 | [diff] [blame] | 1822 | capstone = not_found |
| 1823 | if not get_option('capstone').auto() or have_system or have_user |
| 1824 | capstone = dependency('capstone', version: '>=3.0.5', |
| 1825 | method: 'pkg-config', |
| 1826 | required: get_option('capstone')) |
| 1827 | |
| 1828 | # Some versions of capstone have broken pkg-config file |
| 1829 | # that reports a wrong -I path, causing the #include to |
| 1830 | # fail later. If the system has such a broken version |
| 1831 | # do not use it. |
| 1832 | if capstone.found() and not cc.compiles('#include <capstone.h>', |
| 1833 | dependencies: [capstone]) |
| 1834 | capstone = not_found |
| 1835 | if get_option('capstone').enabled() |
| 1836 | error('capstone requested, but it does not appear to work') |
| 1837 | endif |
| 1838 | endif |
| 1839 | endif |
| 1840 | |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1841 | gmp = dependency('gmp', required: false, method: 'pkg-config') |
Lei He | 4c5e512 | 2022-05-25 17:01:14 +0800 | [diff] [blame] | 1842 | if nettle.found() and gmp.found() |
| 1843 | hogweed = dependency('hogweed', version: '>=3.4', |
| 1844 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1845 | required: get_option('nettle')) |
Lei He | 4c5e512 | 2022-05-25 17:01:14 +0800 | [diff] [blame] | 1846 | endif |
| 1847 | |
| 1848 | |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1849 | gtk = not_found |
Paolo Bonzini | 1b69547 | 2021-01-07 14:02:29 +0100 | [diff] [blame] | 1850 | gtkx11 = not_found |
Paolo Bonzini | c23d7b4 | 2021-06-03 11:31:35 +0200 | [diff] [blame] | 1851 | vte = not_found |
Claudio Fontana | 29e0bff | 2022-11-21 14:55:38 +0100 | [diff] [blame] | 1852 | have_gtk_clipboard = get_option('gtk_clipboard').enabled() |
| 1853 | |
Marc-André Lureau | da554e1 | 2023-08-30 13:38:36 +0400 | [diff] [blame] | 1854 | if get_option('gtk') \ |
| 1855 | .disable_auto_if(not have_system) \ |
| 1856 | .require(pixman.found(), |
| 1857 | error_message: 'cannot enable GTK if pixman is not available') \ |
| 1858 | .allowed() |
Paolo Bonzini | 1b69547 | 2021-01-07 14:02:29 +0100 | [diff] [blame] | 1859 | gtk = dependency('gtk+-3.0', version: '>=3.22.0', |
| 1860 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1861 | required: get_option('gtk')) |
Paolo Bonzini | 1b69547 | 2021-01-07 14:02:29 +0100 | [diff] [blame] | 1862 | if gtk.found() |
| 1863 | gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0', |
| 1864 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1865 | required: false) |
Paolo Bonzini | bd3615d | 2023-03-30 12:45:58 +0200 | [diff] [blame] | 1866 | gtk = declare_dependency(dependencies: [gtk, gtkx11], |
| 1867 | version: gtk.version()) |
Paolo Bonzini | c23d7b4 | 2021-06-03 11:31:35 +0200 | [diff] [blame] | 1868 | |
| 1869 | if not get_option('vte').auto() or have_system |
| 1870 | vte = dependency('vte-2.91', |
| 1871 | method: 'pkg-config', |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1872 | required: get_option('vte')) |
Paolo Bonzini | c23d7b4 | 2021-06-03 11:31:35 +0200 | [diff] [blame] | 1873 | endif |
Claudio Fontana | 29e0bff | 2022-11-21 14:55:38 +0100 | [diff] [blame] | 1874 | elif have_gtk_clipboard |
| 1875 | error('GTK clipboard requested, but GTK not found') |
Paolo Bonzini | 1b69547 | 2021-01-07 14:02:29 +0100 | [diff] [blame] | 1876 | endif |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1877 | endif |
Paolo Bonzini | 1b69547 | 2021-01-07 14:02:29 +0100 | [diff] [blame] | 1878 | |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1879 | x11 = not_found |
Markus Armbruster | 9d49bcf | 2021-05-03 10:40:33 +0200 | [diff] [blame] | 1880 | if gtkx11.found() |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1881 | x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found()) |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1882 | endif |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1883 | png = not_found |
Kshitij Suri | 95f8510 | 2022-04-08 07:13:34 +0000 | [diff] [blame] | 1884 | if get_option('png').allowed() and have_system |
Thomas Huth | 1ec8c2c | 2022-06-23 19:49:41 +0200 | [diff] [blame] | 1885 | png = dependency('libpng', version: '>=1.6.34', required: get_option('png'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1886 | method: 'pkg-config') |
Kshitij Suri | 95f8510 | 2022-04-08 07:13:34 +0000 | [diff] [blame] | 1887 | endif |
| 1888 | vnc = not_found |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1889 | jpeg = not_found |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1890 | sasl = not_found |
Marc-André Lureau | 89fd3ea | 2023-08-30 13:38:34 +0400 | [diff] [blame] | 1891 | if get_option('vnc') \ |
| 1892 | .disable_auto_if(not have_system) \ |
| 1893 | .require(pixman.found(), |
| 1894 | error_message: 'cannot enable VNC if pixman is not available') \ |
| 1895 | .allowed() |
Paolo Bonzini | a0b9323 | 2020-02-06 15:48:52 +0100 | [diff] [blame] | 1896 | vnc = declare_dependency() # dummy dependency |
Paolo Bonzini | 8e242b3 | 2020-11-23 13:34:02 -0500 | [diff] [blame] | 1897 | jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1898 | method: 'pkg-config') |
Paolo Bonzini | a0b9323 | 2020-02-06 15:48:52 +0100 | [diff] [blame] | 1899 | sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1900 | required: get_option('vnc_sasl')) |
Paolo Bonzini | a0b9323 | 2020-02-06 15:48:52 +0100 | [diff] [blame] | 1901 | if sasl.found() |
| 1902 | sasl = declare_dependency(dependencies: sasl, |
| 1903 | compile_args: '-DSTRUCT_IOVEC_DEFINED') |
| 1904 | endif |
Marc-André Lureau | 2b1ccdf | 2019-07-16 23:21:02 +0400 | [diff] [blame] | 1905 | endif |
Paolo Bonzini | 241611e | 2020-11-17 13:32:34 +0100 | [diff] [blame] | 1906 | |
Paolo Bonzini | 05e391a | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 1907 | pam = not_found |
| 1908 | if not get_option('auth_pam').auto() or have_system |
| 1909 | pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1910 | required: get_option('auth_pam')) |
Paolo Bonzini | 05e391a | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 1911 | endif |
| 1912 | if pam.found() and not cc.links(''' |
| 1913 | #include <stddef.h> |
| 1914 | #include <security/pam_appl.h> |
| 1915 | int main(void) { |
| 1916 | const char *service_name = "qemu"; |
| 1917 | const char *user = "frank"; |
| 1918 | const struct pam_conv pam_conv = { 0 }; |
| 1919 | pam_handle_t *pamh = NULL; |
| 1920 | pam_start(service_name, user, &pam_conv, &pamh); |
| 1921 | return 0; |
| 1922 | }''', dependencies: pam) |
| 1923 | pam = not_found |
| 1924 | if get_option('auth_pam').enabled() |
| 1925 | error('could not link libpam') |
| 1926 | else |
| 1927 | warning('could not link libpam, disabling') |
| 1928 | endif |
| 1929 | endif |
| 1930 | |
Marc-André Lureau | 708eab4 | 2019-09-03 16:59:33 +0400 | [diff] [blame] | 1931 | snappy = not_found |
Paolo Bonzini | 241611e | 2020-11-17 13:32:34 +0100 | [diff] [blame] | 1932 | if not get_option('snappy').auto() or have_system |
| 1933 | snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1934 | required: get_option('snappy')) |
Marc-André Lureau | 708eab4 | 2019-09-03 16:59:33 +0400 | [diff] [blame] | 1935 | endif |
Thomas Huth | 785abf0 | 2023-07-06 08:47:36 +0200 | [diff] [blame] | 1936 | if snappy.found() and not cc.links(''' |
Paolo Bonzini | 241611e | 2020-11-17 13:32:34 +0100 | [diff] [blame] | 1937 | #include <snappy-c.h> |
| 1938 | int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy) |
| 1939 | snappy = not_found |
| 1940 | if get_option('snappy').enabled() |
| 1941 | error('could not link libsnappy') |
| 1942 | else |
| 1943 | warning('could not link libsnappy, disabling') |
| 1944 | endif |
Marc-André Lureau | 708eab4 | 2019-09-03 16:59:33 +0400 | [diff] [blame] | 1945 | endif |
Paolo Bonzini | 0c32a0a | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 1946 | |
Marc-André Lureau | 708eab4 | 2019-09-03 16:59:33 +0400 | [diff] [blame] | 1947 | lzo = not_found |
Paolo Bonzini | 0c32a0a | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 1948 | if not get_option('lzo').auto() or have_system |
| 1949 | lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1950 | required: get_option('lzo')) |
Marc-André Lureau | 708eab4 | 2019-09-03 16:59:33 +0400 | [diff] [blame] | 1951 | endif |
Paolo Bonzini | 0c32a0a | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 1952 | if lzo.found() and not cc.links(''' |
| 1953 | #include <lzo/lzo1x.h> |
| 1954 | int main(void) { lzo_version(); return 0; }''', dependencies: lzo) |
| 1955 | lzo = not_found |
| 1956 | if get_option('lzo').enabled() |
| 1957 | error('could not link liblzo2') |
| 1958 | else |
| 1959 | warning('could not link liblzo2, disabling') |
| 1960 | endif |
| 1961 | endif |
| 1962 | |
Paolo Bonzini | 488a8c7 | 2021-12-21 12:38:27 +0100 | [diff] [blame] | 1963 | numa = not_found |
| 1964 | if not get_option('numa').auto() or have_system or have_tools |
| 1965 | numa = cc.find_library('numa', has_headers: ['numa.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 1966 | required: get_option('numa')) |
Paolo Bonzini | 488a8c7 | 2021-12-21 12:38:27 +0100 | [diff] [blame] | 1967 | endif |
| 1968 | if numa.found() and not cc.links(''' |
| 1969 | #include <numa.h> |
| 1970 | int main(void) { return numa_available(); } |
| 1971 | ''', dependencies: numa) |
| 1972 | numa = not_found |
| 1973 | if get_option('numa').enabled() |
| 1974 | error('could not link numa') |
| 1975 | else |
| 1976 | warning('could not link numa, disabling') |
| 1977 | endif |
| 1978 | endif |
| 1979 | |
Paolo Bonzini | 7a6f334 | 2024-01-25 12:22:57 +0100 | [diff] [blame] | 1980 | fdt = not_found |
| 1981 | fdt_opt = get_option('fdt') |
| 1982 | if fdt_opt == 'enabled' and get_option('wrap_mode') == 'nodownload' |
| 1983 | fdt_opt = 'system' |
| 1984 | endif |
| 1985 | if fdt_opt in ['enabled', 'system'] or (fdt_opt == 'auto' and have_system) |
| 1986 | fdt = cc.find_library('fdt', required: fdt_opt == 'system') |
| 1987 | if fdt.found() and cc.links(''' |
| 1988 | #include <libfdt.h> |
| 1989 | #include <libfdt_env.h> |
| 1990 | int main(void) { fdt_find_max_phandle(NULL, NULL); return 0; }''', |
| 1991 | dependencies: fdt) |
| 1992 | fdt_opt = 'system' |
| 1993 | elif fdt_opt != 'system' |
| 1994 | fdt_opt = get_option('wrap_mode') == 'nodownload' ? 'disabled' : 'internal' |
| 1995 | fdt = not_found |
| 1996 | else |
| 1997 | error('system libfdt is too old (1.5.1 or newer required)') |
| 1998 | endif |
| 1999 | endif |
| 2000 | if fdt_opt == 'internal' |
| 2001 | assert(not fdt.found()) |
| 2002 | libfdt_proj = subproject('dtc', required: true, |
| 2003 | default_options: ['tools=false', 'yaml=disabled', |
| 2004 | 'python=disabled', 'default_library=static']) |
| 2005 | fdt = libfdt_proj.get_variable('libfdt_dep') |
| 2006 | endif |
| 2007 | |
Marc-André Lureau | 5516623 | 2019-07-24 19:16:22 +0400 | [diff] [blame] | 2008 | rdma = not_found |
Paolo Bonzini | 3730a73 | 2022-04-20 17:33:41 +0200 | [diff] [blame] | 2009 | if not get_option('rdma').auto() or have_system |
Paolo Bonzini | 3730a73 | 2022-04-20 17:33:41 +0200 | [diff] [blame] | 2010 | rdma_libs = [cc.find_library('rdmacm', has_headers: ['rdma/rdma_cma.h'], |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2011 | required: get_option('rdma')), |
zhenwei pi | 829858f | 2024-06-11 18:54:26 +0800 | [diff] [blame] | 2012 | cc.find_library('ibverbs', required: get_option('rdma'))] |
Paolo Bonzini | 3730a73 | 2022-04-20 17:33:41 +0200 | [diff] [blame] | 2013 | rdma = declare_dependency(dependencies: rdma_libs) |
| 2014 | foreach lib: rdma_libs |
| 2015 | if not lib.found() |
| 2016 | rdma = not_found |
| 2017 | endif |
| 2018 | endforeach |
Marc-André Lureau | 5516623 | 2019-07-24 19:16:22 +0400 | [diff] [blame] | 2019 | endif |
Paolo Bonzini | 3730a73 | 2022-04-20 17:33:41 +0200 | [diff] [blame] | 2020 | |
Paolo Bonzini | 06677ce | 2020-08-06 13:07:39 +0200 | [diff] [blame] | 2021 | cacard = not_found |
Paolo Bonzini | 5f364c5 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 2022 | if not get_option('smartcard').auto() or have_system |
| 2023 | cacard = dependency('libcacard', required: get_option('smartcard'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2024 | version: '>=2.5.1', method: 'pkg-config') |
Paolo Bonzini | 06677ce | 2020-08-06 13:07:39 +0200 | [diff] [blame] | 2025 | endif |
César Belley | 0a40bcb | 2020-08-26 13:42:04 +0200 | [diff] [blame] | 2026 | u2f = not_found |
Paolo Bonzini | e7c22ff | 2023-09-08 12:10:27 +0200 | [diff] [blame] | 2027 | if not get_option('u2f').auto() or have_system |
César Belley | 0a40bcb | 2020-08-26 13:42:04 +0200 | [diff] [blame] | 2028 | u2f = dependency('u2f-emu', required: get_option('u2f'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2029 | method: 'pkg-config') |
César Belley | 0a40bcb | 2020-08-26 13:42:04 +0200 | [diff] [blame] | 2030 | endif |
Hongren (Zenithal) Zheng | 8caef85 | 2022-05-19 20:38:57 +0800 | [diff] [blame] | 2031 | canokey = not_found |
Paolo Bonzini | e7c22ff | 2023-09-08 12:10:27 +0200 | [diff] [blame] | 2032 | if not get_option('canokey').auto() or have_system |
Hongren (Zenithal) Zheng | 8caef85 | 2022-05-19 20:38:57 +0800 | [diff] [blame] | 2033 | canokey = dependency('canokey-qemu', required: get_option('canokey'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2034 | method: 'pkg-config') |
Hongren (Zenithal) Zheng | 8caef85 | 2022-05-19 20:38:57 +0800 | [diff] [blame] | 2035 | endif |
Paolo Bonzini | 06677ce | 2020-08-06 13:07:39 +0200 | [diff] [blame] | 2036 | usbredir = not_found |
Paolo Bonzini | 18f31e6 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 2037 | if not get_option('usb_redir').auto() or have_system |
| 2038 | usbredir = dependency('libusbredirparser-0.5', required: get_option('usb_redir'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2039 | version: '>=0.6', method: 'pkg-config') |
Paolo Bonzini | 06677ce | 2020-08-06 13:07:39 +0200 | [diff] [blame] | 2040 | endif |
| 2041 | libusb = not_found |
Paolo Bonzini | 90540f3 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 2042 | if not get_option('libusb').auto() or have_system |
| 2043 | libusb = dependency('libusb-1.0', required: get_option('libusb'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2044 | version: '>=1.0.13', method: 'pkg-config') |
Paolo Bonzini | 06677ce | 2020-08-06 13:07:39 +0200 | [diff] [blame] | 2045 | endif |
Paolo Bonzini | 90540f3 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 2046 | |
Marc-André Lureau | c9322ab | 2019-08-18 19:51:17 +0400 | [diff] [blame] | 2047 | libpmem = not_found |
Paolo Bonzini | e36e8c7 | 2021-06-03 11:31:35 +0200 | [diff] [blame] | 2048 | if not get_option('libpmem').auto() or have_system |
| 2049 | libpmem = dependency('libpmem', required: get_option('libpmem'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2050 | method: 'pkg-config') |
Marc-André Lureau | c9322ab | 2019-08-18 19:51:17 +0400 | [diff] [blame] | 2051 | endif |
Bruce Rogers | c7c91a7 | 2020-08-24 09:52:12 -0600 | [diff] [blame] | 2052 | libdaxctl = not_found |
Paolo Bonzini | 83ef168 | 2021-06-03 11:31:35 +0200 | [diff] [blame] | 2053 | if not get_option('libdaxctl').auto() or have_system |
| 2054 | libdaxctl = dependency('libdaxctl', required: get_option('libdaxctl'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2055 | version: '>=57', method: 'pkg-config') |
Bruce Rogers | c7c91a7 | 2020-08-24 09:52:12 -0600 | [diff] [blame] | 2056 | endif |
Marc-André Lureau | 8ce0a45 | 2020-08-28 15:07:20 +0400 | [diff] [blame] | 2057 | tasn1 = not_found |
Paolo Bonzini | ba7ed40 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 2058 | if gnutls.found() |
| 2059 | tasn1 = dependency('libtasn1', |
Philippe Mathieu-Daudé | dc37d1c | 2024-05-02 11:56:42 +0200 | [diff] [blame] | 2060 | required: false, |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2061 | method: 'pkg-config') |
Marc-André Lureau | 8ce0a45 | 2020-08-28 15:07:20 +0400 | [diff] [blame] | 2062 | endif |
Max Fritz | 0db0fbb | 2023-05-22 02:12:02 +0200 | [diff] [blame] | 2063 | keyutils = not_found |
Thomas Huth | c64023b | 2023-08-24 11:42:08 +0200 | [diff] [blame] | 2064 | if not get_option('libkeyutils').auto() or have_block |
| 2065 | keyutils = dependency('libkeyutils', required: get_option('libkeyutils'), |
| 2066 | method: 'pkg-config') |
Max Fritz | 0db0fbb | 2023-05-22 02:12:02 +0200 | [diff] [blame] | 2067 | endif |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 2068 | |
Marc-André Lureau | 3909def | 2020-08-28 15:07:33 +0400 | [diff] [blame] | 2069 | has_gettid = cc.has_function('gettid') |
| 2070 | |
Richard W.M. Jones | 3d212b4 | 2021-11-15 14:29:43 -0600 | [diff] [blame] | 2071 | # libselinux |
| 2072 | selinux = dependency('libselinux', |
| 2073 | required: get_option('selinux'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2074 | method: 'pkg-config') |
Richard W.M. Jones | 3d212b4 | 2021-11-15 14:29:43 -0600 | [diff] [blame] | 2075 | |
Paolo Bonzini | aa08796 | 2020-09-01 11:15:30 -0400 | [diff] [blame] | 2076 | # Malloc tests |
| 2077 | |
| 2078 | malloc = [] |
| 2079 | if get_option('malloc') == 'system' |
| 2080 | has_malloc_trim = \ |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2081 | get_option('malloc_trim').allowed() and \ |
Michal Privoznik | 09a49af | 2023-05-30 12:31:23 +0200 | [diff] [blame] | 2082 | cc.has_function('malloc_trim', prefix: '#include <malloc.h>') |
Paolo Bonzini | aa08796 | 2020-09-01 11:15:30 -0400 | [diff] [blame] | 2083 | else |
| 2084 | has_malloc_trim = false |
| 2085 | malloc = cc.find_library(get_option('malloc'), required: true) |
| 2086 | endif |
| 2087 | if not has_malloc_trim and get_option('malloc_trim').enabled() |
| 2088 | if get_option('malloc') == 'system' |
| 2089 | error('malloc_trim not available on this platform.') |
| 2090 | else |
| 2091 | error('malloc_trim not available with non-libc memory allocator') |
| 2092 | endif |
| 2093 | endif |
| 2094 | |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2095 | gnu_source_prefix = ''' |
Max Reitz | 84e319a | 2020-11-02 17:18:55 +0100 | [diff] [blame] | 2096 | #ifndef _GNU_SOURCE |
| 2097 | #define _GNU_SOURCE |
| 2098 | #endif |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2099 | ''' |
Max Reitz | 84e319a | 2020-11-02 17:18:55 +0100 | [diff] [blame] | 2100 | |
Michal Privoznik | 09a49af | 2023-05-30 12:31:23 +0200 | [diff] [blame] | 2101 | # Check whether the glibc provides STATX_BASIC_STATS |
| 2102 | |
| 2103 | has_statx = cc.has_header_symbol('sys/stat.h', 'STATX_BASIC_STATS', prefix: gnu_source_prefix) |
Max Reitz | 84e319a | 2020-11-02 17:18:55 +0100 | [diff] [blame] | 2104 | |
Hanna Reitz | 4ce7a08 | 2022-02-23 10:23:40 +0100 | [diff] [blame] | 2105 | # Check whether statx() provides mount ID information |
| 2106 | |
Michal Privoznik | 09a49af | 2023-05-30 12:31:23 +0200 | [diff] [blame] | 2107 | has_statx_mnt_id = cc.has_header_symbol('sys/stat.h', 'STATX_MNT_ID', prefix: gnu_source_prefix) |
Hanna Reitz | 4ce7a08 | 2022-02-23 10:23:40 +0100 | [diff] [blame] | 2108 | |
Paolo Bonzini | a436d6d | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2109 | have_vhost_user_blk_server = get_option('vhost_user_blk_server') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2110 | .require(host_os == 'linux', |
Paolo Bonzini | a436d6d | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2111 | error_message: 'vhost_user_blk_server requires linux') \ |
Paolo Bonzini | 2a3129a | 2022-04-20 17:34:05 +0200 | [diff] [blame] | 2112 | .require(have_vhost_user, |
Paolo Bonzini | a436d6d | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2113 | error_message: 'vhost_user_blk_server requires vhost-user support') \ |
Alex Bennée | 26ed501 | 2022-05-24 16:40:42 +0100 | [diff] [blame] | 2114 | .disable_auto_if(not have_tools and not have_system) \ |
Paolo Bonzini | a436d6d | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2115 | .allowed() |
Daniele Buono | 9e62ba4 | 2020-12-04 18:06:14 -0500 | [diff] [blame] | 2116 | |
Max Reitz | df4ea70 | 2020-10-27 20:05:46 +0100 | [diff] [blame] | 2117 | if get_option('fuse').disabled() and get_option('fuse_lseek').enabled() |
| 2118 | error('Cannot enable fuse-lseek while fuse is disabled') |
| 2119 | endif |
| 2120 | |
Max Reitz | a484a71 | 2020-10-27 20:05:41 +0100 | [diff] [blame] | 2121 | fuse = dependency('fuse3', required: get_option('fuse'), |
Paolo Bonzini | 063d511 | 2022-07-14 14:56:58 +0200 | [diff] [blame] | 2122 | version: '>=3.1', method: 'pkg-config') |
Max Reitz | a484a71 | 2020-10-27 20:05:41 +0100 | [diff] [blame] | 2123 | |
Max Reitz | df4ea70 | 2020-10-27 20:05:46 +0100 | [diff] [blame] | 2124 | fuse_lseek = not_found |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2125 | if get_option('fuse_lseek').allowed() |
Max Reitz | df4ea70 | 2020-10-27 20:05:46 +0100 | [diff] [blame] | 2126 | if fuse.version().version_compare('>=3.8') |
| 2127 | # Dummy dependency |
| 2128 | fuse_lseek = declare_dependency() |
| 2129 | elif get_option('fuse_lseek').enabled() |
| 2130 | if fuse.found() |
| 2131 | error('fuse-lseek requires libfuse >=3.8, found ' + fuse.version()) |
| 2132 | else |
| 2133 | error('fuse-lseek requires libfuse, which was not found') |
| 2134 | endif |
| 2135 | endif |
| 2136 | endif |
| 2137 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2138 | have_libvduse = (host_os == 'linux') |
Xie Yongji | a6caeee | 2022-05-23 16:46:08 +0800 | [diff] [blame] | 2139 | if get_option('libvduse').enabled() |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2140 | if host_os != 'linux' |
Xie Yongji | a6caeee | 2022-05-23 16:46:08 +0800 | [diff] [blame] | 2141 | error('libvduse requires linux') |
| 2142 | endif |
| 2143 | elif get_option('libvduse').disabled() |
| 2144 | have_libvduse = false |
| 2145 | endif |
| 2146 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2147 | have_vduse_blk_export = (have_libvduse and host_os == 'linux') |
Xie Yongji | 2a2359b | 2022-05-23 16:46:09 +0800 | [diff] [blame] | 2148 | if get_option('vduse_blk_export').enabled() |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2149 | if host_os != 'linux' |
Xie Yongji | 2a2359b | 2022-05-23 16:46:09 +0800 | [diff] [blame] | 2150 | error('vduse_blk_export requires linux') |
| 2151 | elif not have_libvduse |
| 2152 | error('vduse_blk_export requires libvduse support') |
| 2153 | endif |
| 2154 | elif get_option('vduse_blk_export').disabled() |
| 2155 | have_vduse_blk_export = false |
| 2156 | endif |
| 2157 | |
Andrew Melnychenko | 46627f4 | 2021-05-14 14:48:32 +0300 | [diff] [blame] | 2158 | # libbpf |
Andrew Melnychenko | 0cc1418 | 2024-02-05 18:54:35 +0200 | [diff] [blame] | 2159 | bpf_version = '1.1.0' |
| 2160 | libbpf = dependency('libbpf', version: '>=' + bpf_version, required: get_option('bpf'), method: 'pkg-config') |
Andrew Melnychenko | 46627f4 | 2021-05-14 14:48:32 +0300 | [diff] [blame] | 2161 | if libbpf.found() and not cc.links(''' |
| 2162 | #include <bpf/libbpf.h> |
Andrew Melnychenko | 0cc1418 | 2024-02-05 18:54:35 +0200 | [diff] [blame] | 2163 | #include <linux/bpf.h> |
Andrew Melnychenko | 46627f4 | 2021-05-14 14:48:32 +0300 | [diff] [blame] | 2164 | int main(void) |
| 2165 | { |
Andrew Melnychenko | 0cc1418 | 2024-02-05 18:54:35 +0200 | [diff] [blame] | 2166 | // check flag availability |
| 2167 | int flag = BPF_F_MMAPABLE; |
Andrew Melnychenko | 46627f4 | 2021-05-14 14:48:32 +0300 | [diff] [blame] | 2168 | bpf_object__destroy_skeleton(NULL); |
| 2169 | return 0; |
| 2170 | }''', dependencies: libbpf) |
| 2171 | libbpf = not_found |
| 2172 | if get_option('bpf').enabled() |
Andrew Melnychenko | 0cc1418 | 2024-02-05 18:54:35 +0200 | [diff] [blame] | 2173 | error('libbpf skeleton/mmaping test failed') |
Andrew Melnychenko | 46627f4 | 2021-05-14 14:48:32 +0300 | [diff] [blame] | 2174 | else |
Andrew Melnychenko | 0cc1418 | 2024-02-05 18:54:35 +0200 | [diff] [blame] | 2175 | warning('libbpf skeleton/mmaping test failed, disabling') |
Andrew Melnychenko | 46627f4 | 2021-05-14 14:48:32 +0300 | [diff] [blame] | 2176 | endif |
| 2177 | endif |
| 2178 | |
Ilya Maximets | cb039ef | 2023-09-13 20:34:37 +0200 | [diff] [blame] | 2179 | # libxdp |
| 2180 | libxdp = not_found |
| 2181 | if not get_option('af_xdp').auto() or have_system |
Daniel P. Berrangé | 1f37280 | 2024-10-23 09:50:56 +0100 | [diff] [blame] | 2182 | if libbpf.found() |
| 2183 | libxdp = dependency('libxdp', required: get_option('af_xdp'), |
| 2184 | version: '>=1.4.0', method: 'pkg-config') |
| 2185 | else |
| 2186 | if get_option('af_xdp').enabled() |
| 2187 | error('libxdp requested, but libbpf is not available') |
| 2188 | endif |
| 2189 | endif |
Ilya Maximets | cb039ef | 2023-09-13 20:34:37 +0200 | [diff] [blame] | 2190 | endif |
| 2191 | |
Ilya Leoshkevich | 7c10cb3 | 2023-01-12 16:20:12 +0100 | [diff] [blame] | 2192 | # libdw |
Ilya Leoshkevich | bc71d58 | 2023-02-10 01:52:07 +0100 | [diff] [blame] | 2193 | libdw = not_found |
Ilya Leoshkevich | 550c6d9 | 2023-02-10 01:52:08 +0100 | [diff] [blame] | 2194 | if not get_option('libdw').auto() or \ |
Paolo Bonzini | a0cbd2e | 2022-07-14 14:33:49 +0200 | [diff] [blame] | 2195 | (not get_option('prefer_static') and (have_system or have_user)) |
Ilya Leoshkevich | bc71d58 | 2023-02-10 01:52:07 +0100 | [diff] [blame] | 2196 | libdw = dependency('libdw', |
| 2197 | method: 'pkg-config', |
Ilya Leoshkevich | bc71d58 | 2023-02-10 01:52:07 +0100 | [diff] [blame] | 2198 | required: get_option('libdw')) |
| 2199 | endif |
Ilya Leoshkevich | 7c10cb3 | 2023-01-12 16:20:12 +0100 | [diff] [blame] | 2200 | |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 2201 | ################# |
| 2202 | # config-host.h # |
| 2203 | ################# |
| 2204 | |
Paolo Bonzini | 95933f1 | 2023-09-08 12:10:08 +0200 | [diff] [blame] | 2205 | config_host_data = configuration_data() |
| 2206 | |
Manos Pitsidianakis | 764a6ee | 2024-10-03 16:28:44 +0300 | [diff] [blame] | 2207 | config_host_data.set('CONFIG_HAVE_RUST', have_rust) |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 2208 | audio_drivers_selected = [] |
| 2209 | if have_system |
| 2210 | audio_drivers_available = { |
| 2211 | 'alsa': alsa.found(), |
| 2212 | 'coreaudio': coreaudio.found(), |
| 2213 | 'dsound': dsound.found(), |
| 2214 | 'jack': jack.found(), |
| 2215 | 'oss': oss.found(), |
| 2216 | 'pa': pulse.found(), |
Dorinda Bassey | c2d3d1c | 2023-04-17 12:56:54 +0200 | [diff] [blame] | 2217 | 'pipewire': pipewire.found(), |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 2218 | 'sdl': sdl.found(), |
Alexandre Ratchov | 663df1c | 2022-09-07 15:23:42 +0200 | [diff] [blame] | 2219 | 'sndio': sndio.found(), |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 2220 | } |
Paolo Bonzini | e5424a2 | 2021-10-07 15:06:10 +0200 | [diff] [blame] | 2221 | foreach k, v: audio_drivers_available |
| 2222 | config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v) |
| 2223 | endforeach |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 2224 | |
| 2225 | # Default to native drivers first, OSS second, SDL third |
| 2226 | audio_drivers_priority = \ |
Alexandre Ratchov | 663df1c | 2022-09-07 15:23:42 +0200 | [diff] [blame] | 2227 | [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2228 | (host_os == 'linux' ? [] : [ 'sdl' ]) |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 2229 | audio_drivers_default = [] |
| 2230 | foreach k: audio_drivers_priority |
| 2231 | if audio_drivers_available[k] |
| 2232 | audio_drivers_default += k |
| 2233 | endif |
| 2234 | endforeach |
| 2235 | |
| 2236 | foreach k: get_option('audio_drv_list') |
| 2237 | if k == 'default' |
| 2238 | audio_drivers_selected += audio_drivers_default |
| 2239 | elif not audio_drivers_available[k] |
| 2240 | error('Audio driver "@0@" not available.'.format(k)) |
| 2241 | else |
| 2242 | audio_drivers_selected += k |
| 2243 | endif |
| 2244 | endforeach |
| 2245 | endif |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 2246 | config_host_data.set('CONFIG_AUDIO_DRIVERS', |
| 2247 | '"' + '", "'.join(audio_drivers_selected) + '", ') |
| 2248 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2249 | have_host_block_device = (host_os != 'darwin' or |
Joelle van Dyne | 14176c8 | 2021-03-15 11:03:38 -0700 | [diff] [blame] | 2250 | cc.has_header('IOKit/storage/IOMedia.h')) |
| 2251 | |
Paolo Bonzini | a436d6d | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2252 | dbus_display = get_option('dbus_display') \ |
| 2253 | .require(gio.version().version_compare('>=2.64'), |
| 2254 | error_message: '-display dbus requires glib>=2.64') \ |
Paolo Bonzini | 7544060 | 2022-04-20 17:33:44 +0200 | [diff] [blame] | 2255 | .require(gdbus_codegen.found(), |
Paolo Bonzini | bb2dc4b | 2022-09-30 09:53:02 +0200 | [diff] [blame] | 2256 | error_message: gdbus_codegen_error.format('-display dbus')) \ |
Paolo Bonzini | a436d6d | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2257 | .allowed() |
Marc-André Lureau | 142ca62 | 2021-07-15 11:53:53 +0400 | [diff] [blame] | 2258 | |
Paolo Bonzini | a436d6d | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2259 | have_virtfs = get_option('virtfs') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2260 | .require(host_os == 'linux' or host_os == 'darwin', |
Keno Fischer | 0fb1e19 | 2022-02-27 17:35:22 -0500 | [diff] [blame] | 2261 | error_message: 'virtio-9p (virtfs) requires Linux or macOS') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2262 | .require(host_os == 'linux' or cc.has_function('pthread_fchdir_np'), |
Keno Fischer | 0fb1e19 | 2022-02-27 17:35:22 -0500 | [diff] [blame] | 2263 | error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2264 | .require(host_os == 'darwin' or libattr.found(), |
Peter Foley | 1a67e07 | 2023-05-03 09:07:56 -0400 | [diff] [blame] | 2265 | error_message: 'virtio-9p (virtfs) on Linux requires libattr-devel') \ |
Paolo Bonzini | a436d6d | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2266 | .disable_auto_if(not have_tools and not have_system) \ |
| 2267 | .allowed() |
Paolo Bonzini | 69202b4 | 2020-11-17 14:46:21 +0100 | [diff] [blame] | 2268 | |
Daniel P. Berrangé | 4bb3da4 | 2024-07-12 14:24:44 +0100 | [diff] [blame] | 2269 | qga_fsfreeze = false |
| 2270 | qga_fstrim = false |
| 2271 | if host_os == 'linux' |
| 2272 | if cc.has_header_symbol('linux/fs.h', 'FIFREEZE') |
| 2273 | qga_fsfreeze = true |
| 2274 | endif |
| 2275 | if cc.has_header_symbol('linux/fs.h', 'FITRIM') |
| 2276 | qga_fstrim = true |
| 2277 | endif |
| 2278 | elif host_os == 'freebsd' and cc.has_header_symbol('ufs/ffs/fs.h', 'UFSSUSPEND') |
| 2279 | qga_fsfreeze = true |
| 2280 | endif |
| 2281 | |
Paolo Bonzini | 622d64f | 2022-04-20 17:33:53 +0200 | [diff] [blame] | 2282 | if get_option('block_drv_ro_whitelist') == '' |
| 2283 | config_host_data.set('CONFIG_BDRV_RO_WHITELIST', '') |
| 2284 | else |
| 2285 | config_host_data.set('CONFIG_BDRV_RO_WHITELIST', |
| 2286 | '"' + get_option('block_drv_ro_whitelist').replace(',', '", "') + '", ') |
| 2287 | endif |
| 2288 | if get_option('block_drv_rw_whitelist') == '' |
| 2289 | config_host_data.set('CONFIG_BDRV_RW_WHITELIST', '') |
| 2290 | else |
| 2291 | config_host_data.set('CONFIG_BDRV_RW_WHITELIST', |
| 2292 | '"' + get_option('block_drv_rw_whitelist').replace(',', '", "') + '", ') |
| 2293 | endif |
| 2294 | |
Paolo Bonzini | 9c29b74 | 2021-10-07 15:08:14 +0200 | [diff] [blame] | 2295 | foreach k : get_option('trace_backends') |
| 2296 | config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true) |
| 2297 | endforeach |
| 2298 | config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('trace_file')) |
Paolo Bonzini | 41f2ae2 | 2022-04-20 17:33:52 +0200 | [diff] [blame] | 2299 | config_host_data.set_quoted('CONFIG_TLS_PRIORITY', get_option('tls_priority')) |
Paolo Bonzini | 40c909f | 2022-04-20 17:33:49 +0200 | [diff] [blame] | 2300 | if iasl.found() |
| 2301 | config_host_data.set_quoted('CONFIG_IASL', iasl.full_path()) |
Paolo Bonzini | 5dc4618 | 2021-10-13 13:19:00 +0200 | [diff] [blame] | 2302 | endif |
Paolo Bonzini | 16bf7a3 | 2020-10-16 03:19:14 -0400 | [diff] [blame] | 2303 | config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir')) |
| 2304 | config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix')) |
| 2305 | config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir) |
| 2306 | config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir) |
| 2307 | config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir) |
Akihiko Odaki | 8154f5e | 2022-06-25 00:40:42 +0900 | [diff] [blame] | 2308 | |
| 2309 | qemu_firmwarepath = '' |
| 2310 | foreach k : get_option('qemu_firmwarepath') |
| 2311 | qemu_firmwarepath += '"' + get_option('prefix') / k + '", ' |
| 2312 | endforeach |
| 2313 | config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_firmwarepath) |
| 2314 | |
Paolo Bonzini | 16bf7a3 | 2020-10-16 03:19:14 -0400 | [diff] [blame] | 2315 | config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir')) |
| 2316 | config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir) |
| 2317 | config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir')) |
| 2318 | config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir')) |
| 2319 | config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir) |
| 2320 | config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir')) |
| 2321 | |
Paolo Bonzini | 6002711 | 2022-10-20 14:53:10 +0200 | [diff] [blame] | 2322 | if enable_modules |
Paolo Bonzini | b0b4323 | 2022-04-20 17:33:54 +0200 | [diff] [blame] | 2323 | config_host_data.set('CONFIG_STAMP', run_command( |
| 2324 | meson.current_source_dir() / 'scripts/qemu-stamp.py', |
| 2325 | meson.project_version(), get_option('pkgversion'), '--', |
| 2326 | meson.current_source_dir() / 'configure', |
| 2327 | capture: true, check: true).stdout().strip()) |
| 2328 | endif |
| 2329 | |
Paolo Bonzini | 35acbb3 | 2021-10-13 13:43:36 +0200 | [diff] [blame] | 2330 | have_slirp_smbd = get_option('slirp_smbd') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2331 | .require(host_os != 'windows', error_message: 'Host smbd not supported on this platform.') \ |
Paolo Bonzini | 35acbb3 | 2021-10-13 13:43:36 +0200 | [diff] [blame] | 2332 | .allowed() |
| 2333 | if have_slirp_smbd |
| 2334 | smbd_path = get_option('smbd') |
| 2335 | if smbd_path == '' |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2336 | smbd_path = (host_os == 'sunos' ? '/usr/sfw/sbin/smbd' : '/usr/sbin/smbd') |
Paolo Bonzini | 35acbb3 | 2021-10-13 13:43:36 +0200 | [diff] [blame] | 2337 | endif |
| 2338 | config_host_data.set_quoted('CONFIG_SMBD_COMMAND', smbd_path) |
| 2339 | endif |
| 2340 | |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 2341 | config_host_data.set('HOST_' + host_arch.to_upper(), 1) |
| 2342 | |
Paolo Bonzini | 95933f1 | 2023-09-08 12:10:08 +0200 | [diff] [blame] | 2343 | kvm_targets_c = '""' |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2344 | if get_option('kvm').allowed() and host_os == 'linux' |
Paolo Bonzini | 95933f1 | 2023-09-08 12:10:08 +0200 | [diff] [blame] | 2345 | kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"' |
| 2346 | endif |
| 2347 | config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c) |
| 2348 | |
Paolo Bonzini | 2cb2f58 | 2022-04-20 17:33:46 +0200 | [diff] [blame] | 2349 | if get_option('module_upgrades') and not enable_modules |
| 2350 | error('Cannot enable module-upgrades as modules are not enabled') |
| 2351 | endif |
| 2352 | config_host_data.set('CONFIG_MODULE_UPGRADES', get_option('module_upgrades')) |
| 2353 | |
Paolo Bonzini | f7f2d65 | 2020-11-17 14:45:24 +0100 | [diff] [blame] | 2354 | config_host_data.set('CONFIG_ATTR', libattr.found()) |
Paolo Bonzini | c55cf6a | 2021-10-13 11:46:09 +0200 | [diff] [blame] | 2355 | config_host_data.set('CONFIG_BDRV_WHITELIST_TOOLS', get_option('block_drv_whitelist_in_tools')) |
Paolo Bonzini | 8c6d4ff | 2020-11-17 13:02:17 +0100 | [diff] [blame] | 2356 | config_host_data.set('CONFIG_BRLAPI', brlapi.found()) |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2357 | config_host_data.set('CONFIG_BSD', host_os in bsd_oses) |
Daniel P. Berrangé | 4be55a4 | 2024-07-12 14:24:54 +0100 | [diff] [blame] | 2358 | config_host_data.set('CONFIG_FREEBSD', host_os == 'freebsd') |
Paolo Bonzini | a775c71 | 2023-09-08 12:09:22 +0200 | [diff] [blame] | 2359 | config_host_data.set('CONFIG_CAPSTONE', capstone.found()) |
Paolo Bonzini | b4e312e | 2020-09-01 11:28:59 -0400 | [diff] [blame] | 2360 | config_host_data.set('CONFIG_COCOA', cocoa.found()) |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2361 | config_host_data.set('CONFIG_DARWIN', host_os == 'darwin') |
Paolo Bonzini | 7a6f334 | 2024-01-25 12:22:57 +0100 | [diff] [blame] | 2362 | config_host_data.set('CONFIG_FDT', fdt.found()) |
Paolo Bonzini | 537b724 | 2021-10-07 15:08:12 +0200 | [diff] [blame] | 2363 | config_host_data.set('CONFIG_FUZZ', get_option('fuzzing')) |
Paolo Bonzini | af2bb99 | 2021-10-07 15:08:17 +0200 | [diff] [blame] | 2364 | config_host_data.set('CONFIG_GCOV', get_option('b_coverage')) |
Paolo Bonzini | f01496a | 2020-09-16 17:54:14 +0200 | [diff] [blame] | 2365 | config_host_data.set('CONFIG_LIBUDEV', libudev.found()) |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2366 | config_host_data.set('CONFIG_LINUX', host_os == 'linux') |
| 2367 | config_host_data.set('CONFIG_POSIX', host_os != 'windows') |
| 2368 | config_host_data.set('CONFIG_WIN32', host_os == 'windows') |
Paolo Bonzini | 0c32a0a | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 2369 | config_host_data.set('CONFIG_LZO', lzo.found()) |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 2370 | config_host_data.set('CONFIG_MPATH', mpathpersist.found()) |
Stefan Hajnoczi | fd66dbd | 2022-10-13 14:58:57 -0400 | [diff] [blame] | 2371 | config_host_data.set('CONFIG_BLKIO', blkio.found()) |
Stefano Garzarella | 98b126f | 2023-05-30 09:19:41 +0200 | [diff] [blame] | 2372 | if blkio.found() |
| 2373 | config_host_data.set('CONFIG_BLKIO_VHOST_VDPA_FD', |
| 2374 | blkio.version().version_compare('>=1.3.0')) |
Stefano Garzarella | 547c4e5 | 2024-08-08 10:05:45 +0200 | [diff] [blame] | 2375 | config_host_data.set('CONFIG_BLKIO_WRITE_ZEROS_FUA', |
| 2376 | blkio.version().version_compare('>=1.4.0')) |
Stefano Garzarella | 98b126f | 2023-05-30 09:19:41 +0200 | [diff] [blame] | 2377 | endif |
Paolo Bonzini | f9cd86f | 2020-11-17 12:43:15 +0100 | [diff] [blame] | 2378 | config_host_data.set('CONFIG_CURL', curl.found()) |
Yonggang Luo | 5285e59 | 2020-10-13 07:43:48 +0800 | [diff] [blame] | 2379 | config_host_data.set('CONFIG_CURSES', curses.found()) |
Thomas Huth | 8bc5184 | 2021-07-13 13:09:02 +0200 | [diff] [blame] | 2380 | config_host_data.set('CONFIG_GBM', gbm.found()) |
Paolo Bonzini | 7544060 | 2022-04-20 17:33:44 +0200 | [diff] [blame] | 2381 | config_host_data.set('CONFIG_GIO', gio.found()) |
Paolo Bonzini | 08821ca | 2020-11-17 13:01:26 +0100 | [diff] [blame] | 2382 | config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found()) |
| 2383 | if glusterfs.found() |
| 2384 | config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().version_compare('>=4')) |
| 2385 | config_host_data.set('CONFIG_GLUSTERFS_DISCARD', glusterfs.version().version_compare('>=5')) |
| 2386 | config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().version_compare('>=6')) |
| 2387 | config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().version_compare('>=6')) |
| 2388 | config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat) |
| 2389 | config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat) |
| 2390 | endif |
Paolo Bonzini | 1b69547 | 2021-01-07 14:02:29 +0100 | [diff] [blame] | 2391 | config_host_data.set('CONFIG_GTK', gtk.found()) |
Paolo Bonzini | c23d7b4 | 2021-06-03 11:31:35 +0200 | [diff] [blame] | 2392 | config_host_data.set('CONFIG_VTE', vte.found()) |
Claudio Fontana | 29e0bff | 2022-11-21 14:55:38 +0100 | [diff] [blame] | 2393 | config_host_data.set('CONFIG_GTK_CLIPBOARD', have_gtk_clipboard) |
Taylor Simpson | 63efb6a | 2023-04-27 15:59:52 -0700 | [diff] [blame] | 2394 | config_host_data.set('CONFIG_HEXAGON_IDEF_PARSER', get_option('hexagon_idef_parser')) |
Paolo Bonzini | f7f2d65 | 2020-11-17 14:45:24 +0100 | [diff] [blame] | 2395 | config_host_data.set('CONFIG_LIBATTR', have_old_libattr) |
Paolo Bonzini | 727c8bb | 2020-11-17 14:46:58 +0100 | [diff] [blame] | 2396 | config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found()) |
Andrew Melnychenko | 46627f4 | 2021-05-14 14:48:32 +0300 | [diff] [blame] | 2397 | config_host_data.set('CONFIG_EBPF', libbpf.found()) |
Ilya Maximets | cb039ef | 2023-09-13 20:34:37 +0200 | [diff] [blame] | 2398 | config_host_data.set('CONFIG_AF_XDP', libxdp.found()) |
Paolo Bonzini | 63a7f85 | 2021-07-08 13:50:06 +0200 | [diff] [blame] | 2399 | config_host_data.set('CONFIG_LIBDAXCTL', libdaxctl.found()) |
Paolo Bonzini | 9db405a | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 2400 | config_host_data.set('CONFIG_LIBISCSI', libiscsi.found()) |
Paolo Bonzini | 30045c0 | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 2401 | config_host_data.set('CONFIG_LIBNFS', libnfs.found()) |
Thomas Huth | e6a52b3 | 2021-12-09 15:48:01 +0100 | [diff] [blame] | 2402 | config_host_data.set('CONFIG_LIBSSH', libssh.found()) |
Paolo Bonzini | ff66f3e | 2021-10-07 15:08:20 +0200 | [diff] [blame] | 2403 | config_host_data.set('CONFIG_LINUX_AIO', libaio.found()) |
Paolo Bonzini | 63a7f85 | 2021-07-08 13:50:06 +0200 | [diff] [blame] | 2404 | config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found()) |
| 2405 | config_host_data.set('CONFIG_LIBPMEM', libpmem.found()) |
Paolo Bonzini | 6002711 | 2022-10-20 14:53:10 +0200 | [diff] [blame] | 2406 | config_host_data.set('CONFIG_MODULES', enable_modules) |
Paolo Bonzini | 488a8c7 | 2021-12-21 12:38:27 +0100 | [diff] [blame] | 2407 | config_host_data.set('CONFIG_NUMA', numa.found()) |
Michal Privoznik | 6bb613f | 2022-12-15 10:55:03 +0100 | [diff] [blame] | 2408 | if numa.found() |
| 2409 | config_host_data.set('HAVE_NUMA_HAS_PREFERRED_MANY', |
| 2410 | cc.has_function('numa_has_preferred_many', |
| 2411 | dependencies: numa)) |
| 2412 | endif |
Paolo Bonzini | 88b6e61 | 2022-04-20 17:33:40 +0200 | [diff] [blame] | 2413 | config_host_data.set('CONFIG_OPENGL', opengl.found()) |
Paolo Bonzini | 2c13c57 | 2023-08-30 12:20:53 +0200 | [diff] [blame] | 2414 | config_host_data.set('CONFIG_PLUGIN', get_option('plugins')) |
Paolo Bonzini | fabd1e9 | 2020-11-17 13:11:25 +0100 | [diff] [blame] | 2415 | config_host_data.set('CONFIG_RBD', rbd.found()) |
Paolo Bonzini | 3730a73 | 2022-04-20 17:33:41 +0200 | [diff] [blame] | 2416 | config_host_data.set('CONFIG_RDMA', rdma.found()) |
Paolo Bonzini | 655e2a7 | 2023-10-05 14:19:34 +0200 | [diff] [blame] | 2417 | config_host_data.set('CONFIG_RELOCATABLE', get_option('relocatable')) |
Paolo Bonzini | 721fa5e | 2022-10-12 11:59:51 +0200 | [diff] [blame] | 2418 | config_host_data.set('CONFIG_SAFESTACK', get_option('safe_stack')) |
Paolo Bonzini | 35be72b | 2020-02-06 14:17:15 +0100 | [diff] [blame] | 2419 | config_host_data.set('CONFIG_SDL', sdl.found()) |
| 2420 | config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found()) |
Paolo Bonzini | 90835c2 | 2020-11-17 14:22:24 +0100 | [diff] [blame] | 2421 | config_host_data.set('CONFIG_SECCOMP', seccomp.found()) |
Michal Privoznik | 73422d9 | 2022-10-26 09:30:24 +0200 | [diff] [blame] | 2422 | if seccomp.found() |
| 2423 | config_host_data.set('CONFIG_SECCOMP_SYSRAWRC', seccomp_has_sysrawrc) |
| 2424 | endif |
Marc-André Lureau | cca1575 | 2023-08-30 13:38:25 +0400 | [diff] [blame] | 2425 | config_host_data.set('CONFIG_PIXMAN', pixman.found()) |
Paolo Bonzini | a775c71 | 2023-09-08 12:09:22 +0200 | [diff] [blame] | 2426 | config_host_data.set('CONFIG_SLIRP', slirp.found()) |
Paolo Bonzini | 241611e | 2020-11-17 13:32:34 +0100 | [diff] [blame] | 2427 | config_host_data.set('CONFIG_SNAPPY', snappy.found()) |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2428 | config_host_data.set('CONFIG_SOLARIS', host_os == 'sunos') |
Paolo Bonzini | 875be287 | 2022-02-15 11:37:00 +0100 | [diff] [blame] | 2429 | if get_option('tcg').allowed() |
| 2430 | config_host_data.set('CONFIG_TCG', 1) |
| 2431 | config_host_data.set('CONFIG_TCG_INTERPRETER', tcg_arch == 'tci') |
| 2432 | endif |
Paolo Bonzini | 0d04c4c | 2021-12-21 12:38:27 +0100 | [diff] [blame] | 2433 | config_host_data.set('CONFIG_TPM', have_tpm) |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 2434 | config_host_data.set('CONFIG_TSAN', get_option('tsan')) |
Paolo Bonzini | 90540f3 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 2435 | config_host_data.set('CONFIG_USB_LIBUSB', libusb.found()) |
Paolo Bonzini | e172399 | 2021-10-07 15:08:21 +0200 | [diff] [blame] | 2436 | config_host_data.set('CONFIG_VDE', vde.found()) |
Stefan Hajnoczi | c0c4f14 | 2023-10-03 21:45:32 -0400 | [diff] [blame] | 2437 | config_host_data.set('CONFIG_VHOST', have_vhost) |
Paolo Bonzini | 2df89d5 | 2022-04-20 17:34:07 +0200 | [diff] [blame] | 2438 | config_host_data.set('CONFIG_VHOST_NET', have_vhost_net) |
| 2439 | config_host_data.set('CONFIG_VHOST_NET_USER', have_vhost_net_user) |
| 2440 | config_host_data.set('CONFIG_VHOST_NET_VDPA', have_vhost_net_vdpa) |
| 2441 | config_host_data.set('CONFIG_VHOST_KERNEL', have_vhost_kernel) |
| 2442 | config_host_data.set('CONFIG_VHOST_USER', have_vhost_user) |
| 2443 | config_host_data.set('CONFIG_VHOST_CRYPTO', have_vhost_user_crypto) |
| 2444 | config_host_data.set('CONFIG_VHOST_VDPA', have_vhost_vdpa) |
Vladislav Yaroshchuk | e2c1d78 | 2022-03-17 20:28:33 +0300 | [diff] [blame] | 2445 | config_host_data.set('CONFIG_VMNET', vmnet.found()) |
Stefan Hajnoczi | e5e856c | 2020-11-10 17:11:19 +0000 | [diff] [blame] | 2446 | config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server) |
Xie Yongji | 2a2359b | 2022-05-23 16:46:09 +0800 | [diff] [blame] | 2447 | config_host_data.set('CONFIG_VDUSE_BLK_EXPORT', have_vduse_blk_export) |
Kshitij Suri | 95f8510 | 2022-04-08 07:13:34 +0000 | [diff] [blame] | 2448 | config_host_data.set('CONFIG_PNG', png.found()) |
Paolo Bonzini | a0b9323 | 2020-02-06 15:48:52 +0100 | [diff] [blame] | 2449 | config_host_data.set('CONFIG_VNC', vnc.found()) |
| 2450 | config_host_data.set('CONFIG_VNC_JPEG', jpeg.found()) |
Paolo Bonzini | a0b9323 | 2020-02-06 15:48:52 +0100 | [diff] [blame] | 2451 | config_host_data.set('CONFIG_VNC_SASL', sasl.found()) |
Paolo Bonzini | 95933f1 | 2023-09-08 12:10:08 +0200 | [diff] [blame] | 2452 | if virgl.found() |
Dmitry Osipenko | ffac964 | 2024-10-25 00:03:04 +0300 | [diff] [blame] | 2453 | config_host_data.set('VIRGL_VERSION_MAJOR', virgl.version().split('.')[0]) |
Paolo Bonzini | 95933f1 | 2023-09-08 12:10:08 +0200 | [diff] [blame] | 2454 | endif |
Paolo Bonzini | 69202b4 | 2020-11-17 14:46:21 +0100 | [diff] [blame] | 2455 | config_host_data.set('CONFIG_VIRTFS', have_virtfs) |
Paolo Bonzini | 63a7f85 | 2021-07-08 13:50:06 +0200 | [diff] [blame] | 2456 | config_host_data.set('CONFIG_VTE', vte.found()) |
Laurent Vivier | 4113f4c | 2020-08-24 17:24:29 +0200 | [diff] [blame] | 2457 | config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found()) |
Marc-André Lureau | af04e89 | 2020-08-28 15:07:25 +0400 | [diff] [blame] | 2458 | config_host_data.set('CONFIG_KEYUTILS', keyutils.found()) |
Marc-André Lureau | 3909def | 2020-08-28 15:07:33 +0400 | [diff] [blame] | 2459 | config_host_data.set('CONFIG_GETTID', has_gettid) |
Paolo Bonzini | 5761251 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 2460 | config_host_data.set('CONFIG_GNUTLS', gnutls.found()) |
Daniel P. Berrangé | cc4c7c7 | 2021-06-30 17:20:02 +0100 | [diff] [blame] | 2461 | config_host_data.set('CONFIG_GNUTLS_CRYPTO', gnutls_crypto.found()) |
Daniel P. Berrangé | d47b83b | 2022-04-26 17:00:43 +0100 | [diff] [blame] | 2462 | config_host_data.set('CONFIG_TASN1', tasn1.found()) |
Paolo Bonzini | 5761251 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 2463 | config_host_data.set('CONFIG_GCRYPT', gcrypt.found()) |
| 2464 | config_host_data.set('CONFIG_NETTLE', nettle.found()) |
Hyman Huang | 52ed9f4 | 2023-12-07 23:47:35 +0800 | [diff] [blame] | 2465 | config_host_data.set('CONFIG_CRYPTO_SM4', crypto_sm4.found()) |
Lei He | 4c5e512 | 2022-05-25 17:01:14 +0800 | [diff] [blame] | 2466 | config_host_data.set('CONFIG_HOGWEED', hogweed.found()) |
Paolo Bonzini | 5761251 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 2467 | config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts == 'private') |
Paolo Bonzini | aa08796 | 2020-09-01 11:15:30 -0400 | [diff] [blame] | 2468 | config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim) |
Max Reitz | 84e319a | 2020-11-02 17:18:55 +0100 | [diff] [blame] | 2469 | config_host_data.set('CONFIG_STATX', has_statx) |
Hanna Reitz | 4ce7a08 | 2022-02-23 10:23:40 +0100 | [diff] [blame] | 2470 | config_host_data.set('CONFIG_STATX_MNT_ID', has_statx_mnt_id) |
Paolo Bonzini | b1def33 | 2020-11-17 13:37:39 +0100 | [diff] [blame] | 2471 | config_host_data.set('CONFIG_ZSTD', zstd.found()) |
Yuan Liu | b844a2c | 2024-06-10 18:21:06 +0800 | [diff] [blame] | 2472 | config_host_data.set('CONFIG_QPL', qpl.found()) |
Shameer Kolothum | cfc589a | 2024-06-07 14:53:05 +0100 | [diff] [blame] | 2473 | config_host_data.set('CONFIG_UADK', uadk.found()) |
Bryan Zhang | e28ed31 | 2024-08-30 16:27:19 -0700 | [diff] [blame] | 2474 | config_host_data.set('CONFIG_QATZIP', qatzip.found()) |
Max Reitz | a484a71 | 2020-10-27 20:05:41 +0100 | [diff] [blame] | 2475 | config_host_data.set('CONFIG_FUSE', fuse.found()) |
Max Reitz | df4ea70 | 2020-10-27 20:05:46 +0100 | [diff] [blame] | 2476 | config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found()) |
Marc-André Lureau | 3f0a5d5 | 2021-10-07 15:08:23 +0200 | [diff] [blame] | 2477 | config_host_data.set('CONFIG_SPICE_PROTOCOL', spice_protocol.found()) |
Marc-André Lureau | ddece46 | 2021-10-06 14:18:09 +0400 | [diff] [blame] | 2478 | if spice_protocol.found() |
| 2479 | config_host_data.set('CONFIG_SPICE_PROTOCOL_MAJOR', spice_protocol.version().split('.')[0]) |
| 2480 | config_host_data.set('CONFIG_SPICE_PROTOCOL_MINOR', spice_protocol.version().split('.')[1]) |
| 2481 | config_host_data.set('CONFIG_SPICE_PROTOCOL_MICRO', spice_protocol.version().split('.')[2]) |
| 2482 | endif |
Marc-André Lureau | 3f0a5d5 | 2021-10-07 15:08:23 +0200 | [diff] [blame] | 2483 | config_host_data.set('CONFIG_SPICE', spice.found()) |
Paolo Bonzini | 9d71037 | 2021-01-07 13:54:22 +0100 | [diff] [blame] | 2484 | config_host_data.set('CONFIG_X11', x11.found()) |
Marc-André Lureau | 142ca62 | 2021-07-15 11:53:53 +0400 | [diff] [blame] | 2485 | config_host_data.set('CONFIG_DBUS_DISPLAY', dbus_display) |
Daniele Buono | 9e62ba4 | 2020-12-04 18:06:14 -0500 | [diff] [blame] | 2486 | config_host_data.set('CONFIG_CFI', get_option('cfi')) |
Richard W.M. Jones | 3d212b4 | 2021-11-15 14:29:43 -0600 | [diff] [blame] | 2487 | config_host_data.set('CONFIG_SELINUX', selinux.found()) |
Paolo Bonzini | 14efd8d | 2022-04-20 17:33:47 +0200 | [diff] [blame] | 2488 | config_host_data.set('CONFIG_XEN_BACKEND', xen.found()) |
Ilya Leoshkevich | 7c10cb3 | 2023-01-12 16:20:12 +0100 | [diff] [blame] | 2489 | config_host_data.set('CONFIG_LIBDW', libdw.found()) |
Paolo Bonzini | 14efd8d | 2022-04-20 17:33:47 +0200 | [diff] [blame] | 2490 | if xen.found() |
| 2491 | # protect from xen.version() having less than three components |
| 2492 | xen_version = xen.version().split('.') + ['0', '0'] |
| 2493 | xen_ctrl_version = xen_version[0] + \ |
| 2494 | ('0' + xen_version[1]).substring(-2) + \ |
| 2495 | ('0' + xen_version[2]).substring(-2) |
| 2496 | config_host_data.set('CONFIG_XEN_CTRL_INTERFACE_VERSION', xen_ctrl_version) |
| 2497 | endif |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 2498 | config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version())) |
| 2499 | config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0]) |
| 2500 | config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1]) |
| 2501 | config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2]) |
| 2502 | |
Paolo Bonzini | a630508 | 2021-10-07 15:08:15 +0200 | [diff] [blame] | 2503 | config_host_data.set_quoted('CONFIG_HOST_DSOSUF', host_dsosuf) |
Paolo Bonzini | 69d8de7 | 2021-06-03 11:56:11 +0200 | [diff] [blame] | 2504 | config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device) |
| 2505 | |
Paolo Bonzini | 728c0a2 | 2021-10-13 11:52:03 +0200 | [diff] [blame] | 2506 | have_coroutine_pool = get_option('coroutine_pool') |
| 2507 | if get_option('debug_stack_usage') and have_coroutine_pool |
| 2508 | message('Disabling coroutine pool to measure stack usage') |
| 2509 | have_coroutine_pool = false |
| 2510 | endif |
Paolo Bonzini | 230f6e0 | 2023-10-05 14:31:27 +0200 | [diff] [blame] | 2511 | config_host_data.set('CONFIG_COROUTINE_POOL', have_coroutine_pool) |
Stefan Hajnoczi | 58a2e3f | 2023-05-01 13:34:43 -0400 | [diff] [blame] | 2512 | config_host_data.set('CONFIG_DEBUG_GRAPH_LOCK', get_option('debug_graph_lock')) |
Paolo Bonzini | c55cf6a | 2021-10-13 11:46:09 +0200 | [diff] [blame] | 2513 | config_host_data.set('CONFIG_DEBUG_MUTEX', get_option('debug_mutex')) |
Paolo Bonzini | 728c0a2 | 2021-10-13 11:52:03 +0200 | [diff] [blame] | 2514 | config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_option('debug_stack_usage')) |
Paolo Bonzini | 1d558c9 | 2023-08-28 11:48:30 +0200 | [diff] [blame] | 2515 | config_host_data.set('CONFIG_DEBUG_TCG', get_option('debug_tcg')) |
Ilya Leoshkevich | 1f2355f | 2024-03-12 01:23:30 +0100 | [diff] [blame] | 2516 | config_host_data.set('CONFIG_DEBUG_REMAP', get_option('debug_remap')) |
Paolo Bonzini | c55cf6a | 2021-10-13 11:46:09 +0200 | [diff] [blame] | 2517 | config_host_data.set('CONFIG_QOM_CAST_DEBUG', get_option('qom_cast_debug')) |
Juan Quintela | abad185 | 2022-09-02 18:51:25 +0200 | [diff] [blame] | 2518 | config_host_data.set('CONFIG_REPLICATION', get_option('replication').allowed()) |
Daniel P. Berrangé | 4bb3da4 | 2024-07-12 14:24:44 +0100 | [diff] [blame] | 2519 | config_host_data.set('CONFIG_FSFREEZE', qga_fsfreeze) |
| 2520 | config_host_data.set('CONFIG_FSTRIM', qga_fstrim) |
Paolo Bonzini | 406523f | 2021-10-13 11:43:54 +0200 | [diff] [blame] | 2521 | |
Paolo Bonzini | 69d8de7 | 2021-06-03 11:56:11 +0200 | [diff] [blame] | 2522 | # has_header |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2523 | config_host_data.set('CONFIG_EPOLL', cc.has_header('sys/epoll.h')) |
Paolo Bonzini | d47a8b3 | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2524 | config_host_data.set('CONFIG_LINUX_MAGIC_H', cc.has_header('linux/magic.h')) |
| 2525 | config_host_data.set('CONFIG_VALGRIND_H', cc.has_header('valgrind/valgrind.h')) |
Thomas Huth | 48f670e | 2020-11-18 18:10:52 +0100 | [diff] [blame] | 2526 | config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h')) |
Thomas Huth | 2964be5 | 2020-11-18 18:10:49 +0100 | [diff] [blame] | 2527 | config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h')) |
Michael Vogt | 9729930 | 2024-10-01 17:14:54 +0200 | [diff] [blame] | 2528 | config_host_data.set('HAVE_OPENAT2_H', cc.has_header('linux/openat2.h')) |
Thomas Huth | 2802d91 | 2020-11-18 18:10:48 +0100 | [diff] [blame] | 2529 | config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h')) |
Paolo Bonzini | 69d8de7 | 2021-06-03 11:56:11 +0200 | [diff] [blame] | 2530 | config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h')) |
Thomas Huth | ded5d78 | 2020-11-14 11:10:11 +0100 | [diff] [blame] | 2531 | config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) |
Thomas Huth | 4a9d5f8 | 2020-11-18 18:10:51 +0100 | [diff] [blame] | 2532 | config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2533 | if host_os == 'windows' |
Bin Meng | d409373 | 2022-08-02 15:51:58 +0800 | [diff] [blame] | 2534 | config_host_data.set('HAVE_AFUNIX_H', cc.has_header('afunix.h')) |
| 2535 | endif |
Thomas Huth | ded5d78 | 2020-11-14 11:10:11 +0100 | [diff] [blame] | 2536 | |
Paolo Bonzini | 69d8de7 | 2021-06-03 11:56:11 +0200 | [diff] [blame] | 2537 | # has_function |
Claudio Imbrenda | c891c24 | 2022-08-12 15:34:53 +0200 | [diff] [blame] | 2538 | config_host_data.set('CONFIG_CLOSE_RANGE', cc.has_function('close_range')) |
Paolo Bonzini | a620fbe | 2021-06-03 13:04:47 +0200 | [diff] [blame] | 2539 | config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4')) |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2540 | config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime')) |
| 2541 | config_host_data.set('CONFIG_DUP3', cc.has_function('dup3')) |
| 2542 | config_host_data.set('CONFIG_FALLOCATE', cc.has_function('fallocate')) |
| 2543 | config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate')) |
Paolo Bonzini | 6750485 | 2023-06-21 00:47:31 +0200 | [diff] [blame] | 2544 | config_host_data.set('CONFIG_GETCPU', cc.has_function('getcpu', prefix: gnu_source_prefix)) |
| 2545 | config_host_data.set('CONFIG_SCHED_GETCPU', cc.has_function('sched_getcpu', prefix: '#include <sched.h>')) |
Peter Maydell | 8698343 | 2022-02-26 18:07:19 +0000 | [diff] [blame] | 2546 | # Note that we need to specify prefix: here to avoid incorrectly |
| 2547 | # thinking that Windows has posix_memalign() |
| 2548 | config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include <stdlib.h>')) |
Peter Maydell | 5c8c714 | 2022-02-26 18:07:20 +0000 | [diff] [blame] | 2549 | config_host_data.set('CONFIG_ALIGNED_MALLOC', cc.has_function('_aligned_malloc')) |
Peter Maydell | 88454f8 | 2022-02-26 18:07:21 +0000 | [diff] [blame] | 2550 | config_host_data.set('CONFIG_VALLOC', cc.has_function('valloc')) |
| 2551 | config_host_data.set('CONFIG_MEMALIGN', cc.has_function('memalign')) |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2552 | config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll')) |
Peter Maydell | 2b9f74e | 2021-01-26 15:58:46 +0000 | [diff] [blame] | 2553 | config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>')) |
Keno Fischer | 029ed1b | 2022-02-27 17:35:20 -0500 | [diff] [blame] | 2554 | config_host_data.set('CONFIG_PTHREAD_FCHDIR_NP', cc.has_function('pthread_fchdir_np')) |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2555 | config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile')) |
| 2556 | config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare')) |
| 2557 | config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs')) |
| 2558 | config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range')) |
| 2559 | config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create')) |
Paolo Bonzini | be7e89f | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2560 | config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range')) |
Andrew Deason | 59e35c7 | 2022-04-26 14:55:22 -0500 | [diff] [blame] | 2561 | config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs')) |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 2562 | config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice) |
Manos Pitsidianakis | dc43b18 | 2024-10-03 16:28:48 +0300 | [diff] [blame] | 2563 | config_host_data.set('HAVE_GLIB_WITH_ALIGNED_ALLOC', glib_has_aligned_alloc) |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2564 | config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util)) |
Paolo Bonzini | ed3b3f1 | 2021-06-03 12:14:48 +0200 | [diff] [blame] | 2565 | config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul')) |
Paolo Bonzini | 69d8de7 | 2021-06-03 11:56:11 +0200 | [diff] [blame] | 2566 | config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>')) |
Stefano Garzarella | 66dc5f9 | 2022-05-17 09:10:12 +0200 | [diff] [blame] | 2567 | if rbd.found() |
| 2568 | config_host_data.set('HAVE_RBD_NAMESPACE_EXISTS', |
| 2569 | cc.has_function('rbd_namespace_exists', |
| 2570 | dependencies: rbd, |
| 2571 | prefix: '#include <rbd/librbd.h>')) |
| 2572 | endif |
Li Zhijian | 911965a | 2021-09-10 15:02:55 +0800 | [diff] [blame] | 2573 | if rdma.found() |
| 2574 | config_host_data.set('HAVE_IBV_ADVISE_MR', |
| 2575 | cc.has_function('ibv_advise_mr', |
Paolo Bonzini | 3730a73 | 2022-04-20 17:33:41 +0200 | [diff] [blame] | 2576 | dependencies: rdma, |
Li Zhijian | 911965a | 2021-09-10 15:02:55 +0800 | [diff] [blame] | 2577 | prefix: '#include <infiniband/verbs.h>')) |
| 2578 | endif |
Peter Maydell | 2b9f74e | 2021-01-26 15:58:46 +0000 | [diff] [blame] | 2579 | |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 2580 | have_asan_fiber = false |
Richard Henderson | cb771ac | 2024-08-13 19:52:15 +1000 | [diff] [blame] | 2581 | if get_option('asan') and \ |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 2582 | not cc.has_function('__sanitizer_start_switch_fiber', |
| 2583 | args: '-fsanitize=address', |
| 2584 | prefix: '#include <sanitizer/asan_interface.h>') |
| 2585 | warning('Missing ASAN due to missing fiber annotation interface') |
| 2586 | warning('Without code annotation, the report may be inferior.') |
| 2587 | else |
| 2588 | have_asan_fiber = true |
| 2589 | endif |
| 2590 | config_host_data.set('CONFIG_ASAN_IFACE_FIBER', have_asan_fiber) |
| 2591 | |
Ilya Leoshkevich | a1a9800 | 2024-02-06 01:22:03 +0100 | [diff] [blame] | 2592 | have_inotify_init = cc.has_header_symbol('sys/inotify.h', 'inotify_init') |
| 2593 | have_inotify_init1 = cc.has_header_symbol('sys/inotify.h', 'inotify_init1') |
| 2594 | inotify = not_found |
| 2595 | if (have_inotify_init or have_inotify_init1) and host_os == 'freebsd' |
| 2596 | # libinotify-kqueue |
| 2597 | inotify = cc.find_library('inotify') |
| 2598 | if have_inotify_init |
| 2599 | have_inotify_init = inotify.found() |
| 2600 | endif |
| 2601 | if have_inotify_init1 |
| 2602 | have_inotify_init1 = inotify.found() |
| 2603 | endif |
| 2604 | endif |
| 2605 | config_host_data.set('CONFIG_INOTIFY', have_inotify_init) |
| 2606 | config_host_data.set('CONFIG_INOTIFY1', have_inotify_init1) |
| 2607 | |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2608 | # has_header_symbol |
Sam Li | 6d43eaa | 2023-05-08 12:55:28 +0800 | [diff] [blame] | 2609 | config_host_data.set('CONFIG_BLKZONED', |
| 2610 | cc.has_header_symbol('linux/blkzoned.h', 'BLKOPENZONE')) |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2611 | config_host_data.set('CONFIG_EPOLL_CREATE1', |
| 2612 | cc.has_header_symbol('sys/epoll.h', 'epoll_create1')) |
| 2613 | config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE', |
| 2614 | cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_PUNCH_HOLE') and |
| 2615 | cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_KEEP_SIZE')) |
| 2616 | config_host_data.set('CONFIG_FALLOCATE_ZERO_RANGE', |
| 2617 | cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_ZERO_RANGE')) |
| 2618 | config_host_data.set('CONFIG_FIEMAP', |
| 2619 | cc.has_header('linux/fiemap.h') and |
| 2620 | cc.has_header_symbol('linux/fs.h', 'FS_IOC_FIEMAP')) |
Paolo Bonzini | be7e89f | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2621 | config_host_data.set('CONFIG_GETRANDOM', |
| 2622 | cc.has_function('getrandom') and |
| 2623 | cc.has_header_symbol('sys/random.h', 'GRND_NONBLOCK')) |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2624 | config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK', |
| 2625 | cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK')) |
Paolo Bonzini | be7e89f | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2626 | config_host_data.set('CONFIG_RTNETLINK', |
| 2627 | cc.has_header_symbol('linux/rtnetlink.h', 'IFLA_PROTO_DOWN')) |
| 2628 | config_host_data.set('CONFIG_SYSMACROS', |
| 2629 | cc.has_header_symbol('sys/sysmacros.h', 'makedev')) |
Paolo Bonzini | e1fbd2c | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2630 | config_host_data.set('HAVE_OPTRESET', |
| 2631 | cc.has_header_symbol('getopt.h', 'optreset')) |
Marc-André Lureau | 653163f | 2021-09-07 16:19:13 +0400 | [diff] [blame] | 2632 | config_host_data.set('HAVE_IPPROTO_MPTCP', |
| 2633 | cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP')) |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2634 | |
| 2635 | # has_member |
| 2636 | config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID', |
| 2637 | cc.has_member('struct sigevent', 'sigev_notify_thread_id', |
| 2638 | prefix: '#include <signal.h>')) |
Paolo Bonzini | ed3b3f1 | 2021-06-03 12:14:48 +0200 | [diff] [blame] | 2639 | config_host_data.set('HAVE_STRUCT_STAT_ST_ATIM', |
| 2640 | cc.has_member('struct stat', 'st_atim', |
| 2641 | prefix: '#include <sys/stat.h>')) |
Sam Li | 6d43eaa | 2023-05-08 12:55:28 +0800 | [diff] [blame] | 2642 | config_host_data.set('HAVE_BLK_ZONE_REP_CAPACITY', |
| 2643 | cc.has_member('struct blk_zone', 'capacity', |
| 2644 | prefix: '#include <linux/blkzoned.h>')) |
Paolo Bonzini | e66420a | 2021-06-03 12:10:05 +0200 | [diff] [blame] | 2645 | |
Paolo Bonzini | 6a23f81 | 2021-11-16 08:28:29 +0100 | [diff] [blame] | 2646 | # has_type |
| 2647 | config_host_data.set('CONFIG_IOVEC', |
| 2648 | cc.has_type('struct iovec', |
| 2649 | prefix: '#include <sys/uio.h>')) |
| 2650 | config_host_data.set('HAVE_UTMPX', |
| 2651 | cc.has_type('struct utmpx', |
| 2652 | prefix: '#include <utmpx.h>')) |
| 2653 | |
Paolo Bonzini | 904ad5e | 2021-07-07 16:35:26 +0200 | [diff] [blame] | 2654 | config_host_data.set('CONFIG_EVENTFD', cc.links(''' |
Paolo Bonzini | e1fbd2c | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2655 | #include <sys/eventfd.h> |
| 2656 | int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }''')) |
Paolo Bonzini | 904ad5e | 2021-07-07 16:35:26 +0200 | [diff] [blame] | 2657 | config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + ''' |
Paolo Bonzini | e1fbd2c | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2658 | #include <unistd.h> |
| 2659 | int main(void) { |
| 2660 | #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0 |
| 2661 | return fdatasync(0); |
| 2662 | #else |
| 2663 | #error Not supported |
| 2664 | #endif |
| 2665 | }''')) |
Andrew Deason | 8900c20 | 2022-03-15 22:52:25 -0500 | [diff] [blame] | 2666 | |
| 2667 | has_madvise = cc.links(gnu_source_prefix + ''' |
Paolo Bonzini | e1fbd2c | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2668 | #include <sys/types.h> |
| 2669 | #include <sys/mman.h> |
| 2670 | #include <stddef.h> |
Andrew Deason | 8900c20 | 2022-03-15 22:52:25 -0500 | [diff] [blame] | 2671 | int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }''') |
| 2672 | missing_madvise_proto = false |
| 2673 | if has_madvise |
| 2674 | # Some platforms (illumos and Solaris before Solaris 11) provide madvise() |
| 2675 | # but forget to prototype it. In this case, has_madvise will be true (the |
| 2676 | # test program links despite a compile warning). To detect the |
| 2677 | # missing-prototype case, we try again with a definitely-bogus prototype. |
| 2678 | # This will only compile if the system headers don't provide the prototype; |
| 2679 | # otherwise the conflicting prototypes will cause a compiler error. |
| 2680 | missing_madvise_proto = cc.links(gnu_source_prefix + ''' |
| 2681 | #include <sys/types.h> |
| 2682 | #include <sys/mman.h> |
| 2683 | #include <stddef.h> |
| 2684 | extern int madvise(int); |
| 2685 | int main(void) { return madvise(0); }''') |
| 2686 | endif |
| 2687 | config_host_data.set('CONFIG_MADVISE', has_madvise) |
| 2688 | config_host_data.set('HAVE_MADVISE_WITHOUT_PROTOTYPE', missing_madvise_proto) |
| 2689 | |
Paolo Bonzini | 904ad5e | 2021-07-07 16:35:26 +0200 | [diff] [blame] | 2690 | config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + ''' |
Paolo Bonzini | e1fbd2c | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2691 | #include <sys/mman.h> |
| 2692 | int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }''')) |
Paolo Bonzini | 904ad5e | 2021-07-07 16:35:26 +0200 | [diff] [blame] | 2693 | config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + ''' |
Paolo Bonzini | d47a8b3 | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2694 | #include <fcntl.h> |
| 2695 | #if !defined(AT_EMPTY_PATH) |
| 2696 | # error missing definition |
| 2697 | #else |
| 2698 | int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); } |
| 2699 | #endif''')) |
Michal Privoznik | 12d7d0c | 2024-06-05 12:44:54 +0200 | [diff] [blame] | 2700 | |
| 2701 | # On Darwin posix_madvise() has the same return semantics as plain madvise(), |
| 2702 | # i.e. errno is set and -1 is returned. That's not really how POSIX defines the |
| 2703 | # function. On the flip side, it has madvise() which is preferred anyways. |
| 2704 | if host_os != 'darwin' |
| 2705 | config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + ''' |
| 2706 | #include <sys/mman.h> |
| 2707 | #include <stddef.h> |
| 2708 | int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }''')) |
| 2709 | endif |
Paolo Bonzini | 10f6b23 | 2021-10-07 15:08:19 +0200 | [diff] [blame] | 2710 | |
Paolo Bonzini | 6a23f81 | 2021-11-16 08:28:29 +0100 | [diff] [blame] | 2711 | config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(gnu_source_prefix + ''' |
Paolo Bonzini | 10f6b23 | 2021-10-07 15:08:19 +0200 | [diff] [blame] | 2712 | #include <pthread.h> |
| 2713 | |
| 2714 | static void *f(void *p) { return NULL; } |
| 2715 | int main(void) |
| 2716 | { |
| 2717 | pthread_t thread; |
| 2718 | pthread_create(&thread, 0, f, 0); |
| 2719 | pthread_setname_np(thread, "QEMU"); |
| 2720 | return 0; |
| 2721 | }''', dependencies: threads)) |
Paolo Bonzini | 6a23f81 | 2021-11-16 08:28:29 +0100 | [diff] [blame] | 2722 | config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_prefix + ''' |
Paolo Bonzini | 10f6b23 | 2021-10-07 15:08:19 +0200 | [diff] [blame] | 2723 | #include <pthread.h> |
| 2724 | |
| 2725 | static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; } |
| 2726 | int main(void) |
| 2727 | { |
| 2728 | pthread_t thread; |
| 2729 | pthread_create(&thread, 0, f, 0); |
| 2730 | return 0; |
| 2731 | }''', dependencies: threads)) |
Brad Smith | 3ada67a | 2022-12-18 03:22:04 -0500 | [diff] [blame] | 2732 | config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(gnu_source_prefix + ''' |
| 2733 | #include <pthread.h> |
| 2734 | #include <pthread_np.h> |
| 2735 | |
| 2736 | static void *f(void *p) { return NULL; } |
| 2737 | int main(void) |
| 2738 | { |
| 2739 | pthread_t thread; |
| 2740 | pthread_create(&thread, 0, f, 0); |
| 2741 | pthread_set_name_np(thread, "QEMU"); |
| 2742 | return 0; |
| 2743 | }''', dependencies: threads)) |
Longpeng(Mike) | 657ac98 | 2022-02-22 17:05:05 +0800 | [diff] [blame] | 2744 | config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(gnu_source_prefix + ''' |
| 2745 | #include <pthread.h> |
| 2746 | #include <time.h> |
| 2747 | |
| 2748 | int main(void) |
| 2749 | { |
| 2750 | pthread_condattr_t attr |
| 2751 | pthread_condattr_init(&attr); |
| 2752 | pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); |
| 2753 | return 0; |
| 2754 | }''', dependencies: threads)) |
David Hildenbrand | 7730f32 | 2022-10-14 15:47:15 +0200 | [diff] [blame] | 2755 | config_host_data.set('CONFIG_PTHREAD_AFFINITY_NP', cc.links(gnu_source_prefix + ''' |
| 2756 | #include <pthread.h> |
Paolo Bonzini | 10f6b23 | 2021-10-07 15:08:19 +0200 | [diff] [blame] | 2757 | |
David Hildenbrand | 7730f32 | 2022-10-14 15:47:15 +0200 | [diff] [blame] | 2758 | static void *f(void *p) { return NULL; } |
| 2759 | int main(void) |
| 2760 | { |
| 2761 | int setsize = CPU_ALLOC_SIZE(64); |
| 2762 | pthread_t thread; |
| 2763 | cpu_set_t *cpuset; |
| 2764 | pthread_create(&thread, 0, f, 0); |
| 2765 | cpuset = CPU_ALLOC(64); |
| 2766 | CPU_ZERO_S(setsize, cpuset); |
| 2767 | pthread_setaffinity_np(thread, setsize, cpuset); |
| 2768 | pthread_getaffinity_np(thread, setsize, cpuset); |
| 2769 | CPU_FREE(cpuset); |
| 2770 | return 0; |
| 2771 | }''', dependencies: threads)) |
Paolo Bonzini | 904ad5e | 2021-07-07 16:35:26 +0200 | [diff] [blame] | 2772 | config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + ''' |
Kacper Słomiński | 6bd17dc | 2021-09-05 03:16:22 +0200 | [diff] [blame] | 2773 | #include <sys/signalfd.h> |
| 2774 | #include <stddef.h> |
| 2775 | int main(void) { return signalfd(-1, NULL, SFD_CLOEXEC); }''')) |
Paolo Bonzini | 904ad5e | 2021-07-07 16:35:26 +0200 | [diff] [blame] | 2776 | config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + ''' |
Paolo Bonzini | a620fbe | 2021-06-03 13:04:47 +0200 | [diff] [blame] | 2777 | #include <unistd.h> |
| 2778 | #include <fcntl.h> |
| 2779 | #include <limits.h> |
| 2780 | |
| 2781 | int main(void) |
| 2782 | { |
| 2783 | int len, fd = 0; |
| 2784 | len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK); |
| 2785 | splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE); |
| 2786 | return 0; |
| 2787 | }''')) |
Paolo Bonzini | e1fbd2c | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 2788 | |
Paolo Bonzini | 96a63ae | 2021-10-07 15:08:18 +0200 | [diff] [blame] | 2789 | config_host_data.set('HAVE_MLOCKALL', cc.links(gnu_source_prefix + ''' |
| 2790 | #include <sys/mman.h> |
Paolo Bonzini | b5d3dac | 2022-11-03 18:19:18 +0100 | [diff] [blame] | 2791 | int main(void) { |
Paolo Bonzini | 96a63ae | 2021-10-07 15:08:18 +0200 | [diff] [blame] | 2792 | return mlockall(MCL_FUTURE); |
| 2793 | }''')) |
| 2794 | |
Thomas Huth | eea9453 | 2021-10-28 20:59:08 +0200 | [diff] [blame] | 2795 | have_l2tpv3 = false |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2796 | if get_option('l2tpv3').allowed() and have_system |
Paolo Bonzini | 6a23f81 | 2021-11-16 08:28:29 +0100 | [diff] [blame] | 2797 | have_l2tpv3 = cc.has_type('struct mmsghdr', |
| 2798 | prefix: gnu_source_prefix + ''' |
| 2799 | #include <sys/socket.h> |
| 2800 | #include <linux/ip.h>''') |
Thomas Huth | eea9453 | 2021-10-28 20:59:08 +0200 | [diff] [blame] | 2801 | endif |
| 2802 | config_host_data.set('CONFIG_L2TPV3', have_l2tpv3) |
| 2803 | |
Paolo Bonzini | 837b84b | 2021-10-07 15:08:22 +0200 | [diff] [blame] | 2804 | have_netmap = false |
Paolo Bonzini | 43a363a | 2021-12-18 16:39:43 +0100 | [diff] [blame] | 2805 | if get_option('netmap').allowed() and have_system |
Paolo Bonzini | 837b84b | 2021-10-07 15:08:22 +0200 | [diff] [blame] | 2806 | have_netmap = cc.compiles(''' |
| 2807 | #include <inttypes.h> |
| 2808 | #include <net/if.h> |
| 2809 | #include <net/netmap.h> |
| 2810 | #include <net/netmap_user.h> |
| 2811 | #if (NETMAP_API < 11) || (NETMAP_API > 15) |
| 2812 | #error |
| 2813 | #endif |
| 2814 | int main(void) { return 0; }''') |
| 2815 | if not have_netmap and get_option('netmap').enabled() |
| 2816 | error('Netmap headers not available') |
| 2817 | endif |
| 2818 | endif |
| 2819 | config_host_data.set('CONFIG_NETMAP', have_netmap) |
| 2820 | |
Paolo Bonzini | 96a63ae | 2021-10-07 15:08:18 +0200 | [diff] [blame] | 2821 | # Work around a system header bug with some kernel/XFS header |
| 2822 | # versions where they both try to define 'struct fsxattr': |
| 2823 | # xfs headers will not try to redefine structs from linux headers |
| 2824 | # if this macro is set. |
| 2825 | config_host_data.set('HAVE_FSXATTR', cc.links(''' |
Paolo Bonzini | 6a23f81 | 2021-11-16 08:28:29 +0100 | [diff] [blame] | 2826 | #include <linux/fs.h> |
Paolo Bonzini | 96a63ae | 2021-10-07 15:08:18 +0200 | [diff] [blame] | 2827 | struct fsxattr foo; |
| 2828 | int main(void) { |
| 2829 | return 0; |
| 2830 | }''')) |
| 2831 | |
Paolo Bonzini | e46bd55 | 2021-06-03 11:57:04 +0200 | [diff] [blame] | 2832 | # Some versions of Mac OS X incorrectly define SIZE_MAX |
| 2833 | config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles(''' |
| 2834 | #include <stdint.h> |
| 2835 | #include <stdio.h> |
Paolo Bonzini | b5d3dac | 2022-11-03 18:19:18 +0100 | [diff] [blame] | 2836 | int main(void) { |
Paolo Bonzini | e46bd55 | 2021-06-03 11:57:04 +0200 | [diff] [blame] | 2837 | return printf("%zu", SIZE_MAX); |
| 2838 | }''', args: ['-Werror'])) |
| 2839 | |
Richard Henderson | e61f1ef | 2022-11-05 11:34:58 +0000 | [diff] [blame] | 2840 | # See if 64-bit atomic operations are supported. |
| 2841 | # Note that without __atomic builtins, we can only |
| 2842 | # assume atomic loads/stores max at pointer size. |
| 2843 | config_host_data.set('CONFIG_ATOMIC64', cc.links(''' |
Paolo Bonzini | bd87a36 | 2021-10-07 15:08:25 +0200 | [diff] [blame] | 2844 | #include <stdint.h> |
| 2845 | int main(void) |
| 2846 | { |
Richard Henderson | e61f1ef | 2022-11-05 11:34:58 +0000 | [diff] [blame] | 2847 | uint64_t x = 0, y = 0; |
Paolo Bonzini | bd87a36 | 2021-10-07 15:08:25 +0200 | [diff] [blame] | 2848 | y = __atomic_load_n(&x, __ATOMIC_RELAXED); |
| 2849 | __atomic_store_n(&x, y, __ATOMIC_RELAXED); |
| 2850 | __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED); |
| 2851 | __atomic_exchange_n(&x, y, __ATOMIC_RELAXED); |
| 2852 | __atomic_fetch_add(&x, y, __ATOMIC_RELAXED); |
| 2853 | return 0; |
Paolo Bonzini | 8db4e0f | 2024-10-06 09:44:00 +0200 | [diff] [blame] | 2854 | }''', args: qemu_isa_flags)) |
Paolo Bonzini | bd87a36 | 2021-10-07 15:08:25 +0200 | [diff] [blame] | 2855 | |
Richard Henderson | 6479dd7 | 2023-05-24 08:14:41 -0700 | [diff] [blame] | 2856 | has_int128_type = cc.compiles(''' |
| 2857 | __int128_t a; |
| 2858 | __uint128_t b; |
| 2859 | int main(void) { b = a; }''') |
| 2860 | config_host_data.set('CONFIG_INT128_TYPE', has_int128_type) |
| 2861 | |
| 2862 | has_int128 = has_int128_type and cc.links(''' |
Marc-André Lureau | 848126d | 2022-02-28 15:49:19 +0400 | [diff] [blame] | 2863 | __int128_t a; |
| 2864 | __uint128_t b; |
| 2865 | int main (void) { |
| 2866 | a = a + b; |
| 2867 | b = a * b; |
| 2868 | a = a * a; |
| 2869 | return 0; |
| 2870 | }''') |
Marc-André Lureau | 848126d | 2022-02-28 15:49:19 +0400 | [diff] [blame] | 2871 | config_host_data.set('CONFIG_INT128', has_int128) |
| 2872 | |
Richard Henderson | 6479dd7 | 2023-05-24 08:14:41 -0700 | [diff] [blame] | 2873 | if has_int128_type |
Marc-André Lureau | d2958fb | 2022-02-28 16:03:09 +0400 | [diff] [blame] | 2874 | # "do we have 128-bit atomics which are handled inline and specifically not |
| 2875 | # via libatomic". The reason we can't use libatomic is documented in the |
| 2876 | # comment starting "GCC is a house divided" in include/qemu/atomic128.h. |
Richard Henderson | e61f1ef | 2022-11-05 11:34:58 +0000 | [diff] [blame] | 2877 | # We only care about these operations on 16-byte aligned pointers, so |
| 2878 | # force 16-byte alignment of the pointer, which may be greater than |
| 2879 | # __alignof(unsigned __int128) for the host. |
| 2880 | atomic_test_128 = ''' |
| 2881 | int main(int ac, char **av) { |
Richard Henderson | 6479dd7 | 2023-05-24 08:14:41 -0700 | [diff] [blame] | 2882 | __uint128_t *p = __builtin_assume_aligned(av[ac - 1], 16); |
Richard Henderson | e61f1ef | 2022-11-05 11:34:58 +0000 | [diff] [blame] | 2883 | p[1] = __atomic_load_n(&p[0], __ATOMIC_RELAXED); |
| 2884 | __atomic_store_n(&p[2], p[3], __ATOMIC_RELAXED); |
| 2885 | __atomic_compare_exchange_n(&p[4], &p[5], p[6], 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED); |
| 2886 | return 0; |
| 2887 | }''' |
Paolo Bonzini | 8db4e0f | 2024-10-06 09:44:00 +0200 | [diff] [blame] | 2888 | has_atomic128 = cc.links(atomic_test_128, args: qemu_isa_flags) |
Marc-André Lureau | 848126d | 2022-02-28 15:49:19 +0400 | [diff] [blame] | 2889 | |
| 2890 | config_host_data.set('CONFIG_ATOMIC128', has_atomic128) |
| 2891 | |
| 2892 | if not has_atomic128 |
Richard Henderson | e61f1ef | 2022-11-05 11:34:58 +0000 | [diff] [blame] | 2893 | # Even with __builtin_assume_aligned, the above test may have failed |
| 2894 | # without optimization enabled. Try again with optimizations locally |
| 2895 | # enabled for the function. See |
| 2896 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107389 |
Paolo Bonzini | 8db4e0f | 2024-10-06 09:44:00 +0200 | [diff] [blame] | 2897 | has_atomic128_opt = cc.links('__attribute__((optimize("O1")))' + atomic_test_128, |
| 2898 | args: qemu_isa_flags) |
Richard Henderson | e61f1ef | 2022-11-05 11:34:58 +0000 | [diff] [blame] | 2899 | config_host_data.set('CONFIG_ATOMIC128_OPT', has_atomic128_opt) |
Marc-André Lureau | 848126d | 2022-02-28 15:49:19 +0400 | [diff] [blame] | 2900 | |
Richard Henderson | e61f1ef | 2022-11-05 11:34:58 +0000 | [diff] [blame] | 2901 | if not has_atomic128_opt |
| 2902 | config_host_data.set('CONFIG_CMPXCHG128', cc.links(''' |
| 2903 | int main(void) |
| 2904 | { |
Richard Henderson | 6479dd7 | 2023-05-24 08:14:41 -0700 | [diff] [blame] | 2905 | __uint128_t x = 0, y = 0; |
Richard Henderson | e61f1ef | 2022-11-05 11:34:58 +0000 | [diff] [blame] | 2906 | __sync_val_compare_and_swap_16(&x, y, x); |
| 2907 | return 0; |
| 2908 | } |
Paolo Bonzini | 8db4e0f | 2024-10-06 09:44:00 +0200 | [diff] [blame] | 2909 | ''', args: qemu_isa_flags)) |
Richard Henderson | e61f1ef | 2022-11-05 11:34:58 +0000 | [diff] [blame] | 2910 | endif |
Marc-André Lureau | 848126d | 2022-02-28 15:49:19 +0400 | [diff] [blame] | 2911 | endif |
| 2912 | endif |
Paolo Bonzini | bd87a36 | 2021-10-07 15:08:25 +0200 | [diff] [blame] | 2913 | |
| 2914 | config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + ''' |
| 2915 | #include <sys/auxv.h> |
| 2916 | int main(void) { |
| 2917 | return getauxval(AT_HWCAP) == 0; |
| 2918 | }''')) |
| 2919 | |
Brad Smith | 27fca0a | 2024-07-27 23:58:55 -0400 | [diff] [blame] | 2920 | config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(gnu_source_prefix + ''' |
| 2921 | #include <sys/auxv.h> |
| 2922 | int main(void) { |
| 2923 | unsigned long hwcap = 0; |
| 2924 | elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); |
| 2925 | return hwcap; |
| 2926 | }''')) |
| 2927 | |
Paolo Bonzini | 0dae95d | 2022-04-20 17:33:43 +0200 | [diff] [blame] | 2928 | config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles(''' |
| 2929 | #include <linux/usbdevice_fs.h> |
| 2930 | |
| 2931 | #ifndef USBDEVFS_GET_CAPABILITIES |
| 2932 | #error "USBDEVFS_GET_CAPABILITIES undefined" |
| 2933 | #endif |
| 2934 | |
| 2935 | #ifndef USBDEVFS_DISCONNECT_CLAIM |
| 2936 | #error "USBDEVFS_DISCONNECT_CLAIM undefined" |
| 2937 | #endif |
| 2938 | |
| 2939 | int main(void) { return 0; }''')) |
| 2940 | |
Paolo Bonzini | 2edd2c0 | 2022-04-20 17:33:42 +0200 | [diff] [blame] | 2941 | have_keyring = get_option('keyring') \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 2942 | .require(host_os == 'linux', error_message: 'keyring is only available on Linux') \ |
Paolo Bonzini | 2edd2c0 | 2022-04-20 17:33:42 +0200 | [diff] [blame] | 2943 | .require(cc.compiles(''' |
| 2944 | #include <errno.h> |
| 2945 | #include <asm/unistd.h> |
| 2946 | #include <linux/keyctl.h> |
| 2947 | #include <sys/syscall.h> |
| 2948 | #include <unistd.h> |
| 2949 | int main(void) { |
| 2950 | return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0); |
| 2951 | }'''), error_message: 'keyctl syscall not available on this system').allowed() |
| 2952 | config_host_data.set('CONFIG_SECRET_KEYRING', have_keyring) |
| 2953 | |
Paolo Bonzini | 622753d | 2021-11-08 13:38:58 +0100 | [diff] [blame] | 2954 | have_cpuid_h = cc.links(''' |
| 2955 | #include <cpuid.h> |
| 2956 | int main(void) { |
| 2957 | unsigned a, b, c, d; |
| 2958 | unsigned max = __get_cpuid_max(0, 0); |
| 2959 | |
| 2960 | if (max >= 1) { |
| 2961 | __cpuid(1, a, b, c, d); |
| 2962 | } |
| 2963 | |
| 2964 | if (max >= 7) { |
| 2965 | __cpuid_count(7, 0, a, b, c, d); |
| 2966 | } |
| 2967 | |
| 2968 | return 0; |
| 2969 | }''') |
| 2970 | config_host_data.set('CONFIG_CPUID_H', have_cpuid_h) |
| 2971 | |
Richard Henderson | e571730 | 2024-06-27 17:36:43 +0000 | [diff] [blame] | 2972 | # Don't bother to advertise asm/hwprobe.h for old versions that do |
| 2973 | # not contain RISCV_HWPROBE_EXT_ZBA. |
| 2974 | config_host_data.set('CONFIG_ASM_HWPROBE_H', |
| 2975 | cc.has_header_symbol('asm/hwprobe.h', |
| 2976 | 'RISCV_HWPROBE_EXT_ZBA')) |
| 2977 | |
Paolo Bonzini | 622753d | 2021-11-08 13:38:58 +0100 | [diff] [blame] | 2978 | config_host_data.set('CONFIG_AVX2_OPT', get_option('avx2') \ |
| 2979 | .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX2') \ |
| 2980 | .require(cc.links(''' |
Paolo Bonzini | 622753d | 2021-11-08 13:38:58 +0100 | [diff] [blame] | 2981 | #include <cpuid.h> |
| 2982 | #include <immintrin.h> |
Richard Henderson | 701ea58 | 2022-12-03 19:31:12 -0600 | [diff] [blame] | 2983 | static int __attribute__((target("avx2"))) bar(void *a) { |
Paolo Bonzini | 622753d | 2021-11-08 13:38:58 +0100 | [diff] [blame] | 2984 | __m256i x = *(__m256i *)a; |
| 2985 | return _mm256_testz_si256(x, x); |
| 2986 | } |
Paolo Bonzini | b5d3dac | 2022-11-03 18:19:18 +0100 | [diff] [blame] | 2987 | int main(int argc, char *argv[]) { return bar(argv[argc - 1]); } |
Paolo Bonzini | 622753d | 2021-11-08 13:38:58 +0100 | [diff] [blame] | 2988 | '''), error_message: 'AVX2 not available').allowed()) |
| 2989 | |
ling xu | 04ffce1 | 2022-11-16 23:29:22 +0800 | [diff] [blame] | 2990 | config_host_data.set('CONFIG_AVX512BW_OPT', get_option('avx512bw') \ |
| 2991 | .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512BW') \ |
| 2992 | .require(cc.links(''' |
ling xu | 04ffce1 | 2022-11-16 23:29:22 +0800 | [diff] [blame] | 2993 | #include <cpuid.h> |
| 2994 | #include <immintrin.h> |
Richard Henderson | dc165fc | 2023-05-01 22:05:55 +0100 | [diff] [blame] | 2995 | static int __attribute__((target("avx512bw"))) bar(void *a) { |
ling xu | 04ffce1 | 2022-11-16 23:29:22 +0800 | [diff] [blame] | 2996 | __m512i *x = a; |
| 2997 | __m512i res= _mm512_abs_epi8(*x); |
| 2998 | return res[1]; |
| 2999 | } |
| 3000 | int main(int argc, char *argv[]) { return bar(argv[0]); } |
| 3001 | '''), error_message: 'AVX512BW not available').allowed()) |
| 3002 | |
Richard Henderson | 8d97f28 | 2023-06-02 07:43:40 +0000 | [diff] [blame] | 3003 | # For both AArch64 and AArch32, detect if builtins are available. |
| 3004 | config_host_data.set('CONFIG_ARM_AES_BUILTIN', cc.compiles(''' |
| 3005 | #include <arm_neon.h> |
| 3006 | #ifndef __ARM_FEATURE_AES |
| 3007 | __attribute__((target("+crypto"))) |
| 3008 | #endif |
| 3009 | void foo(uint8x16_t *p) { *p = vaesmcq_u8(*p); } |
| 3010 | ''')) |
| 3011 | |
Paolo Bonzini | b87df90 | 2021-11-08 13:52:11 +0100 | [diff] [blame] | 3012 | if get_option('membarrier').disabled() |
| 3013 | have_membarrier = false |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 3014 | elif host_os == 'windows' |
Paolo Bonzini | b87df90 | 2021-11-08 13:52:11 +0100 | [diff] [blame] | 3015 | have_membarrier = true |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 3016 | elif host_os == 'linux' |
Paolo Bonzini | b87df90 | 2021-11-08 13:52:11 +0100 | [diff] [blame] | 3017 | have_membarrier = cc.compiles(''' |
| 3018 | #include <linux/membarrier.h> |
| 3019 | #include <sys/syscall.h> |
| 3020 | #include <unistd.h> |
| 3021 | #include <stdlib.h> |
| 3022 | int main(void) { |
| 3023 | syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0); |
| 3024 | syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0); |
| 3025 | exit(0); |
| 3026 | }''') |
| 3027 | endif |
| 3028 | config_host_data.set('CONFIG_MEMBARRIER', get_option('membarrier') \ |
| 3029 | .require(have_membarrier, error_message: 'membarrier system call not available') \ |
| 3030 | .allowed()) |
| 3031 | |
Paolo Bonzini | 34b5261 | 2021-11-08 14:02:42 +0100 | [diff] [blame] | 3032 | have_afalg = get_option('crypto_afalg') \ |
| 3033 | .require(cc.compiles(gnu_source_prefix + ''' |
| 3034 | #include <errno.h> |
| 3035 | #include <sys/types.h> |
| 3036 | #include <sys/socket.h> |
| 3037 | #include <linux/if_alg.h> |
| 3038 | int main(void) { |
| 3039 | int sock; |
| 3040 | sock = socket(AF_ALG, SOCK_SEQPACKET, 0); |
| 3041 | return sock; |
| 3042 | } |
| 3043 | '''), error_message: 'AF_ALG requested but could not be detected').allowed() |
| 3044 | config_host_data.set('CONFIG_AF_ALG', have_afalg) |
| 3045 | |
Marc-André Lureau | 9d734b8 | 2022-04-01 15:50:05 +0400 | [diff] [blame] | 3046 | config_host_data.set('CONFIG_AF_VSOCK', cc.has_header_symbol( |
| 3047 | 'linux/vm_sockets.h', 'AF_VSOCK', |
| 3048 | prefix: '#include <sys/socket.h>', |
| 3049 | )) |
Paolo Bonzini | bd87a36 | 2021-10-07 15:08:25 +0200 | [diff] [blame] | 3050 | |
Marc-André Lureau | 8821a38 | 2022-02-01 16:53:43 +0400 | [diff] [blame] | 3051 | have_vss = false |
Marc-André Lureau | 872b69e | 2022-02-22 23:40:02 +0400 | [diff] [blame] | 3052 | have_vss_sdk = false # old xp/2003 SDK |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 3053 | if host_os == 'windows' and 'cpp' in all_languages |
Marc-André Lureau | 8821a38 | 2022-02-01 16:53:43 +0400 | [diff] [blame] | 3054 | have_vss = cxx.compiles(''' |
| 3055 | #define __MIDL_user_allocate_free_DEFINED__ |
Marc-André Lureau | 32478cb | 2022-02-22 23:40:01 +0400 | [diff] [blame] | 3056 | #include <vss.h> |
Marc-André Lureau | 8821a38 | 2022-02-01 16:53:43 +0400 | [diff] [blame] | 3057 | int main(void) { return VSS_CTX_BACKUP; }''') |
Marc-André Lureau | 872b69e | 2022-02-22 23:40:02 +0400 | [diff] [blame] | 3058 | have_vss_sdk = cxx.has_header('vscoordint.h') |
Marc-André Lureau | 8821a38 | 2022-02-01 16:53:43 +0400 | [diff] [blame] | 3059 | endif |
Marc-André Lureau | 872b69e | 2022-02-22 23:40:02 +0400 | [diff] [blame] | 3060 | config_host_data.set('HAVE_VSS_SDK', have_vss_sdk) |
Marc-André Lureau | 8821a38 | 2022-02-01 16:53:43 +0400 | [diff] [blame] | 3061 | |
Richard Henderson | 6391c77 | 2022-04-17 11:30:06 -0700 | [diff] [blame] | 3062 | # Older versions of MinGW do not import _lock_file and _unlock_file properly. |
| 3063 | # This was fixed for v6.0.0 with commit b48e3ac8969d. |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 3064 | if host_os == 'windows' |
Richard Henderson | 6391c77 | 2022-04-17 11:30:06 -0700 | [diff] [blame] | 3065 | config_host_data.set('HAVE__LOCK_FILE', cc.links(''' |
| 3066 | #include <stdio.h> |
| 3067 | int main(void) { |
| 3068 | _lock_file(NULL); |
| 3069 | _unlock_file(NULL); |
| 3070 | return 0; |
| 3071 | }''', name: '_lock_file and _unlock_file')) |
| 3072 | endif |
| 3073 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 3074 | if host_os == 'windows' |
Pierrick Bouvier | dbd672c | 2023-02-21 16:30:04 +0100 | [diff] [blame] | 3075 | mingw_has_setjmp_longjmp = cc.links(''' |
| 3076 | #include <setjmp.h> |
| 3077 | int main(void) { |
| 3078 | /* |
| 3079 | * These functions are not available in setjmp header, but may be |
| 3080 | * available at link time, from libmingwex.a. |
| 3081 | */ |
| 3082 | extern int __mingw_setjmp(jmp_buf); |
| 3083 | extern void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int); |
| 3084 | jmp_buf env; |
| 3085 | __mingw_setjmp(env); |
| 3086 | __mingw_longjmp(env, 0); |
| 3087 | } |
| 3088 | ''', name: 'mingw setjmp and longjmp') |
| 3089 | |
| 3090 | if cpu == 'aarch64' and not mingw_has_setjmp_longjmp |
| 3091 | error('mingw must provide setjmp/longjmp for windows-arm64') |
| 3092 | endif |
| 3093 | endif |
| 3094 | |
Paolo Bonzini | a0c9162 | 2020-10-07 11:01:51 -0400 | [diff] [blame] | 3095 | ######################## |
| 3096 | # Target configuration # |
| 3097 | ######################## |
| 3098 | |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3099 | minikconf = find_program('scripts/minikconf.py') |
Paolo Bonzini | 1f2146f | 2023-08-30 11:39:45 +0200 | [diff] [blame] | 3100 | |
Paolo Bonzini | cfc1a88 | 2023-09-29 11:40:03 +0200 | [diff] [blame] | 3101 | config_all_accel = {} |
Paolo Bonzini | a98006b | 2020-09-01 05:32:23 -0400 | [diff] [blame] | 3102 | config_all_devices = {} |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3103 | config_devices_mak_list = [] |
| 3104 | config_devices_h = {} |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 3105 | config_target_h = {} |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3106 | config_target_mak = {} |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3107 | |
| 3108 | disassemblers = { |
| 3109 | 'alpha' : ['CONFIG_ALPHA_DIS'], |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3110 | 'avr' : ['CONFIG_AVR_DIS'], |
Taylor Simpson | 3e7a84e | 2021-02-07 23:46:24 -0600 | [diff] [blame] | 3111 | 'hexagon' : ['CONFIG_HEXAGON_DIS'], |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3112 | 'hppa' : ['CONFIG_HPPA_DIS'], |
| 3113 | 'i386' : ['CONFIG_I386_DIS'], |
| 3114 | 'x86_64' : ['CONFIG_I386_DIS'], |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3115 | 'm68k' : ['CONFIG_M68K_DIS'], |
| 3116 | 'microblaze' : ['CONFIG_MICROBLAZE_DIS'], |
| 3117 | 'mips' : ['CONFIG_MIPS_DIS'], |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3118 | 'or1k' : ['CONFIG_OPENRISC_DIS'], |
| 3119 | 'ppc' : ['CONFIG_PPC_DIS'], |
| 3120 | 'riscv' : ['CONFIG_RISCV_DIS'], |
| 3121 | 'rx' : ['CONFIG_RX_DIS'], |
| 3122 | 's390' : ['CONFIG_S390_DIS'], |
| 3123 | 'sh4' : ['CONFIG_SH4_DIS'], |
| 3124 | 'sparc' : ['CONFIG_SPARC_DIS'], |
| 3125 | 'xtensa' : ['CONFIG_XTENSA_DIS'], |
Song Gao | aae1746 | 2022-06-06 20:43:06 +0800 | [diff] [blame] | 3126 | 'loongarch' : ['CONFIG_LOONGARCH_DIS'], |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3127 | } |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3128 | |
Paolo Bonzini | e1fbd2c | 2021-06-03 12:02:00 +0200 | [diff] [blame] | 3129 | have_ivshmem = config_host_data.get('CONFIG_EVENTFD') |
Paolo Bonzini | 0a18911 | 2020-11-17 14:58:32 +0100 | [diff] [blame] | 3130 | host_kconfig = \ |
Paolo Bonzini | 537b724 | 2021-10-07 15:08:12 +0200 | [diff] [blame] | 3131 | (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \ |
Paolo Bonzini | 0d04c4c | 2021-12-21 12:38:27 +0100 | [diff] [blame] | 3132 | (have_tpm ? ['CONFIG_TPM=y'] : []) + \ |
Marc-André Lureau | cca1575 | 2023-08-30 13:38:25 +0400 | [diff] [blame] | 3133 | (pixman.found() ? ['CONFIG_PIXMAN=y'] : []) + \ |
Marc-André Lureau | 3f0a5d5 | 2021-10-07 15:08:23 +0200 | [diff] [blame] | 3134 | (spice.found() ? ['CONFIG_SPICE=y'] : []) + \ |
Paolo Bonzini | ccd250a | 2021-06-03 12:50:17 +0200 | [diff] [blame] | 3135 | (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \ |
Paolo Bonzini | 88b6e61 | 2022-04-20 17:33:40 +0200 | [diff] [blame] | 3136 | (opengl.found() ? ['CONFIG_OPENGL=y'] : []) + \ |
Dorjoy Chowdhury | bb154e3 | 2024-10-09 03:17:23 +0600 | [diff] [blame] | 3137 | (libcbor.found() ? ['CONFIG_LIBCBOR=y'] : []) + \ |
Dorjoy Chowdhury | 63d2a5c | 2024-10-09 03:17:24 +0600 | [diff] [blame] | 3138 | (gnutls.found() ? ['CONFIG_GNUTLS=y'] : []) + \ |
Paolo Bonzini | 9d71037 | 2021-01-07 13:54:22 +0100 | [diff] [blame] | 3139 | (x11.found() ? ['CONFIG_X11=y'] : []) + \ |
Paolo Bonzini | 1935b7e | 2024-05-07 14:13:46 +0200 | [diff] [blame] | 3140 | (fdt.found() ? ['CONFIG_FDT=y'] : []) + \ |
Paolo Bonzini | 2a3129a | 2022-04-20 17:34:05 +0200 | [diff] [blame] | 3141 | (have_vhost_user ? ['CONFIG_VHOST_USER=y'] : []) + \ |
| 3142 | (have_vhost_vdpa ? ['CONFIG_VHOST_VDPA=y'] : []) + \ |
| 3143 | (have_vhost_kernel ? ['CONFIG_VHOST_KERNEL=y'] : []) + \ |
Paolo Bonzini | 69202b4 | 2020-11-17 14:46:21 +0100 | [diff] [blame] | 3144 | (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \ |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 3145 | (host_os == 'linux' ? ['CONFIG_LINUX=y'] : []) + \ |
Jagannathan Raman | 5511696 | 2022-06-13 16:26:24 -0400 | [diff] [blame] | 3146 | (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : []) + \ |
Maciej S. Szmigiero | 0d9e8c0 | 2023-06-12 16:00:54 +0200 | [diff] [blame] | 3147 | (vfio_user_server_allowed ? ['CONFIG_VFIO_USER_SERVER_ALLOWED=y'] : []) + \ |
Manos Pitsidianakis | 764a6ee | 2024-10-03 16:28:44 +0300 | [diff] [blame] | 3148 | (hv_balloon ? ['CONFIG_HV_BALLOON_POSSIBLE=y'] : []) + \ |
| 3149 | (have_rust ? ['CONFIG_HAVE_RUST=y'] : []) |
Paolo Bonzini | 0a18911 | 2020-11-17 14:58:32 +0100 | [diff] [blame] | 3150 | |
Paolo Bonzini | a9a7490 | 2020-09-21 05:11:01 -0400 | [diff] [blame] | 3151 | ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ] |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3152 | |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 3153 | default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host |
| 3154 | actual_target_dirs = [] |
Paolo Bonzini | fbb4121 | 2020-10-05 11:31:15 +0200 | [diff] [blame] | 3155 | fdt_required = [] |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3156 | foreach target : target_dirs |
Paolo Bonzini | 765686d | 2020-09-18 06:37:21 -0400 | [diff] [blame] | 3157 | config_target = { 'TARGET_NAME': target.split('-')[0] } |
| 3158 | if target.endswith('linux-user') |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 3159 | if host_os != 'linux' |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 3160 | if default_targets |
| 3161 | continue |
| 3162 | endif |
| 3163 | error('Target @0@ is only available on a Linux host'.format(target)) |
| 3164 | endif |
Paolo Bonzini | 765686d | 2020-09-18 06:37:21 -0400 | [diff] [blame] | 3165 | config_target += { 'CONFIG_LINUX_USER': 'y' } |
| 3166 | elif target.endswith('bsd-user') |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 3167 | if host_os not in bsd_oses |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 3168 | if default_targets |
| 3169 | continue |
| 3170 | endif |
| 3171 | error('Target @0@ is only available on a BSD host'.format(target)) |
| 3172 | endif |
Paolo Bonzini | 765686d | 2020-09-18 06:37:21 -0400 | [diff] [blame] | 3173 | config_target += { 'CONFIG_BSD_USER': 'y' } |
| 3174 | elif target.endswith('softmmu') |
Philippe Mathieu-Daudé | bd0c03b | 2023-06-13 15:33:45 +0200 | [diff] [blame] | 3175 | config_target += { 'CONFIG_SYSTEM_ONLY': 'y' } |
Paolo Bonzini | 765686d | 2020-09-18 06:37:21 -0400 | [diff] [blame] | 3176 | config_target += { 'CONFIG_SOFTMMU': 'y' } |
| 3177 | endif |
| 3178 | if target.endswith('-user') |
| 3179 | config_target += { |
| 3180 | 'CONFIG_USER_ONLY': 'y', |
| 3181 | 'CONFIG_QEMU_INTERP_PREFIX': |
Paolo Bonzini | ce6119d | 2022-04-20 17:33:55 +0200 | [diff] [blame] | 3182 | get_option('interp_prefix').replace('%M', config_target['TARGET_NAME']) |
Paolo Bonzini | 765686d | 2020-09-18 06:37:21 -0400 | [diff] [blame] | 3183 | } |
| 3184 | endif |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 3185 | |
Paolo Bonzini | bae3e3a | 2024-01-29 11:53:17 +0100 | [diff] [blame] | 3186 | target_kconfig = [] |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 3187 | foreach sym: accelerators |
| 3188 | if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, []) |
| 3189 | config_target += { sym: 'y' } |
Paolo Bonzini | cfc1a88 | 2023-09-29 11:40:03 +0200 | [diff] [blame] | 3190 | config_all_accel += { sym: 'y' } |
Gerd Hoffmann | dae0ec1 | 2021-06-24 12:38:31 +0200 | [diff] [blame] | 3191 | if target in modular_tcg |
| 3192 | config_target += { 'CONFIG_TCG_MODULAR': 'y' } |
| 3193 | else |
| 3194 | config_target += { 'CONFIG_TCG_BUILTIN': 'y' } |
| 3195 | endif |
Paolo Bonzini | bae3e3a | 2024-01-29 11:53:17 +0100 | [diff] [blame] | 3196 | target_kconfig += [ sym + '=y' ] |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 3197 | endif |
| 3198 | endforeach |
Paolo Bonzini | bae3e3a | 2024-01-29 11:53:17 +0100 | [diff] [blame] | 3199 | if target_kconfig.length() == 0 |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 3200 | if default_targets |
| 3201 | continue |
| 3202 | endif |
| 3203 | error('No accelerator available for target @0@'.format(target)) |
| 3204 | endif |
Paolo Bonzini | 8a19980 | 2020-09-18 05:37:01 -0400 | [diff] [blame] | 3205 | |
Alex Bennée | 812b31d | 2021-07-07 14:17:43 +0100 | [diff] [blame] | 3206 | config_target += keyval.load('configs/targets' / target + '.mak') |
Paolo Bonzini | a9a7490 | 2020-09-21 05:11:01 -0400 | [diff] [blame] | 3207 | config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' } |
Paolo Bonzini | 765686d | 2020-09-18 06:37:21 -0400 | [diff] [blame] | 3208 | |
Paolo Bonzini | 7a6f334 | 2024-01-25 12:22:57 +0100 | [diff] [blame] | 3209 | if 'TARGET_NEED_FDT' in config_target and not fdt.found() |
Paolo Bonzini | 9b089d2 | 2024-05-08 09:25:48 +0200 | [diff] [blame] | 3210 | if default_targets |
| 3211 | warning('Disabling ' + target + ' due to missing libfdt') |
| 3212 | else |
| 3213 | fdt_required += target |
| 3214 | endif |
Paolo Bonzini | 7a6f334 | 2024-01-25 12:22:57 +0100 | [diff] [blame] | 3215 | continue |
Paolo Bonzini | fbb4121 | 2020-10-05 11:31:15 +0200 | [diff] [blame] | 3216 | endif |
| 3217 | |
Paolo Bonzini | 7a6f334 | 2024-01-25 12:22:57 +0100 | [diff] [blame] | 3218 | actual_target_dirs += target |
| 3219 | |
Paolo Bonzini | fa73168 | 2020-09-21 05:19:07 -0400 | [diff] [blame] | 3220 | # Add default keys |
| 3221 | if 'TARGET_BASE_ARCH' not in config_target |
| 3222 | config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']} |
| 3223 | endif |
| 3224 | if 'TARGET_ABI_DIR' not in config_target |
| 3225 | config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']} |
| 3226 | endif |
Marc-André Lureau | ee3eb3a | 2022-03-23 19:57:18 +0400 | [diff] [blame] | 3227 | if 'TARGET_BIG_ENDIAN' not in config_target |
| 3228 | config_target += {'TARGET_BIG_ENDIAN': 'n'} |
| 3229 | endif |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 3230 | |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3231 | foreach k, v: disassemblers |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 3232 | if host_arch.startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k) |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3233 | foreach sym: v |
| 3234 | config_target += { sym: 'y' } |
Paolo Bonzini | ca0fc78 | 2020-09-01 06:04:28 -0400 | [diff] [blame] | 3235 | endforeach |
| 3236 | endif |
| 3237 | endforeach |
| 3238 | |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 3239 | config_target_data = configuration_data() |
| 3240 | foreach k, v: config_target |
| 3241 | if not k.startswith('TARGET_') and not k.startswith('CONFIG_') |
| 3242 | # do nothing |
| 3243 | elif ignored.contains(k) |
| 3244 | # do nothing |
| 3245 | elif k == 'TARGET_BASE_ARCH' |
Paolo Bonzini | a9a7490 | 2020-09-21 05:11:01 -0400 | [diff] [blame] | 3246 | # Note that TARGET_BASE_ARCH ends up in config-target.h but it is |
| 3247 | # not used to select files from sourcesets. |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 3248 | config_target_data.set('TARGET_' + v.to_upper(), 1) |
Paolo Bonzini | 765686d | 2020-09-18 06:37:21 -0400 | [diff] [blame] | 3249 | elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX' |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 3250 | config_target_data.set_quoted(k, v) |
| 3251 | elif v == 'y' |
| 3252 | config_target_data.set(k, 1) |
Marc-André Lureau | ee3eb3a | 2022-03-23 19:57:18 +0400 | [diff] [blame] | 3253 | elif v == 'n' |
| 3254 | config_target_data.set(k, 0) |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 3255 | else |
| 3256 | config_target_data.set(k, v) |
| 3257 | endif |
| 3258 | endforeach |
Peter Maydell | cb2c553 | 2021-07-30 11:59:43 +0100 | [diff] [blame] | 3259 | config_target_data.set('QEMU_ARCH', |
| 3260 | 'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper()) |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 3261 | config_target_h += {target: configure_file(output: target + '-config-target.h', |
| 3262 | configuration: config_target_data)} |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3263 | |
| 3264 | if target.endswith('-softmmu') |
Paolo Bonzini | bae3e3a | 2024-01-29 11:53:17 +0100 | [diff] [blame] | 3265 | target_kconfig += 'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y' |
| 3266 | target_kconfig += 'CONFIG_TARGET_BIG_ENDIAN=' + config_target['TARGET_BIG_ENDIAN'] |
| 3267 | |
Alex Bennée | d1d5e9e | 2021-07-07 14:17:44 +0100 | [diff] [blame] | 3268 | config_input = meson.get_external_property(target, 'default') |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3269 | config_devices_mak = target + '-config-devices.mak' |
| 3270 | config_devices_mak = configure_file( |
Alex Bennée | d1d5e9e | 2021-07-07 14:17:44 +0100 | [diff] [blame] | 3271 | input: ['configs/devices' / target / config_input + '.mak', 'Kconfig'], |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3272 | output: config_devices_mak, |
| 3273 | depfile: config_devices_mak + '.d', |
| 3274 | capture: true, |
Paolo Bonzini | 7bc3ca7 | 2020-11-20 08:38:22 +0100 | [diff] [blame] | 3275 | command: [minikconf, |
| 3276 | get_option('default_devices') ? '--defconfig' : '--allnoconfig', |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3277 | config_devices_mak, '@DEPFILE@', '@INPUT@', |
Paolo Bonzini | bae3e3a | 2024-01-29 11:53:17 +0100 | [diff] [blame] | 3278 | host_kconfig, target_kconfig]) |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 3279 | |
| 3280 | config_devices_data = configuration_data() |
| 3281 | config_devices = keyval.load(config_devices_mak) |
| 3282 | foreach k, v: config_devices |
| 3283 | config_devices_data.set(k, 1) |
| 3284 | endforeach |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3285 | config_devices_mak_list += config_devices_mak |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 3286 | config_devices_h += {target: configure_file(output: target + '-config-devices.h', |
| 3287 | configuration: config_devices_data)} |
| 3288 | config_target += config_devices |
Paolo Bonzini | a98006b | 2020-09-01 05:32:23 -0400 | [diff] [blame] | 3289 | config_all_devices += config_devices |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3290 | endif |
| 3291 | config_target_mak += {target: config_target} |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3292 | endforeach |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 3293 | target_dirs = actual_target_dirs |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3294 | |
Paolo Bonzini | eed56e9 | 2021-11-10 11:01:26 +0100 | [diff] [blame] | 3295 | target_configs_h = [] |
| 3296 | foreach target: target_dirs |
| 3297 | target_configs_h += config_target_h[target] |
| 3298 | target_configs_h += config_devices_h.get(target, []) |
| 3299 | endforeach |
| 3300 | genh += custom_target('config-poison.h', |
| 3301 | input: [target_configs_h], |
| 3302 | output: 'config-poison.h', |
| 3303 | capture: true, |
| 3304 | command: [find_program('scripts/make-config-poison.sh'), |
| 3305 | target_configs_h]) |
| 3306 | |
Paolo Bonzini | 7a6f334 | 2024-01-25 12:22:57 +0100 | [diff] [blame] | 3307 | if fdt_required.length() > 0 |
| 3308 | error('fdt disabled but required by targets ' + ', '.join(fdt_required)) |
| 3309 | endif |
| 3310 | |
Paolo Bonzini | a775c71 | 2023-09-08 12:09:22 +0200 | [diff] [blame] | 3311 | ############### |
| 3312 | # Subprojects # |
| 3313 | ############### |
Paolo Bonzini | 4d34a86 | 2020-10-05 11:31:15 +0200 | [diff] [blame] | 3314 | |
Jagannathan Raman | 5511696 | 2022-06-13 16:26:24 -0400 | [diff] [blame] | 3315 | libvfio_user_dep = not_found |
| 3316 | if have_system and vfio_user_server_allowed |
Paolo Bonzini | 2019cab | 2023-05-18 16:50:00 +0200 | [diff] [blame] | 3317 | libvfio_user_proj = subproject('libvfio-user', required: true) |
Paolo Bonzini | 5328353 | 2023-03-30 12:47:23 +0200 | [diff] [blame] | 3318 | libvfio_user_dep = libvfio_user_proj.get_variable('libvfio_user_dep') |
Jagannathan Raman | 5511696 | 2022-06-13 16:26:24 -0400 | [diff] [blame] | 3319 | endif |
| 3320 | |
Paolo Bonzini | a775c71 | 2023-09-08 12:09:22 +0200 | [diff] [blame] | 3321 | vhost_user = not_found |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 3322 | if host_os == 'linux' and have_vhost_user |
Paolo Bonzini | a775c71 | 2023-09-08 12:09:22 +0200 | [diff] [blame] | 3323 | libvhost_user = subproject('libvhost-user') |
| 3324 | vhost_user = libvhost_user.get_variable('vhost_user_dep') |
| 3325 | endif |
| 3326 | |
| 3327 | libvduse = not_found |
| 3328 | if have_libvduse |
| 3329 | libvduse_proj = subproject('libvduse') |
| 3330 | libvduse = libvduse_proj.get_variable('libvduse_dep') |
| 3331 | endif |
Richard Henderson | 8b18cdb | 2020-09-13 12:19:25 -0700 | [diff] [blame] | 3332 | |
Paolo Bonzini | a0c9162 | 2020-10-07 11:01:51 -0400 | [diff] [blame] | 3333 | ##################### |
| 3334 | # Generated sources # |
| 3335 | ##################### |
Richard Henderson | 8b18cdb | 2020-09-13 12:19:25 -0700 | [diff] [blame] | 3336 | |
Paolo Bonzini | a0c9162 | 2020-10-07 11:01:51 -0400 | [diff] [blame] | 3337 | genh += configure_file(output: 'config-host.h', configuration: config_host_data) |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3338 | |
Paolo Bonzini | 7b72c7d | 2024-10-15 11:14:18 +0200 | [diff] [blame] | 3339 | if have_rust and have_system |
| 3340 | rustc_args = run_command( |
| 3341 | find_program('scripts/rust/rustc_args.py'), |
| 3342 | '--config-headers', meson.project_build_root() / 'config-host.h', |
| 3343 | capture : true, |
| 3344 | check: true).stdout().strip().split() |
| 3345 | |
| 3346 | # Prohibit code that is forbidden in Rust 2024 |
| 3347 | rustc_args += ['-D', 'unsafe_op_in_unsafe_fn'] |
Paolo Bonzini | cde3c42 | 2024-10-18 16:30:56 +0200 | [diff] [blame] | 3348 | |
| 3349 | # Apart from procedural macros, our Rust executables will often link |
| 3350 | # with C code, so include all the libraries that C code needs. This |
| 3351 | # is safe; https://github.com/rust-lang/rust/pull/54675 says that |
| 3352 | # passing -nodefaultlibs to the linker "was more ideological to |
| 3353 | # start with than anything". |
| 3354 | add_project_arguments(rustc_args + ['-C', 'default-linker-libraries'], |
| 3355 | native: false, language: 'rust') |
| 3356 | |
Paolo Bonzini | 7b72c7d | 2024-10-15 11:14:18 +0200 | [diff] [blame] | 3357 | add_project_arguments(rustc_args, native: true, language: 'rust') |
| 3358 | endif |
| 3359 | |
Marc-André Lureau | 3f88565 | 2019-07-15 18:06:04 +0400 | [diff] [blame] | 3360 | hxtool = find_program('scripts/hxtool') |
Marc-André Lureau | e2c4012 | 2023-01-24 18:00:57 +0000 | [diff] [blame] | 3361 | shaderinclude = find_program('scripts/shaderinclude.py') |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3362 | qapi_gen = find_program('scripts/qapi-gen.py') |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 3363 | qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py', |
| 3364 | meson.current_source_dir() / 'scripts/qapi/commands.py', |
| 3365 | meson.current_source_dir() / 'scripts/qapi/common.py', |
| 3366 | meson.current_source_dir() / 'scripts/qapi/error.py', |
| 3367 | meson.current_source_dir() / 'scripts/qapi/events.py', |
| 3368 | meson.current_source_dir() / 'scripts/qapi/expr.py', |
| 3369 | meson.current_source_dir() / 'scripts/qapi/gen.py', |
| 3370 | meson.current_source_dir() / 'scripts/qapi/introspect.py', |
Markus Armbruster | 88d357d | 2023-04-28 12:54:16 +0200 | [diff] [blame] | 3371 | meson.current_source_dir() / 'scripts/qapi/main.py', |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 3372 | meson.current_source_dir() / 'scripts/qapi/parser.py', |
| 3373 | meson.current_source_dir() / 'scripts/qapi/schema.py', |
| 3374 | meson.current_source_dir() / 'scripts/qapi/source.py', |
| 3375 | meson.current_source_dir() / 'scripts/qapi/types.py', |
| 3376 | meson.current_source_dir() / 'scripts/qapi/visit.py', |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 3377 | meson.current_source_dir() / 'scripts/qapi-gen.py' |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3378 | ] |
| 3379 | |
| 3380 | tracetool = [ |
| 3381 | python, files('scripts/tracetool.py'), |
Paolo Bonzini | 9c29b74 | 2021-10-07 15:08:14 +0200 | [diff] [blame] | 3382 | '--backend=' + ','.join(get_option('trace_backends')) |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3383 | ] |
Stefan Hajnoczi | 0572d6c | 2021-01-25 11:09:58 +0000 | [diff] [blame] | 3384 | tracetool_depends = files( |
| 3385 | 'scripts/tracetool/backend/log.py', |
| 3386 | 'scripts/tracetool/backend/__init__.py', |
| 3387 | 'scripts/tracetool/backend/dtrace.py', |
| 3388 | 'scripts/tracetool/backend/ftrace.py', |
| 3389 | 'scripts/tracetool/backend/simple.py', |
| 3390 | 'scripts/tracetool/backend/syslog.py', |
| 3391 | 'scripts/tracetool/backend/ust.py', |
Stefan Hajnoczi | 0572d6c | 2021-01-25 11:09:58 +0000 | [diff] [blame] | 3392 | 'scripts/tracetool/format/ust_events_c.py', |
| 3393 | 'scripts/tracetool/format/ust_events_h.py', |
| 3394 | 'scripts/tracetool/format/__init__.py', |
| 3395 | 'scripts/tracetool/format/d.py', |
Stefan Hajnoczi | 0572d6c | 2021-01-25 11:09:58 +0000 | [diff] [blame] | 3396 | 'scripts/tracetool/format/simpletrace_stap.py', |
| 3397 | 'scripts/tracetool/format/c.py', |
| 3398 | 'scripts/tracetool/format/h.py', |
Stefan Hajnoczi | 0572d6c | 2021-01-25 11:09:58 +0000 | [diff] [blame] | 3399 | 'scripts/tracetool/format/log_stap.py', |
| 3400 | 'scripts/tracetool/format/stap.py', |
Stefan Hajnoczi | 0572d6c | 2021-01-25 11:09:58 +0000 | [diff] [blame] | 3401 | 'scripts/tracetool/__init__.py', |
Stefan Hajnoczi | 0572d6c | 2021-01-25 11:09:58 +0000 | [diff] [blame] | 3402 | ) |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3403 | |
Marc-André Lureau | 2c273f3 | 2019-07-15 17:10:19 +0400 | [diff] [blame] | 3404 | qemu_version_cmd = [find_program('scripts/qemu-version.sh'), |
| 3405 | meson.current_source_dir(), |
Paolo Bonzini | b0b4323 | 2022-04-20 17:33:54 +0200 | [diff] [blame] | 3406 | get_option('pkgversion'), meson.project_version()] |
Marc-André Lureau | 2c273f3 | 2019-07-15 17:10:19 +0400 | [diff] [blame] | 3407 | qemu_version = custom_target('qemu-version.h', |
| 3408 | output: 'qemu-version.h', |
| 3409 | command: qemu_version_cmd, |
| 3410 | capture: true, |
| 3411 | build_by_default: true, |
| 3412 | build_always_stale: true) |
| 3413 | genh += qemu_version |
| 3414 | |
Marc-André Lureau | 3f88565 | 2019-07-15 18:06:04 +0400 | [diff] [blame] | 3415 | hxdep = [] |
| 3416 | hx_headers = [ |
| 3417 | ['qemu-options.hx', 'qemu-options.def'], |
| 3418 | ['qemu-img-cmds.hx', 'qemu-img-cmds.h'], |
| 3419 | ] |
| 3420 | if have_system |
| 3421 | hx_headers += [ |
| 3422 | ['hmp-commands.hx', 'hmp-commands.h'], |
| 3423 | ['hmp-commands-info.hx', 'hmp-commands-info.h'], |
| 3424 | ] |
| 3425 | endif |
| 3426 | foreach d : hx_headers |
Marc-André Lureau | b7c70bf | 2019-07-16 21:37:25 +0400 | [diff] [blame] | 3427 | hxdep += custom_target(d[1], |
Marc-André Lureau | 3f88565 | 2019-07-15 18:06:04 +0400 | [diff] [blame] | 3428 | input: files(d[0]), |
| 3429 | output: d[1], |
| 3430 | capture: true, |
Marc-André Lureau | 3f88565 | 2019-07-15 18:06:04 +0400 | [diff] [blame] | 3431 | command: [hxtool, '-h', '@INPUT0@']) |
| 3432 | endforeach |
| 3433 | genh += hxdep |
| 3434 | |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3435 | ############### |
| 3436 | # Trace files # |
| 3437 | ############### |
| 3438 | |
Marc-André Lureau | c9322ab | 2019-08-18 19:51:17 +0400 | [diff] [blame] | 3439 | # TODO: add each directory to the subdirs from its own meson.build, once |
| 3440 | # we have those |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3441 | trace_events_subdirs = [ |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3442 | 'crypto', |
Philippe Mathieu-Daudé | 69ff4d0 | 2021-01-22 21:44:35 +0100 | [diff] [blame] | 3443 | 'qapi', |
| 3444 | 'qom', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3445 | 'monitor', |
Philippe Mathieu-Daudé | 69ff4d0 | 2021-01-22 21:44:35 +0100 | [diff] [blame] | 3446 | 'util', |
Alex Bennée | 842b42d | 2022-09-29 12:42:22 +0100 | [diff] [blame] | 3447 | 'gdbstub', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3448 | ] |
Warner Losh | 6ddc1ab | 2022-01-08 17:37:23 -0700 | [diff] [blame] | 3449 | if have_linux_user |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3450 | trace_events_subdirs += [ 'linux-user' ] |
| 3451 | endif |
Warner Losh | 6ddc1ab | 2022-01-08 17:37:23 -0700 | [diff] [blame] | 3452 | if have_bsd_user |
| 3453 | trace_events_subdirs += [ 'bsd-user' ] |
| 3454 | endif |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3455 | if have_block |
| 3456 | trace_events_subdirs += [ |
| 3457 | 'authz', |
| 3458 | 'block', |
Daniel P. Berrangé | 48fc887 | 2024-07-23 11:31:24 +0100 | [diff] [blame] | 3459 | 'chardev', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3460 | 'io', |
| 3461 | 'nbd', |
| 3462 | 'scsi', |
| 3463 | ] |
| 3464 | endif |
| 3465 | if have_system |
| 3466 | trace_events_subdirs += [ |
Philippe Mathieu-Daudé | 8985db2 | 2021-01-22 21:44:36 +0100 | [diff] [blame] | 3467 | 'accel/kvm', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3468 | 'audio', |
| 3469 | 'backends', |
| 3470 | 'backends/tpm', |
Andrew Melnychenko | 46627f4 | 2021-05-14 14:48:32 +0300 | [diff] [blame] | 3471 | 'ebpf', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3472 | 'hw/9pfs', |
| 3473 | 'hw/acpi', |
Hao Wu | 77c05b0 | 2021-01-08 11:09:42 -0800 | [diff] [blame] | 3474 | 'hw/adc', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3475 | 'hw/alpha', |
| 3476 | 'hw/arm', |
| 3477 | 'hw/audio', |
| 3478 | 'hw/block', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3479 | 'hw/char', |
| 3480 | 'hw/display', |
| 3481 | 'hw/dma', |
Ninad Palsule | 99f0c04 | 2024-01-26 04:49:46 -0600 | [diff] [blame] | 3482 | 'hw/fsi', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3483 | 'hw/hyperv', |
| 3484 | 'hw/i2c', |
| 3485 | 'hw/i386', |
| 3486 | 'hw/i386/xen', |
David Woodhouse | aa98ee3 | 2023-01-13 19:51:32 +0000 | [diff] [blame] | 3487 | 'hw/i386/kvm', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3488 | 'hw/ide', |
| 3489 | 'hw/input', |
| 3490 | 'hw/intc', |
| 3491 | 'hw/isa', |
| 3492 | 'hw/mem', |
| 3493 | 'hw/mips', |
| 3494 | 'hw/misc', |
| 3495 | 'hw/misc/macio', |
| 3496 | 'hw/net', |
Vikram Garhwal | 98e5d7a | 2020-11-18 11:48:43 -0800 | [diff] [blame] | 3497 | 'hw/net/can', |
Mark Cave-Ayland | ce0e6a2 | 2021-09-24 08:37:55 +0100 | [diff] [blame] | 3498 | 'hw/nubus', |
Klaus Jensen | 88eea45 | 2021-04-14 22:14:30 +0200 | [diff] [blame] | 3499 | 'hw/nvme', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3500 | 'hw/nvram', |
| 3501 | 'hw/pci', |
| 3502 | 'hw/pci-host', |
| 3503 | 'hw/ppc', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3504 | 'hw/rtc', |
Tomasz Jeznach | 0c54acb | 2024-10-16 17:40:27 -0300 | [diff] [blame] | 3505 | 'hw/riscv', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3506 | 'hw/s390x', |
| 3507 | 'hw/scsi', |
| 3508 | 'hw/sd', |
BALATON Zoltan | ad52cfc | 2021-10-29 23:02:09 +0200 | [diff] [blame] | 3509 | 'hw/sh4', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3510 | 'hw/sparc', |
| 3511 | 'hw/sparc64', |
| 3512 | 'hw/ssi', |
| 3513 | 'hw/timer', |
| 3514 | 'hw/tpm', |
Jeuk Kim | bc4e68d | 2023-09-06 16:43:48 +0900 | [diff] [blame] | 3515 | 'hw/ufs', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3516 | 'hw/usb', |
| 3517 | 'hw/vfio', |
| 3518 | 'hw/virtio', |
| 3519 | 'hw/watchdog', |
| 3520 | 'hw/xen', |
| 3521 | 'hw/gpio', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3522 | 'migration', |
| 3523 | 'net', |
Philippe Mathieu-Daudé | 8d7f2e7 | 2023-10-04 11:06:28 +0200 | [diff] [blame] | 3524 | 'system', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3525 | 'ui', |
Elena Ufimtseva | ad22c30 | 2021-01-29 11:46:10 -0500 | [diff] [blame] | 3526 | 'hw/remote', |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3527 | ] |
| 3528 | endif |
Philippe Mathieu-Daudé | 8985db2 | 2021-01-22 21:44:36 +0100 | [diff] [blame] | 3529 | if have_system or have_user |
| 3530 | trace_events_subdirs += [ |
| 3531 | 'accel/tcg', |
| 3532 | 'hw/core', |
| 3533 | 'target/arm', |
Alexander Graf | a1477da | 2021-09-16 17:53:58 +0200 | [diff] [blame] | 3534 | 'target/arm/hvf', |
Philippe Mathieu-Daudé | 8985db2 | 2021-01-22 21:44:36 +0100 | [diff] [blame] | 3535 | 'target/hppa', |
| 3536 | 'target/i386', |
| 3537 | 'target/i386/kvm', |
Tianrui Zhao | f844743 | 2024-01-05 15:57:59 +0800 | [diff] [blame] | 3538 | 'target/loongarch', |
Philippe Mathieu-Daudé | 34b8ff2 | 2021-05-30 09:02:16 +0200 | [diff] [blame] | 3539 | 'target/mips/tcg', |
Philippe Mathieu-Daudé | 8985db2 | 2021-01-22 21:44:36 +0100 | [diff] [blame] | 3540 | 'target/ppc', |
| 3541 | 'target/riscv', |
| 3542 | 'target/s390x', |
Cho, Yu-Chen | 6704360 | 2021-07-07 18:53:23 +0800 | [diff] [blame] | 3543 | 'target/s390x/kvm', |
Philippe Mathieu-Daudé | 8985db2 | 2021-01-22 21:44:36 +0100 | [diff] [blame] | 3544 | 'target/sparc', |
| 3545 | ] |
| 3546 | endif |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3547 | |
Paolo Bonzini | 9cd76c9 | 2023-11-03 09:33:57 +0100 | [diff] [blame] | 3548 | ################### |
| 3549 | # Collect sources # |
| 3550 | ################### |
| 3551 | |
| 3552 | authz_ss = ss.source_set() |
| 3553 | blockdev_ss = ss.source_set() |
| 3554 | block_ss = ss.source_set() |
| 3555 | chardev_ss = ss.source_set() |
| 3556 | common_ss = ss.source_set() |
| 3557 | crypto_ss = ss.source_set() |
| 3558 | hwcore_ss = ss.source_set() |
| 3559 | io_ss = ss.source_set() |
| 3560 | qmp_ss = ss.source_set() |
| 3561 | qom_ss = ss.source_set() |
| 3562 | system_ss = ss.source_set() |
| 3563 | specific_fuzz_ss = ss.source_set() |
| 3564 | specific_ss = ss.source_set() |
Manos Pitsidianakis | 37fdb2f | 2024-10-24 17:03:00 +0300 | [diff] [blame] | 3565 | rust_devices_ss = ss.source_set() |
Paolo Bonzini | 9cd76c9 | 2023-11-03 09:33:57 +0100 | [diff] [blame] | 3566 | stub_ss = ss.source_set() |
| 3567 | trace_ss = ss.source_set() |
| 3568 | user_ss = ss.source_set() |
| 3569 | util_ss = ss.source_set() |
| 3570 | |
| 3571 | # accel modules |
| 3572 | qtest_module_ss = ss.source_set() |
| 3573 | tcg_module_ss = ss.source_set() |
| 3574 | |
| 3575 | modules = {} |
| 3576 | target_modules = {} |
| 3577 | hw_arch = {} |
| 3578 | target_arch = {} |
| 3579 | target_system_arch = {} |
| 3580 | target_user_arch = {} |
| 3581 | |
Vladimir Sementsov-Ogievskiy | b83a80e | 2022-01-26 17:11:27 +0100 | [diff] [blame] | 3582 | # NOTE: the trace/ subdirectory needs the qapi_trace_events variable |
| 3583 | # that is filled in by qapi/. |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3584 | subdir('qapi') |
| 3585 | subdir('qobject') |
| 3586 | subdir('stubs') |
| 3587 | subdir('trace') |
| 3588 | subdir('util') |
Marc-André Lureau | 5582c58 | 2019-07-16 19:28:54 +0400 | [diff] [blame] | 3589 | subdir('qom') |
| 3590 | subdir('authz') |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3591 | subdir('crypto') |
Marc-André Lureau | 2d78b56 | 2019-07-15 16:00:36 +0400 | [diff] [blame] | 3592 | subdir('ui') |
Alex Bennée | 842b42d | 2022-09-29 12:42:22 +0100 | [diff] [blame] | 3593 | subdir('gdbstub') |
Philippe Mathieu-Daudé | 6862126 | 2024-04-08 17:53:20 +0200 | [diff] [blame] | 3594 | if have_system |
| 3595 | subdir('hw') |
| 3596 | else |
| 3597 | subdir('hw/core') |
| 3598 | endif |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3599 | |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3600 | if enable_modules |
| 3601 | libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO') |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3602 | modulecommon = declare_dependency(objects: libmodulecommon.extract_all_objects(recursive: false), compile_args: '-DBUILD_DSO') |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3603 | endif |
| 3604 | |
Paolo Bonzini | 1220f58 | 2023-08-30 11:52:43 +0200 | [diff] [blame] | 3605 | qom_ss = qom_ss.apply({}) |
Nicolas Saenz Julienne | 7d5983e | 2022-04-25 09:57:21 +0200 | [diff] [blame] | 3606 | libqom = static_library('qom', qom_ss.sources() + genh, |
| 3607 | dependencies: [qom_ss.dependencies()], |
Paolo Bonzini | 4c545a0 | 2023-09-27 15:48:31 +0200 | [diff] [blame] | 3608 | build_by_default: false) |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3609 | qom = declare_dependency(objects: libqom.extract_all_objects(recursive: false), |
| 3610 | dependencies: qom_ss.dependencies()) |
Nicolas Saenz Julienne | 7d5983e | 2022-04-25 09:57:21 +0200 | [diff] [blame] | 3611 | |
| 3612 | event_loop_base = files('event-loop-base.c') |
Paolo Bonzini | 4c545a0 | 2023-09-27 15:48:31 +0200 | [diff] [blame] | 3613 | event_loop_base = static_library('event-loop-base', |
| 3614 | sources: event_loop_base + genh, |
Paolo Bonzini | 4c545a0 | 2023-09-27 15:48:31 +0200 | [diff] [blame] | 3615 | build_by_default: false) |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3616 | event_loop_base = declare_dependency(objects: event_loop_base.extract_all_objects(recursive: false), |
Nicolas Saenz Julienne | 7d5983e | 2022-04-25 09:57:21 +0200 | [diff] [blame] | 3617 | dependencies: [qom]) |
| 3618 | |
Paolo Bonzini | 1220f58 | 2023-08-30 11:52:43 +0200 | [diff] [blame] | 3619 | stub_ss = stub_ss.apply({}) |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3620 | |
| 3621 | util_ss.add_all(trace_ss) |
Paolo Bonzini | 1220f58 | 2023-08-30 11:52:43 +0200 | [diff] [blame] | 3622 | util_ss = util_ss.apply({}) |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3623 | libqemuutil = static_library('qemuutil', |
Paolo Bonzini | 4c545a0 | 2023-09-27 15:48:31 +0200 | [diff] [blame] | 3624 | build_by_default: false, |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3625 | sources: util_ss.sources() + stub_ss.sources() + genh, |
Paolo Bonzini | 6190fd6 | 2024-04-08 17:53:13 +0200 | [diff] [blame] | 3626 | dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc]) |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3627 | qemuutil = declare_dependency(link_with: libqemuutil, |
Nicolas Saenz Julienne | 70ac26b | 2022-04-25 09:57:22 +0200 | [diff] [blame] | 3628 | sources: genh + version_res, |
| 3629 | dependencies: [event_loop_base]) |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 3630 | |
Philippe Mathieu-Daudé | 957b31f | 2021-01-22 21:44:37 +0100 | [diff] [blame] | 3631 | if have_system or have_user |
| 3632 | decodetree = generator(find_program('scripts/decodetree.py'), |
| 3633 | output: 'decode-@BASENAME@.c.inc', |
| 3634 | arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@']) |
| 3635 | subdir('libdecnumber') |
| 3636 | subdir('target') |
| 3637 | endif |
Paolo Bonzini | abff1ab | 2020-08-07 12:10:23 +0200 | [diff] [blame] | 3638 | |
Paolo Bonzini | 478e943 | 2020-08-17 12:47:55 +0200 | [diff] [blame] | 3639 | subdir('audio') |
Marc-André Lureau | 7fcfd45 | 2019-07-16 19:33:55 +0400 | [diff] [blame] | 3640 | subdir('io') |
Marc-André Lureau | 848e8ff | 2019-07-15 23:18:07 +0400 | [diff] [blame] | 3641 | subdir('chardev') |
Marc-André Lureau | ec0d589 | 2019-07-15 15:04:49 +0400 | [diff] [blame] | 3642 | subdir('fsdev') |
Marc-André Lureau | 708eab4 | 2019-09-03 16:59:33 +0400 | [diff] [blame] | 3643 | subdir('dump') |
Marc-André Lureau | ec0d589 | 2019-07-15 15:04:49 +0400 | [diff] [blame] | 3644 | |
Philippe Mathieu-Daudé | f285bd3 | 2021-01-22 21:44:34 +0100 | [diff] [blame] | 3645 | if have_block |
| 3646 | block_ss.add(files( |
| 3647 | 'block.c', |
| 3648 | 'blockjob.c', |
| 3649 | 'job.c', |
| 3650 | 'qemu-io-cmds.c', |
| 3651 | )) |
Paolo Bonzini | 406523f | 2021-10-13 11:43:54 +0200 | [diff] [blame] | 3652 | if config_host_data.get('CONFIG_REPLICATION') |
| 3653 | block_ss.add(files('replication.c')) |
| 3654 | endif |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 3655 | |
Philippe Mathieu-Daudé | f285bd3 | 2021-01-22 21:44:34 +0100 | [diff] [blame] | 3656 | subdir('nbd') |
| 3657 | subdir('scsi') |
| 3658 | subdir('block') |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 3659 | |
Philippe Mathieu-Daudé | f285bd3 | 2021-01-22 21:44:34 +0100 | [diff] [blame] | 3660 | blockdev_ss.add(files( |
| 3661 | 'blockdev.c', |
| 3662 | 'blockdev-nbd.c', |
| 3663 | 'iothread.c', |
| 3664 | 'job-qmp.c', |
Akihiko Odaki | 7b1070a | 2024-05-24 17:00:23 +0900 | [diff] [blame] | 3665 | )) |
Paolo Bonzini | 4a96337 | 2020-08-03 16:22:28 +0200 | [diff] [blame] | 3666 | |
Philippe Mathieu-Daudé | f285bd3 | 2021-01-22 21:44:34 +0100 | [diff] [blame] | 3667 | # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon, |
| 3668 | # os-win32.c does not |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 3669 | if host_os == 'windows' |
Paolo Bonzini | dc49549 | 2023-08-30 11:29:54 +0200 | [diff] [blame] | 3670 | system_ss.add(files('os-win32.c')) |
| 3671 | else |
| 3672 | blockdev_ss.add(files('os-posix.c')) |
| 3673 | endif |
Philippe Mathieu-Daudé | f285bd3 | 2021-01-22 21:44:34 +0100 | [diff] [blame] | 3674 | endif |
Paolo Bonzini | 4a96337 | 2020-08-03 16:22:28 +0200 | [diff] [blame] | 3675 | |
Philippe Mathieu-Daudé | fe0007f | 2023-09-14 20:57:12 +0200 | [diff] [blame] | 3676 | common_ss.add(files('cpu-common.c')) |
| 3677 | specific_ss.add(files('cpu-target.c')) |
Paolo Bonzini | 4a96337 | 2020-08-03 16:22:28 +0200 | [diff] [blame] | 3678 | |
Philippe Mathieu-Daudé | 8d7f2e7 | 2023-10-04 11:06:28 +0200 | [diff] [blame] | 3679 | subdir('system') |
Marc-André Lureau | c9322ab | 2019-08-18 19:51:17 +0400 | [diff] [blame] | 3680 | |
Richard Henderson | 44b99a6 | 2021-03-22 12:24:26 +0100 | [diff] [blame] | 3681 | # Work around a gcc bug/misfeature wherein constant propagation looks |
| 3682 | # through an alias: |
| 3683 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99696 |
| 3684 | # to guess that a const variable is always zero. Without lto, this is |
| 3685 | # impossible, as the alias is restricted to page-vary-common.c. Indeed, |
| 3686 | # without lto, not even the alias is required -- we simply use different |
| 3687 | # declarations in different compilation units. |
| 3688 | pagevary = files('page-vary-common.c') |
| 3689 | if get_option('b_lto') |
| 3690 | pagevary_flags = ['-fno-lto'] |
| 3691 | if get_option('cfi') |
| 3692 | pagevary_flags += '-fno-sanitize=cfi-icall' |
| 3693 | endif |
Thomas Huth | 54c9b19 | 2022-03-30 13:48:08 +0200 | [diff] [blame] | 3694 | pagevary = static_library('page-vary-common', sources: pagevary + genh, |
Richard Henderson | 44b99a6 | 2021-03-22 12:24:26 +0100 | [diff] [blame] | 3695 | c_args: pagevary_flags) |
| 3696 | pagevary = declare_dependency(link_with: pagevary) |
| 3697 | endif |
| 3698 | common_ss.add(pagevary) |
Philippe Mathieu-Daudé | 75bbe6a | 2023-12-07 10:41:27 +0100 | [diff] [blame] | 3699 | specific_ss.add(files('page-target.c', 'page-vary-target.c')) |
Richard Henderson | 6670d4d | 2021-03-22 12:24:24 +0100 | [diff] [blame] | 3700 | |
Marc-André Lureau | ab31805 | 2019-07-24 19:23:16 +0400 | [diff] [blame] | 3701 | subdir('backends') |
Marc-André Lureau | c574e16 | 2019-07-26 12:02:31 +0400 | [diff] [blame] | 3702 | subdir('disas') |
Marc-André Lureau | 5516623 | 2019-07-24 19:16:22 +0400 | [diff] [blame] | 3703 | subdir('migration') |
Paolo Bonzini | ff219dc | 2020-08-04 21:14:26 +0200 | [diff] [blame] | 3704 | subdir('monitor') |
Marc-André Lureau | cdaf072 | 2019-07-22 23:47:50 +0400 | [diff] [blame] | 3705 | subdir('net') |
Marc-André Lureau | 17ef2af | 2019-07-22 23:40:45 +0400 | [diff] [blame] | 3706 | subdir('replay') |
Philippe Mathieu-Daudé | 8df9f0c | 2021-03-05 13:54:50 +0000 | [diff] [blame] | 3707 | subdir('semihosting') |
Markus Armbruster | aa09b3d | 2023-01-24 13:19:36 +0100 | [diff] [blame] | 3708 | subdir('stats') |
Richard Henderson | 104cc2c | 2021-03-08 12:04:33 -0800 | [diff] [blame] | 3709 | subdir('tcg') |
Richard Henderson | c634754 | 2021-03-08 12:15:06 -0800 | [diff] [blame] | 3710 | subdir('fpu') |
Marc-André Lureau | 1a82878 | 2019-08-18 16:13:08 +0400 | [diff] [blame] | 3711 | subdir('accel') |
Paolo Bonzini | f556b4a | 2020-01-24 13:08:01 +0100 | [diff] [blame] | 3712 | subdir('plugins') |
Richard Henderson | bbf15aa | 2021-11-17 16:14:00 +0100 | [diff] [blame] | 3713 | subdir('ebpf') |
| 3714 | |
| 3715 | common_user_inc = [] |
| 3716 | |
| 3717 | subdir('common-user') |
Marc-André Lureau | b309c32 | 2019-08-18 19:20:37 +0400 | [diff] [blame] | 3718 | subdir('bsd-user') |
Marc-André Lureau | 3a30446 | 2019-08-18 16:13:08 +0400 | [diff] [blame] | 3719 | subdir('linux-user') |
Andrew Melnychenko | 46627f4 | 2021-05-14 14:48:32 +0300 | [diff] [blame] | 3720 | |
Paolo Bonzini | a2ce7db | 2020-08-04 20:00:40 +0200 | [diff] [blame] | 3721 | # needed for fuzzing binaries |
| 3722 | subdir('tests/qtest/libqos') |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 3723 | subdir('tests/qtest/fuzz') |
Paolo Bonzini | a2ce7db | 2020-08-04 20:00:40 +0200 | [diff] [blame] | 3724 | |
Gerd Hoffmann | c94a7b8 | 2021-06-24 12:38:29 +0200 | [diff] [blame] | 3725 | # accel modules |
Gerd Hoffmann | dae0ec1 | 2021-06-24 12:38:31 +0200 | [diff] [blame] | 3726 | tcg_real_module_ss = ss.source_set() |
| 3727 | tcg_real_module_ss.add_all(when: 'CONFIG_TCG_MODULAR', if_true: tcg_module_ss) |
| 3728 | specific_ss.add_all(when: 'CONFIG_TCG_BUILTIN', if_true: tcg_module_ss) |
| 3729 | target_modules += { 'accel' : { 'qtest': qtest_module_ss, |
| 3730 | 'tcg': tcg_real_module_ss }} |
Gerd Hoffmann | c94a7b8 | 2021-06-24 12:38:29 +0200 | [diff] [blame] | 3731 | |
Paolo Bonzini | ea444d9 | 2023-09-08 12:06:12 +0200 | [diff] [blame] | 3732 | ############################################## |
| 3733 | # Internal static_libraries and dependencies # |
| 3734 | ############################################## |
Paolo Bonzini | a0c9162 | 2020-10-07 11:01:51 -0400 | [diff] [blame] | 3735 | |
Gerd Hoffmann | f5723ab | 2021-06-24 12:38:04 +0200 | [diff] [blame] | 3736 | modinfo_collect = find_program('scripts/modinfo-collect.py') |
Gerd Hoffmann | 5ebbfec | 2021-06-24 12:38:05 +0200 | [diff] [blame] | 3737 | modinfo_generate = find_program('scripts/modinfo-generate.py') |
Gerd Hoffmann | f5723ab | 2021-06-24 12:38:04 +0200 | [diff] [blame] | 3738 | modinfo_files = [] |
| 3739 | |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3740 | block_mods = [] |
Philippe Mathieu-Daudé | 21d2140 | 2023-10-04 11:06:26 +0200 | [diff] [blame] | 3741 | system_mods = [] |
Paolo Bonzini | fae7a42 | 2024-05-24 10:27:21 +0200 | [diff] [blame] | 3742 | emulator_modules = [] |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3743 | foreach d, list : modules |
Paolo Bonzini | ef70986 | 2023-05-04 10:20:46 +0200 | [diff] [blame] | 3744 | if not (d == 'block' ? have_block : have_system) |
| 3745 | continue |
| 3746 | endif |
| 3747 | |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3748 | foreach m, module_ss : list |
Paolo Bonzini | 6002711 | 2022-10-20 14:53:10 +0200 | [diff] [blame] | 3749 | if enable_modules |
Paolo Bonzini | fae7a42 | 2024-05-24 10:27:21 +0200 | [diff] [blame] | 3750 | module_ss.add(modulecommon) |
Paolo Bonzini | 0d66549 | 2023-08-31 11:18:24 +0200 | [diff] [blame] | 3751 | module_ss = module_ss.apply(config_all_devices, strict: false) |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3752 | sl = static_library(d + '-' + m, [genh, module_ss.sources()], |
Paolo Bonzini | fae7a42 | 2024-05-24 10:27:21 +0200 | [diff] [blame] | 3753 | dependencies: module_ss.dependencies(), pic: true) |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3754 | if d == 'block' |
| 3755 | block_mods += sl |
| 3756 | else |
Philippe Mathieu-Daudé | 21d2140 | 2023-10-04 11:06:26 +0200 | [diff] [blame] | 3757 | system_mods += sl |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3758 | endif |
Paolo Bonzini | fae7a42 | 2024-05-24 10:27:21 +0200 | [diff] [blame] | 3759 | emulator_modules += shared_module(sl.name(), |
| 3760 | name_prefix: '', |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3761 | objects: sl.extract_all_objects(recursive: false), |
| 3762 | dependencies: module_ss.dependencies(), |
Paolo Bonzini | fae7a42 | 2024-05-24 10:27:21 +0200 | [diff] [blame] | 3763 | install: true, |
| 3764 | install_dir: qemu_moddir) |
Gerd Hoffmann | f5723ab | 2021-06-24 12:38:04 +0200 | [diff] [blame] | 3765 | if module_ss.sources() != [] |
| 3766 | # FIXME: Should use sl.extract_all_objects(recursive: true) as |
| 3767 | # input. Sources can be used multiple times but objects are |
| 3768 | # unique when it comes to lookup in compile_commands.json. |
| 3769 | # Depnds on a mesion version with |
| 3770 | # https://github.com/mesonbuild/meson/pull/8900 |
| 3771 | modinfo_files += custom_target(d + '-' + m + '.modinfo', |
| 3772 | output: d + '-' + m + '.modinfo', |
Paolo Bonzini | ac34711 | 2021-07-21 18:51:57 +0200 | [diff] [blame] | 3773 | input: module_ss.sources() + genh, |
Gerd Hoffmann | f5723ab | 2021-06-24 12:38:04 +0200 | [diff] [blame] | 3774 | capture: true, |
Paolo Bonzini | ac34711 | 2021-07-21 18:51:57 +0200 | [diff] [blame] | 3775 | command: [modinfo_collect, module_ss.sources()]) |
Gerd Hoffmann | f5723ab | 2021-06-24 12:38:04 +0200 | [diff] [blame] | 3776 | endif |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3777 | else |
| 3778 | if d == 'block' |
| 3779 | block_ss.add_all(module_ss) |
| 3780 | else |
Philippe Mathieu-Daudé | de6cd75 | 2023-06-13 15:33:47 +0200 | [diff] [blame] | 3781 | system_ss.add_all(module_ss) |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3782 | endif |
| 3783 | endif |
| 3784 | endforeach |
| 3785 | endforeach |
| 3786 | |
Gerd Hoffmann | db2e89d | 2021-06-24 12:38:22 +0200 | [diff] [blame] | 3787 | foreach d, list : target_modules |
| 3788 | foreach m, module_ss : list |
Paolo Bonzini | 6002711 | 2022-10-20 14:53:10 +0200 | [diff] [blame] | 3789 | if enable_modules |
Paolo Bonzini | fae7a42 | 2024-05-24 10:27:21 +0200 | [diff] [blame] | 3790 | module_ss.add(modulecommon) |
Gerd Hoffmann | db2e89d | 2021-06-24 12:38:22 +0200 | [diff] [blame] | 3791 | foreach target : target_dirs |
| 3792 | if target.endswith('-softmmu') |
| 3793 | config_target = config_target_mak[target] |
Gerd Hoffmann | db2e89d | 2021-06-24 12:38:22 +0200 | [diff] [blame] | 3794 | target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])] |
Philippe Mathieu-Daudé | 7d7a21b | 2023-06-13 16:29:11 +0200 | [diff] [blame] | 3795 | c_args = ['-DCOMPILING_PER_TARGET', |
Gerd Hoffmann | db2e89d | 2021-06-24 12:38:22 +0200 | [diff] [blame] | 3796 | '-DCONFIG_TARGET="@0@-config-target.h"'.format(target), |
| 3797 | '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)] |
| 3798 | target_module_ss = module_ss.apply(config_target, strict: false) |
| 3799 | if target_module_ss.sources() != [] |
| 3800 | module_name = d + '-' + m + '-' + config_target['TARGET_NAME'] |
| 3801 | sl = static_library(module_name, |
| 3802 | [genh, target_module_ss.sources()], |
Paolo Bonzini | fae7a42 | 2024-05-24 10:27:21 +0200 | [diff] [blame] | 3803 | dependencies: target_module_ss.dependencies(), |
Gerd Hoffmann | db2e89d | 2021-06-24 12:38:22 +0200 | [diff] [blame] | 3804 | include_directories: target_inc, |
| 3805 | c_args: c_args, |
| 3806 | pic: true) |
Philippe Mathieu-Daudé | 21d2140 | 2023-10-04 11:06:26 +0200 | [diff] [blame] | 3807 | system_mods += sl |
Paolo Bonzini | fae7a42 | 2024-05-24 10:27:21 +0200 | [diff] [blame] | 3808 | emulator_modules += shared_module(sl.name(), |
| 3809 | name_prefix: '', |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3810 | objects: sl.extract_all_objects(recursive: false), |
| 3811 | dependencies: target_module_ss.dependencies(), |
Paolo Bonzini | fae7a42 | 2024-05-24 10:27:21 +0200 | [diff] [blame] | 3812 | install: true, |
| 3813 | install_dir: qemu_moddir) |
Gerd Hoffmann | db2e89d | 2021-06-24 12:38:22 +0200 | [diff] [blame] | 3814 | # FIXME: Should use sl.extract_all_objects(recursive: true) too. |
| 3815 | modinfo_files += custom_target(module_name + '.modinfo', |
| 3816 | output: module_name + '.modinfo', |
Gerd Hoffmann | 917ddc2 | 2021-07-23 14:01:56 +0200 | [diff] [blame] | 3817 | input: target_module_ss.sources() + genh, |
Gerd Hoffmann | db2e89d | 2021-06-24 12:38:22 +0200 | [diff] [blame] | 3818 | capture: true, |
Gerd Hoffmann | 917ddc2 | 2021-07-23 14:01:56 +0200 | [diff] [blame] | 3819 | command: [modinfo_collect, '--target', target, target_module_ss.sources()]) |
Gerd Hoffmann | db2e89d | 2021-06-24 12:38:22 +0200 | [diff] [blame] | 3820 | endif |
| 3821 | endif |
| 3822 | endforeach |
| 3823 | else |
| 3824 | specific_ss.add_all(module_ss) |
| 3825 | endif |
| 3826 | endforeach |
| 3827 | endforeach |
| 3828 | |
Gerd Hoffmann | 5ebbfec | 2021-06-24 12:38:05 +0200 | [diff] [blame] | 3829 | if enable_modules |
Jose R. Ziviani | 05d6814 | 2022-05-28 00:20:35 +0200 | [diff] [blame] | 3830 | foreach target : target_dirs |
| 3831 | if target.endswith('-softmmu') |
| 3832 | config_target = config_target_mak[target] |
| 3833 | config_devices_mak = target + '-config-devices.mak' |
| 3834 | modinfo_src = custom_target('modinfo-' + target + '.c', |
| 3835 | output: 'modinfo-' + target + '.c', |
| 3836 | input: modinfo_files, |
| 3837 | command: [modinfo_generate, '--devices', config_devices_mak, '@INPUT@'], |
| 3838 | capture: true) |
| 3839 | |
| 3840 | modinfo_lib = static_library('modinfo-' + target + '.c', modinfo_src) |
| 3841 | modinfo_dep = declare_dependency(link_with: modinfo_lib) |
| 3842 | |
| 3843 | arch = config_target['TARGET_NAME'] == 'sparc64' ? 'sparc64' : config_target['TARGET_BASE_ARCH'] |
| 3844 | hw_arch[arch].add(modinfo_dep) |
| 3845 | endif |
| 3846 | endforeach |
Paolo Bonzini | fae7a42 | 2024-05-24 10:27:21 +0200 | [diff] [blame] | 3847 | |
| 3848 | if emulator_modules.length() > 0 |
| 3849 | alias_target('modules', emulator_modules) |
| 3850 | endif |
Gerd Hoffmann | 5ebbfec | 2021-06-24 12:38:05 +0200 | [diff] [blame] | 3851 | endif |
| 3852 | |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3853 | nm = find_program('nm') |
Yonggang Luo | 604f3e4 | 2020-09-03 01:00:50 +0800 | [diff] [blame] | 3854 | undefsym = find_program('scripts/undefsym.py') |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3855 | block_syms = custom_target('block.syms', output: 'block.syms', |
| 3856 | input: [libqemuutil, block_mods], |
| 3857 | capture: true, |
| 3858 | command: [undefsym, nm, '@INPUT@']) |
| 3859 | qemu_syms = custom_target('qemu.syms', output: 'qemu.syms', |
Philippe Mathieu-Daudé | 21d2140 | 2023-10-04 11:06:26 +0200 | [diff] [blame] | 3860 | input: [libqemuutil, system_mods], |
Marc-André Lureau | 3154fee | 2019-08-29 22:07:01 +0400 | [diff] [blame] | 3861 | capture: true, |
| 3862 | command: [undefsym, nm, '@INPUT@']) |
| 3863 | |
Paolo Bonzini | 1220f58 | 2023-08-30 11:52:43 +0200 | [diff] [blame] | 3864 | authz_ss = authz_ss.apply({}) |
Philippe Mathieu-Daudé | 5556789 | 2020-10-06 14:56:01 +0200 | [diff] [blame] | 3865 | libauthz = static_library('authz', authz_ss.sources() + genh, |
| 3866 | dependencies: [authz_ss.dependencies()], |
Philippe Mathieu-Daudé | 5556789 | 2020-10-06 14:56:01 +0200 | [diff] [blame] | 3867 | build_by_default: false) |
| 3868 | |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3869 | authz = declare_dependency(objects: libauthz.extract_all_objects(recursive: false), |
| 3870 | dependencies: [authz_ss.dependencies(), qom]) |
Philippe Mathieu-Daudé | 5556789 | 2020-10-06 14:56:01 +0200 | [diff] [blame] | 3871 | |
Paolo Bonzini | 1220f58 | 2023-08-30 11:52:43 +0200 | [diff] [blame] | 3872 | crypto_ss = crypto_ss.apply({}) |
Philippe Mathieu-Daudé | 2389304 | 2020-10-06 14:56:00 +0200 | [diff] [blame] | 3873 | libcrypto = static_library('crypto', crypto_ss.sources() + genh, |
| 3874 | dependencies: [crypto_ss.dependencies()], |
Philippe Mathieu-Daudé | 2389304 | 2020-10-06 14:56:00 +0200 | [diff] [blame] | 3875 | build_by_default: false) |
| 3876 | |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3877 | crypto = declare_dependency(objects: libcrypto.extract_all_objects(recursive: false), |
| 3878 | dependencies: [crypto_ss.dependencies(), authz, qom]) |
Philippe Mathieu-Daudé | 2389304 | 2020-10-06 14:56:00 +0200 | [diff] [blame] | 3879 | |
Paolo Bonzini | 1220f58 | 2023-08-30 11:52:43 +0200 | [diff] [blame] | 3880 | io_ss = io_ss.apply({}) |
Philippe Mathieu-Daudé | f78536b | 2020-10-06 14:55:59 +0200 | [diff] [blame] | 3881 | libio = static_library('io', io_ss.sources() + genh, |
| 3882 | dependencies: [io_ss.dependencies()], |
| 3883 | link_with: libqemuutil, |
Philippe Mathieu-Daudé | f78536b | 2020-10-06 14:55:59 +0200 | [diff] [blame] | 3884 | build_by_default: false) |
| 3885 | |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3886 | io = declare_dependency(objects: libio.extract_all_objects(recursive: false), |
| 3887 | dependencies: [io_ss.dependencies(), crypto, qom]) |
Philippe Mathieu-Daudé | f78536b | 2020-10-06 14:55:59 +0200 | [diff] [blame] | 3888 | |
Philippe Mathieu-Daudé | 7e6edef | 2020-10-06 14:55:58 +0200 | [diff] [blame] | 3889 | libmigration = static_library('migration', sources: migration_files + genh, |
Philippe Mathieu-Daudé | 7e6edef | 2020-10-06 14:55:58 +0200 | [diff] [blame] | 3890 | build_by_default: false) |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3891 | migration = declare_dependency(objects: libmigration.extract_all_objects(recursive: false), |
Paolo Bonzini | 70eb5fd | 2024-05-24 18:16:08 +0200 | [diff] [blame] | 3892 | dependencies: [qom, io]) |
Philippe Mathieu-Daudé | de6cd75 | 2023-06-13 15:33:47 +0200 | [diff] [blame] | 3893 | system_ss.add(migration) |
Philippe Mathieu-Daudé | 7e6edef | 2020-10-06 14:55:58 +0200 | [diff] [blame] | 3894 | |
Paolo Bonzini | 1220f58 | 2023-08-30 11:52:43 +0200 | [diff] [blame] | 3895 | block_ss = block_ss.apply({}) |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 3896 | libblock = static_library('block', block_ss.sources() + genh, |
| 3897 | dependencies: block_ss.dependencies(), |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 3898 | build_by_default: false) |
| 3899 | |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3900 | block = declare_dependency(objects: libblock.extract_all_objects(recursive: false), |
| 3901 | dependencies: [block_ss.dependencies(), crypto, io]) |
Marc-André Lureau | 5e5733e | 2019-08-29 22:34:43 +0400 | [diff] [blame] | 3902 | |
Paolo Bonzini | 1220f58 | 2023-08-30 11:52:43 +0200 | [diff] [blame] | 3903 | blockdev_ss = blockdev_ss.apply({}) |
Stefan Hajnoczi | 4fb9071 | 2020-09-29 13:55:14 +0100 | [diff] [blame] | 3904 | libblockdev = static_library('blockdev', blockdev_ss.sources() + genh, |
| 3905 | dependencies: blockdev_ss.dependencies(), |
Stefan Hajnoczi | 4fb9071 | 2020-09-29 13:55:14 +0100 | [diff] [blame] | 3906 | build_by_default: false) |
| 3907 | |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3908 | blockdev = declare_dependency(objects: libblockdev.extract_all_objects(recursive: false), |
| 3909 | dependencies: [blockdev_ss.dependencies(), block, event_loop_base]) |
Stefan Hajnoczi | 4fb9071 | 2020-09-29 13:55:14 +0100 | [diff] [blame] | 3910 | |
Paolo Bonzini | 1220f58 | 2023-08-30 11:52:43 +0200 | [diff] [blame] | 3911 | qmp_ss = qmp_ss.apply({}) |
Paolo Bonzini | ff219dc | 2020-08-04 21:14:26 +0200 | [diff] [blame] | 3912 | libqmp = static_library('qmp', qmp_ss.sources() + genh, |
| 3913 | dependencies: qmp_ss.dependencies(), |
Paolo Bonzini | ff219dc | 2020-08-04 21:14:26 +0200 | [diff] [blame] | 3914 | build_by_default: false) |
| 3915 | |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3916 | qmp = declare_dependency(objects: libqmp.extract_all_objects(recursive: false), |
| 3917 | dependencies: qmp_ss.dependencies()) |
Paolo Bonzini | ff219dc | 2020-08-04 21:14:26 +0200 | [diff] [blame] | 3918 | |
Philippe Mathieu-Daudé | c2306d7 | 2020-10-06 14:55:57 +0200 | [diff] [blame] | 3919 | libchardev = static_library('chardev', chardev_ss.sources() + genh, |
Marc-André Lureau | 22d1f7a | 2022-03-23 19:57:12 +0400 | [diff] [blame] | 3920 | dependencies: chardev_ss.dependencies(), |
Philippe Mathieu-Daudé | c2306d7 | 2020-10-06 14:55:57 +0200 | [diff] [blame] | 3921 | build_by_default: false) |
| 3922 | |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3923 | chardev = declare_dependency(objects: libchardev.extract_all_objects(recursive: false), |
| 3924 | dependencies: chardev_ss.dependencies()) |
Philippe Mathieu-Daudé | c2306d7 | 2020-10-06 14:55:57 +0200 | [diff] [blame] | 3925 | |
Paolo Bonzini | 1220f58 | 2023-08-30 11:52:43 +0200 | [diff] [blame] | 3926 | hwcore_ss = hwcore_ss.apply({}) |
Philippe Mathieu-Daudé | f73fb06 | 2021-10-28 16:34:19 +0200 | [diff] [blame] | 3927 | libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh, |
Philippe Mathieu-Daudé | e28ab09 | 2020-10-06 14:55:56 +0200 | [diff] [blame] | 3928 | build_by_default: false) |
Akihiko Odaki | 414b180 | 2024-05-24 17:00:22 +0900 | [diff] [blame] | 3929 | hwcore = declare_dependency(objects: libhwcore.extract_all_objects(recursive: false)) |
Philippe Mathieu-Daudé | e28ab09 | 2020-10-06 14:55:56 +0200 | [diff] [blame] | 3930 | common_ss.add(hwcore) |
| 3931 | |
Philippe Mathieu-Daudé | 064f8ee | 2020-10-06 14:55:54 +0200 | [diff] [blame] | 3932 | ########### |
| 3933 | # Targets # |
| 3934 | ########### |
| 3935 | |
Philippe Mathieu-Daudé | de6cd75 | 2023-06-13 15:33:47 +0200 | [diff] [blame] | 3936 | system_ss.add(authz, blockdev, chardev, crypto, io, qmp) |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 3937 | common_ss.add(qom, qemuutil) |
| 3938 | |
Philippe Mathieu-Daudé | de6cd75 | 2023-06-13 15:33:47 +0200 | [diff] [blame] | 3939 | common_ss.add_all(when: 'CONFIG_SYSTEM_ONLY', if_true: [system_ss]) |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3940 | common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss) |
| 3941 | |
Paolo Bonzini | 0d66549 | 2023-08-31 11:18:24 +0200 | [diff] [blame] | 3942 | # Note that this library is never used directly (only through extract_objects) |
| 3943 | # and is not built by default; therefore, source files not used by the build |
| 3944 | # configuration will be in build.ninja, but are never built by default. |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3945 | common_all = static_library('common', |
| 3946 | build_by_default: false, |
Paolo Bonzini | 0d66549 | 2023-08-31 11:18:24 +0200 | [diff] [blame] | 3947 | sources: common_ss.all_sources() + genh, |
Paolo Bonzini | 9d24fb7 | 2021-12-21 16:09:54 +0100 | [diff] [blame] | 3948 | include_directories: common_user_inc, |
Katsuhiro Ueno | 75eebe0 | 2021-04-29 11:43:07 +0900 | [diff] [blame] | 3949 | implicit_include_directories: false, |
Paolo Bonzini | 4408155 | 2024-05-24 10:56:55 +0200 | [diff] [blame] | 3950 | dependencies: common_ss.all_dependencies()) |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 3951 | |
Manos Pitsidianakis | 6fdc5bc | 2024-10-03 16:28:46 +0300 | [diff] [blame] | 3952 | if have_rust and have_system |
Manos Pitsidianakis | 6fdc5bc | 2024-10-03 16:28:46 +0300 | [diff] [blame] | 3953 | bindgen_args = [ |
| 3954 | '--disable-header-comment', |
| 3955 | '--raw-line', '// @generated', |
| 3956 | '--ctypes-prefix', 'core::ffi', |
| 3957 | '--formatter', 'rustfmt', |
| 3958 | '--generate-block', |
| 3959 | '--generate-cstr', |
| 3960 | '--impl-debug', |
| 3961 | '--merge-extern-blocks', |
| 3962 | '--no-doc-comments', |
| 3963 | '--use-core', |
| 3964 | '--with-derive-default', |
Manos Pitsidianakis | 6fdc5bc | 2024-10-03 16:28:46 +0300 | [diff] [blame] | 3965 | '--no-layout-tests', |
| 3966 | '--no-prepend-enum-name', |
| 3967 | '--allowlist-file', meson.project_source_root() + '/include/.*', |
| 3968 | '--allowlist-file', meson.project_source_root() + '/.*', |
| 3969 | '--allowlist-file', meson.project_build_root() + '/.*' |
| 3970 | ] |
| 3971 | c_enums = [ |
| 3972 | 'DeviceCategory', |
| 3973 | 'GpioPolarity', |
| 3974 | 'MachineInitPhase', |
| 3975 | 'MemoryDeviceInfoKind', |
| 3976 | 'MigrationPolicy', |
| 3977 | 'MigrationPriority', |
| 3978 | 'QEMUChrEvent', |
| 3979 | 'QEMUClockType', |
| 3980 | 'device_endian', |
| 3981 | 'module_init_type', |
| 3982 | ] |
| 3983 | foreach enum : c_enums |
| 3984 | bindgen_args += ['--rustified-enum', enum] |
| 3985 | endforeach |
| 3986 | c_bitfields = [ |
| 3987 | 'ClockEvent', |
| 3988 | 'VMStateFlags', |
| 3989 | ] |
| 3990 | foreach enum : c_bitfields |
| 3991 | bindgen_args += ['--bitfield-enum', enum] |
| 3992 | endforeach |
| 3993 | |
| 3994 | # TODO: Remove this comment when the clang/libclang mismatch issue is solved. |
| 3995 | # |
| 3996 | # Rust bindings generation with `bindgen` might fail in some cases where the |
| 3997 | # detected `libclang` does not match the expected `clang` version/target. In |
| 3998 | # this case you must pass the path to `clang` and `libclang` to your build |
| 3999 | # command invocation using the environment variables CLANG_PATH and |
| 4000 | # LIBCLANG_PATH |
Paolo Bonzini | be3fc97 | 2024-10-15 10:08:57 +0200 | [diff] [blame] | 4001 | bindings_rs = rust.bindgen( |
Manos Pitsidianakis | 6fdc5bc | 2024-10-03 16:28:46 +0300 | [diff] [blame] | 4002 | input: 'rust/wrapper.h', |
| 4003 | dependencies: common_ss.all_dependencies(), |
| 4004 | output: 'bindings.rs', |
| 4005 | include_directories: include_directories('.', 'include'), |
| 4006 | bindgen_version: ['>=0.69.4'], |
| 4007 | args: bindgen_args, |
| 4008 | ) |
| 4009 | subdir('rust') |
| 4010 | endif |
| 4011 | |
| 4012 | |
Akihiko Odaki | 956af7d | 2023-10-09 17:40:51 +0100 | [diff] [blame] | 4013 | feature_to_c = find_program('scripts/feature_to_c.py') |
Paolo Bonzini | d1e526c | 2024-10-15 11:59:14 +0200 | [diff] [blame] | 4014 | rust_root_crate = find_program('scripts/rust/rust_root_crate.sh') |
Marc-André Lureau | c9322ab | 2019-08-18 19:51:17 +0400 | [diff] [blame] | 4015 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4016 | if host_os == 'darwin' |
Philippe Mathieu-Daudé | 30cfa50 | 2022-02-15 17:25:03 +0100 | [diff] [blame] | 4017 | entitlement = find_program('scripts/entitlement.sh') |
| 4018 | endif |
| 4019 | |
Daniel P. Berrangé | 2b608e1 | 2024-01-08 17:13:56 +0000 | [diff] [blame] | 4020 | traceable = [] |
Paolo Bonzini | fd5eef8 | 2020-09-16 05:00:53 -0400 | [diff] [blame] | 4021 | emulators = {} |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4022 | foreach target : target_dirs |
| 4023 | config_target = config_target_mak[target] |
| 4024 | target_name = config_target['TARGET_NAME'] |
Paolo Bonzini | ffb91f6 | 2021-11-08 15:44:39 +0100 | [diff] [blame] | 4025 | target_base_arch = config_target['TARGET_BASE_ARCH'] |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 4026 | arch_srcs = [config_target_h[target]] |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4027 | arch_deps = [] |
Philippe Mathieu-Daudé | 7d7a21b | 2023-06-13 16:29:11 +0200 | [diff] [blame] | 4028 | c_args = ['-DCOMPILING_PER_TARGET', |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4029 | '-DCONFIG_TARGET="@0@-config-target.h"'.format(target), |
| 4030 | '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)] |
Paolo Bonzini | b6c7cfd | 2020-09-21 04:49:50 -0400 | [diff] [blame] | 4031 | link_args = emulator_link_args |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4032 | |
| 4033 | target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])] |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4034 | if host_os == 'linux' |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4035 | target_inc += include_directories('linux-headers', is_system: true) |
| 4036 | endif |
| 4037 | if target.endswith('-softmmu') |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4038 | target_type='system' |
Philippe Mathieu-Daudé | 01c85e6 | 2023-10-04 11:06:27 +0200 | [diff] [blame] | 4039 | t = target_system_arch[target_base_arch].apply(config_target, strict: false) |
Paolo Bonzini | abff1ab | 2020-08-07 12:10:23 +0200 | [diff] [blame] | 4040 | arch_srcs += t.sources() |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4041 | arch_deps += t.dependencies() |
Paolo Bonzini | abff1ab | 2020-08-07 12:10:23 +0200 | [diff] [blame] | 4042 | |
Paolo Bonzini | ffb91f6 | 2021-11-08 15:44:39 +0100 | [diff] [blame] | 4043 | hw_dir = target_name == 'sparc64' ? 'sparc64' : target_base_arch |
Philippe Mathieu-Daudé | bf96432 | 2023-11-21 13:52:48 +0100 | [diff] [blame] | 4044 | if hw_arch.has_key(hw_dir) |
| 4045 | hw = hw_arch[hw_dir].apply(config_target, strict: false) |
| 4046 | arch_srcs += hw.sources() |
| 4047 | arch_deps += hw.dependencies() |
| 4048 | endif |
Marc-André Lureau | 2c44220 | 2019-08-17 13:55:58 +0400 | [diff] [blame] | 4049 | |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4050 | arch_srcs += config_devices_h[target] |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4051 | link_args += ['@block.syms', '@qemu.syms'] |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4052 | else |
Marc-André Lureau | 3a30446 | 2019-08-18 16:13:08 +0400 | [diff] [blame] | 4053 | abi = config_target['TARGET_ABI_DIR'] |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4054 | target_type='user' |
Paolo Bonzini | a3a576b | 2021-12-21 16:23:55 +0100 | [diff] [blame] | 4055 | target_inc += common_user_inc |
Paolo Bonzini | ffb91f6 | 2021-11-08 15:44:39 +0100 | [diff] [blame] | 4056 | if target_base_arch in target_user_arch |
| 4057 | t = target_user_arch[target_base_arch].apply(config_target, strict: false) |
Philippe Mathieu-Daudé | 46369b5 | 2021-04-13 11:27:09 +0200 | [diff] [blame] | 4058 | arch_srcs += t.sources() |
| 4059 | arch_deps += t.dependencies() |
| 4060 | endif |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4061 | if 'CONFIG_LINUX_USER' in config_target |
| 4062 | base_dir = 'linux-user' |
Warner Losh | e2a7472 | 2021-08-03 17:17:17 -0600 | [diff] [blame] | 4063 | endif |
| 4064 | if 'CONFIG_BSD_USER' in config_target |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4065 | base_dir = 'bsd-user' |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4066 | target_inc += include_directories('bsd-user/' / host_os) |
Warner Losh | 85fc1b5 | 2022-01-08 17:27:34 -0700 | [diff] [blame] | 4067 | target_inc += include_directories('bsd-user/host/' / host_arch) |
Warner Losh | e2a7472 | 2021-08-03 17:17:17 -0600 | [diff] [blame] | 4068 | dir = base_dir / abi |
Warner Losh | 19bf129 | 2021-11-04 16:34:48 -0600 | [diff] [blame] | 4069 | arch_srcs += files(dir / 'signal.c', dir / 'target_arch_cpu.c') |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4070 | endif |
| 4071 | target_inc += include_directories( |
| 4072 | base_dir, |
Marc-André Lureau | 3a30446 | 2019-08-18 16:13:08 +0400 | [diff] [blame] | 4073 | base_dir / abi, |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4074 | ) |
Marc-André Lureau | 3a30446 | 2019-08-18 16:13:08 +0400 | [diff] [blame] | 4075 | if 'CONFIG_LINUX_USER' in config_target |
| 4076 | dir = base_dir / abi |
| 4077 | arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c') |
| 4078 | if config_target.has_key('TARGET_SYSTBL_ABI') |
| 4079 | arch_srcs += \ |
| 4080 | syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'], |
| 4081 | extra_args : config_target['TARGET_SYSTBL_ABI']) |
| 4082 | endif |
| 4083 | endif |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4084 | endif |
| 4085 | |
Marc-André Lureau | c9322ab | 2019-08-18 19:51:17 +0400 | [diff] [blame] | 4086 | if 'TARGET_XML_FILES' in config_target |
| 4087 | gdbstub_xml = custom_target(target + '-gdbstub-xml.c', |
| 4088 | output: target + '-gdbstub-xml.c', |
| 4089 | input: files(config_target['TARGET_XML_FILES'].split()), |
| 4090 | command: [feature_to_c, '@INPUT@'], |
| 4091 | capture: true) |
| 4092 | arch_srcs += gdbstub_xml |
| 4093 | endif |
| 4094 | |
Paolo Bonzini | ffb91f6 | 2021-11-08 15:44:39 +0100 | [diff] [blame] | 4095 | t = target_arch[target_base_arch].apply(config_target, strict: false) |
Paolo Bonzini | abff1ab | 2020-08-07 12:10:23 +0200 | [diff] [blame] | 4096 | arch_srcs += t.sources() |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4097 | arch_deps += t.dependencies() |
Paolo Bonzini | abff1ab | 2020-08-07 12:10:23 +0200 | [diff] [blame] | 4098 | |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4099 | target_common = common_ss.apply(config_target, strict: false) |
| 4100 | objects = common_all.extract_objects(target_common.sources()) |
Paolo Bonzini | 727bb5b | 2024-05-07 12:22:31 +0200 | [diff] [blame] | 4101 | arch_deps += target_common.dependencies() |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4102 | |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4103 | target_specific = specific_ss.apply(config_target, strict: false) |
| 4104 | arch_srcs += target_specific.sources() |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4105 | arch_deps += target_specific.dependencies() |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4106 | |
Manos Pitsidianakis | 37fdb2f | 2024-10-24 17:03:00 +0300 | [diff] [blame] | 4107 | if have_rust and have_system |
| 4108 | target_rust = rust_devices_ss.apply(config_target, strict: false) |
| 4109 | crates = [] |
| 4110 | foreach dep : target_rust.dependencies() |
| 4111 | crates += dep.get_variable('crate') |
| 4112 | endforeach |
| 4113 | if crates.length() > 0 |
| 4114 | rlib_rs = custom_target('rust_' + target.underscorify() + '.rs', |
| 4115 | output: 'rust_' + target.underscorify() + '.rs', |
Paolo Bonzini | d1e526c | 2024-10-15 11:59:14 +0200 | [diff] [blame] | 4116 | command: [rust_root_crate, crates], |
Manos Pitsidianakis | 37fdb2f | 2024-10-24 17:03:00 +0300 | [diff] [blame] | 4117 | capture: true, |
| 4118 | build_by_default: true, |
| 4119 | build_always_stale: true) |
| 4120 | rlib = static_library('rust_' + target.underscorify(), |
| 4121 | rlib_rs, |
| 4122 | dependencies: target_rust.dependencies(), |
| 4123 | override_options: ['rust_std=2021', 'build.rust_std=2021'], |
Manos Pitsidianakis | 37fdb2f | 2024-10-24 17:03:00 +0300 | [diff] [blame] | 4124 | rust_abi: 'c') |
| 4125 | arch_deps += declare_dependency(link_whole: [rlib]) |
| 4126 | endif |
| 4127 | endif |
| 4128 | |
Paolo Bonzini | 727bb5b | 2024-05-07 12:22:31 +0200 | [diff] [blame] | 4129 | # allow using headers from the dependencies but do not include the sources, |
| 4130 | # because this emulator only needs those in "objects". For external |
| 4131 | # dependencies, the full dependency is included below in the executable. |
| 4132 | lib_deps = [] |
| 4133 | foreach dep : arch_deps |
| 4134 | lib_deps += dep.partial_dependency(compile_args: true, includes: true) |
| 4135 | endforeach |
| 4136 | |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4137 | lib = static_library('qemu-' + target, |
Paolo Bonzini | 859aef0 | 2020-08-04 18:14:26 +0200 | [diff] [blame] | 4138 | sources: arch_srcs + genh, |
Paolo Bonzini | 727bb5b | 2024-05-07 12:22:31 +0200 | [diff] [blame] | 4139 | dependencies: lib_deps, |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4140 | objects: objects, |
| 4141 | include_directories: target_inc, |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4142 | c_args: c_args, |
Paolo Bonzini | 4408155 | 2024-05-24 10:56:55 +0200 | [diff] [blame] | 4143 | build_by_default: false) |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4144 | |
| 4145 | if target.endswith('-softmmu') |
| 4146 | execs = [{ |
| 4147 | 'name': 'qemu-system-' + target_name, |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 4148 | 'win_subsystem': 'console', |
Philippe Mathieu-Daudé | 8d7f2e7 | 2023-10-04 11:06:28 +0200 | [diff] [blame] | 4149 | 'sources': files('system/main.c'), |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4150 | 'dependencies': [] |
| 4151 | }] |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4152 | if host_os == 'windows' and (sdl.found() or gtk.found()) |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4153 | execs += [{ |
| 4154 | 'name': 'qemu-system-' + target_name + 'w', |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 4155 | 'win_subsystem': 'windows', |
Philippe Mathieu-Daudé | 8d7f2e7 | 2023-10-04 11:06:28 +0200 | [diff] [blame] | 4156 | 'sources': files('system/main.c'), |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4157 | 'dependencies': [] |
| 4158 | }] |
| 4159 | endif |
Paolo Bonzini | 537b724 | 2021-10-07 15:08:12 +0200 | [diff] [blame] | 4160 | if get_option('fuzzing') |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4161 | specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false) |
| 4162 | execs += [{ |
| 4163 | 'name': 'qemu-fuzz-' + target_name, |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 4164 | 'win_subsystem': 'console', |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4165 | 'sources': specific_fuzz.sources(), |
| 4166 | 'dependencies': specific_fuzz.dependencies(), |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4167 | }] |
| 4168 | endif |
| 4169 | else |
| 4170 | execs = [{ |
| 4171 | 'name': 'qemu-' + target_name, |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 4172 | 'win_subsystem': 'console', |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4173 | 'sources': [], |
| 4174 | 'dependencies': [] |
| 4175 | }] |
| 4176 | endif |
| 4177 | foreach exe: execs |
Alexander Graf | 8a74ce6 | 2021-01-20 23:44:34 +0100 | [diff] [blame] | 4178 | exe_name = exe['name'] |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4179 | if host_os == 'darwin' |
Alexander Graf | 8a74ce6 | 2021-01-20 23:44:34 +0100 | [diff] [blame] | 4180 | exe_name += '-unsigned' |
| 4181 | endif |
| 4182 | |
| 4183 | emulator = executable(exe_name, exe['sources'], |
Akihiko Odaki | 237377a | 2021-02-25 09:06:14 +0900 | [diff] [blame] | 4184 | install: true, |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4185 | c_args: c_args, |
Paolo Bonzini | 727bb5b | 2024-05-07 12:22:31 +0200 | [diff] [blame] | 4186 | dependencies: arch_deps + exe['dependencies'], |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4187 | objects: lib.extract_all_objects(recursive: true), |
Paolo Bonzini | 0500725 | 2024-03-20 11:28:28 +0100 | [diff] [blame] | 4188 | link_depends: [block_syms, qemu_syms], |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4189 | link_args: link_args, |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 4190 | win_subsystem: exe['win_subsystem']) |
Alexander Graf | 8a74ce6 | 2021-01-20 23:44:34 +0100 | [diff] [blame] | 4191 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4192 | if host_os == 'darwin' |
Akihiko Odaki | 411ad8d | 2021-07-09 10:25:33 +0900 | [diff] [blame] | 4193 | icon = 'pc-bios/qemu.rsrc' |
| 4194 | build_input = [emulator, files(icon)] |
| 4195 | install_input = [ |
| 4196 | get_option('bindir') / exe_name, |
| 4197 | meson.current_source_dir() / icon |
| 4198 | ] |
| 4199 | if 'CONFIG_HVF' in config_target |
| 4200 | entitlements = 'accel/hvf/entitlements.plist' |
| 4201 | build_input += files(entitlements) |
| 4202 | install_input += meson.current_source_dir() / entitlements |
| 4203 | endif |
| 4204 | |
Alexander Graf | 8a74ce6 | 2021-01-20 23:44:34 +0100 | [diff] [blame] | 4205 | emulators += {exe['name'] : custom_target(exe['name'], |
Akihiko Odaki | 411ad8d | 2021-07-09 10:25:33 +0900 | [diff] [blame] | 4206 | input: build_input, |
Alexander Graf | 8a74ce6 | 2021-01-20 23:44:34 +0100 | [diff] [blame] | 4207 | output: exe['name'], |
Philippe Mathieu-Daudé | 235b523 | 2022-01-22 01:20:52 +0100 | [diff] [blame] | 4208 | command: [entitlement, '@OUTPUT@', '@INPUT@']) |
Alexander Graf | 8a74ce6 | 2021-01-20 23:44:34 +0100 | [diff] [blame] | 4209 | } |
Akihiko Odaki | 237377a | 2021-02-25 09:06:14 +0900 | [diff] [blame] | 4210 | |
Philippe Mathieu-Daudé | 235b523 | 2022-01-22 01:20:52 +0100 | [diff] [blame] | 4211 | meson.add_install_script(entitlement, '--install', |
Akihiko Odaki | 237377a | 2021-02-25 09:06:14 +0900 | [diff] [blame] | 4212 | get_option('bindir') / exe['name'], |
Akihiko Odaki | 411ad8d | 2021-07-09 10:25:33 +0900 | [diff] [blame] | 4213 | install_input) |
Alexander Graf | 8a74ce6 | 2021-01-20 23:44:34 +0100 | [diff] [blame] | 4214 | else |
| 4215 | emulators += {exe['name']: emulator} |
| 4216 | endif |
Marc-André Lureau | 10e1d26 | 2019-08-20 12:29:52 +0400 | [diff] [blame] | 4217 | |
Daniel P. Berrangé | 2b608e1 | 2024-01-08 17:13:56 +0000 | [diff] [blame] | 4218 | traceable += [{ |
| 4219 | 'exe': exe['name'], |
| 4220 | 'probe-prefix': 'qemu.' + target_type + '.' + target_name, |
| 4221 | }] |
| 4222 | |
Paolo Bonzini | 64ed6f9 | 2020-08-03 17:04:25 +0200 | [diff] [blame] | 4223 | endforeach |
Paolo Bonzini | 2becc36 | 2020-02-03 11:42:03 +0100 | [diff] [blame] | 4224 | endforeach |
| 4225 | |
Paolo Bonzini | 931049b | 2020-02-05 09:44:24 +0100 | [diff] [blame] | 4226 | # Other build targets |
Marc-André Lureau | 897b5af | 2019-07-16 21:54:15 +0400 | [diff] [blame] | 4227 | |
Paolo Bonzini | 2c13c57 | 2023-08-30 12:20:53 +0200 | [diff] [blame] | 4228 | if get_option('plugins') |
Paolo Bonzini | f556b4a | 2020-01-24 13:08:01 +0100 | [diff] [blame] | 4229 | install_headers('include/qemu/qemu-plugin.h') |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4230 | if host_os == 'windows' |
Greg Manning | 36fa077 | 2023-11-06 18:51:06 +0000 | [diff] [blame] | 4231 | # On windows, we want to deliver the qemu_plugin_api.lib file in the qemu installer, |
| 4232 | # so that plugin authors can compile against it. |
| 4233 | install_data(win32_qemu_plugin_api_lib, install_dir: 'lib') |
| 4234 | endif |
Paolo Bonzini | f556b4a | 2020-01-24 13:08:01 +0100 | [diff] [blame] | 4235 | endif |
| 4236 | |
Paolo Bonzini | 20cf5cb | 2021-10-15 16:47:43 +0200 | [diff] [blame] | 4237 | subdir('qga') |
Paolo Bonzini | f15bff2 | 2019-07-18 13:19:02 +0200 | [diff] [blame] | 4238 | |
Laurent Vivier | 9755c94 | 2020-08-24 17:24:30 +0200 | [diff] [blame] | 4239 | # Don't build qemu-keymap if xkbcommon is not explicitly enabled |
| 4240 | # when we don't build tools or system |
Laurent Vivier | 4113f4c | 2020-08-24 17:24:29 +0200 | [diff] [blame] | 4241 | if xkbcommon.found() |
Marc-André Lureau | 2874246 | 2019-09-19 20:24:43 +0400 | [diff] [blame] | 4242 | # used for the update-keymaps target, so include rules even if !have_tools |
| 4243 | qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh, |
| 4244 | dependencies: [qemuutil, xkbcommon], install: have_tools) |
| 4245 | endif |
| 4246 | |
Paolo Bonzini | 931049b | 2020-02-05 09:44:24 +0100 | [diff] [blame] | 4247 | if have_tools |
Marc-André Lureau | b7c70bf | 2019-07-16 21:37:25 +0400 | [diff] [blame] | 4248 | qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep], |
Paolo Bonzini | e8f6268 | 2024-05-24 13:17:08 +0200 | [diff] [blame] | 4249 | link_args: '@block.syms', link_depends: block_syms, |
Marc-André Lureau | b7c70bf | 2019-07-16 21:37:25 +0400 | [diff] [blame] | 4250 | dependencies: [authz, block, crypto, io, qom, qemuutil], install: true) |
| 4251 | qemu_io = executable('qemu-io', files('qemu-io.c'), |
Paolo Bonzini | e8f6268 | 2024-05-24 13:17:08 +0200 | [diff] [blame] | 4252 | link_args: '@block.syms', link_depends: block_syms, |
Marc-André Lureau | b7c70bf | 2019-07-16 21:37:25 +0400 | [diff] [blame] | 4253 | dependencies: [block, qemuutil], install: true) |
Daniel P. Berrangé | eb70598 | 2020-08-25 11:38:50 +0100 | [diff] [blame] | 4254 | qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'), |
Paolo Bonzini | e8f6268 | 2024-05-24 13:17:08 +0200 | [diff] [blame] | 4255 | link_args: '@block.syms', link_depends: block_syms, |
Akihiko Odaki | 7b1070a | 2024-05-24 17:00:23 +0900 | [diff] [blame] | 4256 | dependencies: [blockdev, qemuutil, selinux], |
Richard W.M. Jones | 3d212b4 | 2021-11-15 14:29:43 -0600 | [diff] [blame] | 4257 | install: true) |
Marc-André Lureau | b7c70bf | 2019-07-16 21:37:25 +0400 | [diff] [blame] | 4258 | |
Paolo Bonzini | 7c58bb7 | 2020-08-04 20:18:36 +0200 | [diff] [blame] | 4259 | subdir('storage-daemon') |
Daniel P. Berrangé | 2b608e1 | 2024-01-08 17:13:56 +0000 | [diff] [blame] | 4260 | |
| 4261 | foreach exe: [ 'qemu-img', 'qemu-io', 'qemu-nbd', 'qemu-storage-daemon'] |
| 4262 | traceable += [{ |
| 4263 | 'exe': exe, |
| 4264 | 'probe-prefix': 'qemu.' + exe.substring(5).replace('-', '_') |
| 4265 | }] |
| 4266 | endforeach |
| 4267 | |
Marc-André Lureau | 1d7bb6a | 2019-07-12 23:47:06 +0400 | [diff] [blame] | 4268 | subdir('contrib/elf2dmp') |
Paolo Bonzini | a9c9727 | 2019-06-10 12:27:52 +0200 | [diff] [blame] | 4269 | |
Marc-André Lureau | 157e7b1 | 2019-07-15 14:50:58 +0400 | [diff] [blame] | 4270 | executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'), |
| 4271 | dependencies: qemuutil, |
| 4272 | install: true) |
| 4273 | |
Paolo Bonzini | 2a3129a | 2022-04-20 17:34:05 +0200 | [diff] [blame] | 4274 | if have_vhost_user |
Paolo Bonzini | 2d7ac0a | 2019-06-10 12:18:02 +0200 | [diff] [blame] | 4275 | subdir('contrib/vhost-user-blk') |
Paolo Bonzini | b7612f4 | 2020-08-26 08:22:58 +0200 | [diff] [blame] | 4276 | subdir('contrib/vhost-user-gpu') |
Marc-André Lureau | 32fcc62 | 2019-07-12 22:11:20 +0400 | [diff] [blame] | 4277 | subdir('contrib/vhost-user-input') |
Paolo Bonzini | 99650b6 | 2019-06-10 12:21:14 +0200 | [diff] [blame] | 4278 | subdir('contrib/vhost-user-scsi') |
Paolo Bonzini | 931049b | 2020-02-05 09:44:24 +0100 | [diff] [blame] | 4279 | endif |
Marc-André Lureau | 8f51e01 | 2019-07-15 14:39:25 +0400 | [diff] [blame] | 4280 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4281 | if host_os == 'linux' |
Marc-André Lureau | 8f51e01 | 2019-07-15 14:39:25 +0400 | [diff] [blame] | 4282 | executable('qemu-bridge-helper', files('qemu-bridge-helper.c'), |
| 4283 | dependencies: [qemuutil, libcap_ng], |
| 4284 | install: true, |
| 4285 | install_dir: get_option('libexecdir')) |
Marc-André Lureau | 897b5af | 2019-07-16 21:54:15 +0400 | [diff] [blame] | 4286 | |
| 4287 | executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'), |
| 4288 | dependencies: [authz, crypto, io, qom, qemuutil, |
Paolo Bonzini | 6ec0e15 | 2020-09-16 18:07:29 +0200 | [diff] [blame] | 4289 | libcap_ng, mpathpersist], |
Marc-André Lureau | 897b5af | 2019-07-16 21:54:15 +0400 | [diff] [blame] | 4290 | install: true) |
Anthony Harivel | 84369d7 | 2024-05-22 17:34:51 +0200 | [diff] [blame] | 4291 | |
| 4292 | if cpu in ['x86', 'x86_64'] |
| 4293 | executable('qemu-vmsr-helper', files('tools/i386/qemu-vmsr-helper.c'), |
| 4294 | dependencies: [authz, crypto, io, qom, qemuutil, |
| 4295 | libcap_ng, mpathpersist], |
| 4296 | install: true) |
| 4297 | endif |
Marc-André Lureau | 8f51e01 | 2019-07-15 14:39:25 +0400 | [diff] [blame] | 4298 | endif |
| 4299 | |
Paolo Bonzini | ccd250a | 2021-06-03 12:50:17 +0200 | [diff] [blame] | 4300 | if have_ivshmem |
Marc-André Lureau | 5ee24e7 | 2019-07-12 23:16:54 +0400 | [diff] [blame] | 4301 | subdir('contrib/ivshmem-client') |
| 4302 | subdir('contrib/ivshmem-server') |
| 4303 | endif |
Paolo Bonzini | 931049b | 2020-02-05 09:44:24 +0100 | [diff] [blame] | 4304 | endif |
| 4305 | |
Daniel P. Berrangé | 2b608e1 | 2024-01-08 17:13:56 +0000 | [diff] [blame] | 4306 | if stap.found() |
| 4307 | foreach t: traceable |
| 4308 | foreach stp: [ |
| 4309 | {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / t['exe'], 'install': false}, |
| 4310 | {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / t['exe'], 'install': true}, |
| 4311 | {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true}, |
| 4312 | {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true}, |
| 4313 | ] |
| 4314 | cmd = [ |
| 4315 | tracetool, '--group=all', '--format=' + stp['fmt'], |
| 4316 | '--binary=' + stp['bin'], |
| 4317 | '--probe-prefix=' + t['probe-prefix'], |
| 4318 | '@INPUT@', '@OUTPUT@' |
| 4319 | ] |
| 4320 | |
| 4321 | custom_target(t['exe'] + stp['ext'], |
| 4322 | input: trace_events_all, |
| 4323 | output: t['exe'] + stp['ext'], |
| 4324 | install: stp['install'], |
| 4325 | install_dir: get_option('datadir') / 'systemtap/tapset', |
| 4326 | command: cmd, |
| 4327 | depend_files: tracetool_depends) |
| 4328 | endforeach |
| 4329 | endforeach |
| 4330 | endif |
| 4331 | |
Marc-André Lureau | f5aa632 | 2020-08-26 17:06:18 +0400 | [diff] [blame] | 4332 | subdir('scripts') |
Paolo Bonzini | 3f99cf5 | 2020-02-05 09:45:39 +0100 | [diff] [blame] | 4333 | subdir('tools') |
Marc-André Lureau | bdcbea7 | 2019-07-15 21:22:31 +0400 | [diff] [blame] | 4334 | subdir('pc-bios') |
Paolo Bonzini | f8aa24e | 2020-08-05 15:49:10 +0200 | [diff] [blame] | 4335 | subdir('docs') |
Yonggang Luo | e366766 | 2020-10-16 06:06:25 +0800 | [diff] [blame] | 4336 | subdir('tests') |
Paolo Bonzini | 1b69547 | 2021-01-07 14:02:29 +0100 | [diff] [blame] | 4337 | if gtk.found() |
Marc-André Lureau | e8f3bd7 | 2019-09-19 21:02:09 +0400 | [diff] [blame] | 4338 | subdir('po') |
| 4339 | endif |
Paolo Bonzini | 3f99cf5 | 2020-02-05 09:45:39 +0100 | [diff] [blame] | 4340 | |
Marc-André Lureau | 8adfeba | 2020-08-26 15:04:19 +0400 | [diff] [blame] | 4341 | if host_machine.system() == 'windows' |
| 4342 | nsis_cmd = [ |
| 4343 | find_program('scripts/nsis.py'), |
| 4344 | '@OUTPUT@', |
| 4345 | get_option('prefix'), |
| 4346 | meson.current_source_dir(), |
Paolo Bonzini | fc9a809 | 2022-10-12 11:31:32 +0200 | [diff] [blame] | 4347 | glib_pc.get_variable('bindir'), |
Stefan Weil | 24bdcc9 | 2020-11-25 20:18:33 +0100 | [diff] [blame] | 4348 | host_machine.cpu(), |
Marc-André Lureau | 8adfeba | 2020-08-26 15:04:19 +0400 | [diff] [blame] | 4349 | '--', |
| 4350 | '-DDISPLAYVERSION=' + meson.project_version(), |
| 4351 | ] |
| 4352 | if build_docs |
| 4353 | nsis_cmd += '-DCONFIG_DOCUMENTATION=y' |
| 4354 | endif |
Paolo Bonzini | 1b69547 | 2021-01-07 14:02:29 +0100 | [diff] [blame] | 4355 | if gtk.found() |
Marc-André Lureau | 8adfeba | 2020-08-26 15:04:19 +0400 | [diff] [blame] | 4356 | nsis_cmd += '-DCONFIG_GTK=y' |
| 4357 | endif |
| 4358 | |
| 4359 | nsis = custom_target('nsis', |
| 4360 | output: 'qemu-setup-' + meson.project_version() + '.exe', |
| 4361 | input: files('qemu.nsi'), |
| 4362 | build_always_stale: true, |
| 4363 | command: nsis_cmd + ['@INPUT@']) |
| 4364 | alias_target('installer', nsis) |
| 4365 | endif |
| 4366 | |
Paolo Bonzini | a0c9162 | 2020-10-07 11:01:51 -0400 | [diff] [blame] | 4367 | ######################### |
| 4368 | # Configuration summary # |
| 4369 | ######################### |
| 4370 | |
Paolo Bonzini | ac4ccac | 2023-05-18 16:11:29 +0200 | [diff] [blame] | 4371 | # Build environment |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4372 | summary_info = {} |
Paolo Bonzini | ac4ccac | 2023-05-18 16:11:29 +0200 | [diff] [blame] | 4373 | summary_info += {'Build directory': meson.current_build_dir()} |
| 4374 | summary_info += {'Source path': meson.current_source_dir()} |
Paolo Bonzini | ac4ccac | 2023-05-18 16:11:29 +0200 | [diff] [blame] | 4375 | summary_info += {'Download dependencies': get_option('wrap_mode') != 'nodownload'} |
| 4376 | summary(summary_info, bool_yn: true, section: 'Build environment') |
| 4377 | |
| 4378 | # Directories |
Paolo Bonzini | 16bf7a3 | 2020-10-16 03:19:14 -0400 | [diff] [blame] | 4379 | summary_info += {'Install prefix': get_option('prefix')} |
| 4380 | summary_info += {'BIOS directory': qemu_datadir} |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4381 | pathsep = host_os == 'windows' ? ';' : ':' |
Akihiko Odaki | 8154f5e | 2022-06-25 00:40:42 +0900 | [diff] [blame] | 4382 | summary_info += {'firmware path': pathsep.join(get_option('qemu_firmwarepath'))} |
Paolo Bonzini | f7fb6c6 | 2022-04-20 17:33:56 +0200 | [diff] [blame] | 4383 | summary_info += {'binary directory': get_option('prefix') / get_option('bindir')} |
| 4384 | summary_info += {'library directory': get_option('prefix') / get_option('libdir')} |
Paolo Bonzini | 16bf7a3 | 2020-10-16 03:19:14 -0400 | [diff] [blame] | 4385 | summary_info += {'module directory': qemu_moddir} |
Paolo Bonzini | f7fb6c6 | 2022-04-20 17:33:56 +0200 | [diff] [blame] | 4386 | summary_info += {'libexec directory': get_option('prefix') / get_option('libexecdir')} |
| 4387 | summary_info += {'include directory': get_option('prefix') / get_option('includedir')} |
| 4388 | summary_info += {'config directory': get_option('prefix') / get_option('sysconfdir')} |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4389 | if host_os != 'windows' |
Paolo Bonzini | f7fb6c6 | 2022-04-20 17:33:56 +0200 | [diff] [blame] | 4390 | summary_info += {'local state directory': get_option('prefix') / get_option('localstatedir')} |
| 4391 | summary_info += {'Manual directory': get_option('prefix') / get_option('mandir')} |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4392 | else |
| 4393 | summary_info += {'local state directory': 'queried at runtime'} |
| 4394 | endif |
Paolo Bonzini | f7fb6c6 | 2022-04-20 17:33:56 +0200 | [diff] [blame] | 4395 | summary_info += {'Doc directory': get_option('prefix') / get_option('docdir')} |
Philippe Mathieu-Daudé | 983d0a7 | 2021-01-21 10:56:09 +0100 | [diff] [blame] | 4396 | summary(summary_info, bool_yn: true, section: 'Directories') |
| 4397 | |
Philippe Mathieu-Daudé | e11a0e1 | 2021-01-21 10:56:10 +0100 | [diff] [blame] | 4398 | # Host binaries |
Philippe Mathieu-Daudé | 983d0a7 | 2021-01-21 10:56:09 +0100 | [diff] [blame] | 4399 | summary_info = {} |
Philippe Mathieu-Daudé | e11a0e1 | 2021-01-21 10:56:10 +0100 | [diff] [blame] | 4400 | summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4401 | summary_info += {'sphinx-build': sphinx_build} |
Paolo Bonzini | b4d61d3 | 2023-09-28 12:00:48 +0200 | [diff] [blame] | 4402 | |
| 4403 | # FIXME: the [binaries] section of machine files, which can be probed |
| 4404 | # with find_program(), would be great for passing gdb and genisoimage |
| 4405 | # paths from configure to Meson. However, there seems to be no way to |
| 4406 | # hide a program (for example if gdb is too old). |
Paolo Bonzini | a47dd5c | 2023-09-28 10:44:56 +0200 | [diff] [blame] | 4407 | if config_host.has_key('GDB') |
| 4408 | summary_info += {'gdb': config_host['GDB']} |
Philippe Mathieu-Daudé | e11a0e1 | 2021-01-21 10:56:10 +0100 | [diff] [blame] | 4409 | endif |
Paolo Bonzini | 40c909f | 2022-04-20 17:33:49 +0200 | [diff] [blame] | 4410 | summary_info += {'iasl': iasl} |
Philippe Mathieu-Daudé | e11a0e1 | 2021-01-21 10:56:10 +0100 | [diff] [blame] | 4411 | summary_info += {'genisoimage': config_host['GENISOIMAGE']} |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4412 | if host_os == 'windows' and have_ga |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4413 | summary_info += {'wixl': wixl} |
Philippe Mathieu-Daudé | e11a0e1 | 2021-01-21 10:56:10 +0100 | [diff] [blame] | 4414 | endif |
Thomas Huth | 5890258 | 2022-04-08 18:20:47 +0200 | [diff] [blame] | 4415 | if slirp.found() and have_system |
Paolo Bonzini | 35acbb3 | 2021-10-13 13:43:36 +0200 | [diff] [blame] | 4416 | summary_info += {'smbd': have_slirp_smbd ? smbd_path : false} |
Philippe Mathieu-Daudé | e11a0e1 | 2021-01-21 10:56:10 +0100 | [diff] [blame] | 4417 | endif |
| 4418 | summary(summary_info, bool_yn: true, section: 'Host binaries') |
| 4419 | |
Philippe Mathieu-Daudé | 1d71886 | 2021-01-21 10:56:11 +0100 | [diff] [blame] | 4420 | # Configurable features |
| 4421 | summary_info = {} |
| 4422 | summary_info += {'Documentation': build_docs} |
Philippe Mathieu-Daudé | aa3ca63 | 2021-01-21 10:56:13 +0100 | [diff] [blame] | 4423 | summary_info += {'system-mode emulation': have_system} |
| 4424 | summary_info += {'user-mode emulation': have_user} |
Philippe Mathieu-Daudé | 813803a | 2021-01-21 10:56:14 +0100 | [diff] [blame] | 4425 | summary_info += {'block layer': have_block} |
Philippe Mathieu-Daudé | 1d71886 | 2021-01-21 10:56:11 +0100 | [diff] [blame] | 4426 | summary_info += {'Install blobs': get_option('install_blobs')} |
Paolo Bonzini | 6002711 | 2022-10-20 14:53:10 +0200 | [diff] [blame] | 4427 | summary_info += {'module support': enable_modules} |
| 4428 | if enable_modules |
Paolo Bonzini | 2cb2f58 | 2022-04-20 17:33:46 +0200 | [diff] [blame] | 4429 | summary_info += {'alternative module path': get_option('module_upgrades')} |
Philippe Mathieu-Daudé | 1d71886 | 2021-01-21 10:56:11 +0100 | [diff] [blame] | 4430 | endif |
Paolo Bonzini | 537b724 | 2021-10-07 15:08:12 +0200 | [diff] [blame] | 4431 | summary_info += {'fuzzing support': get_option('fuzzing')} |
Philippe Mathieu-Daudé | 1d71886 | 2021-01-21 10:56:11 +0100 | [diff] [blame] | 4432 | if have_system |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 4433 | summary_info += {'Audio drivers': ' '.join(audio_drivers_selected)} |
Philippe Mathieu-Daudé | 1d71886 | 2021-01-21 10:56:11 +0100 | [diff] [blame] | 4434 | endif |
Paolo Bonzini | 9c29b74 | 2021-10-07 15:08:14 +0200 | [diff] [blame] | 4435 | summary_info += {'Trace backends': ','.join(get_option('trace_backends'))} |
| 4436 | if 'simple' in get_option('trace_backends') |
| 4437 | summary_info += {'Trace output file': get_option('trace_file') + '-<pid>'} |
Philippe Mathieu-Daudé | 1d71886 | 2021-01-21 10:56:11 +0100 | [diff] [blame] | 4438 | endif |
Marc-André Lureau | 142ca62 | 2021-07-15 11:53:53 +0400 | [diff] [blame] | 4439 | summary_info += {'D-Bus display': dbus_display} |
Paolo Bonzini | c55cf6a | 2021-10-13 11:46:09 +0200 | [diff] [blame] | 4440 | summary_info += {'QOM debugging': get_option('qom_cast_debug')} |
Paolo Bonzini | 655e2a7 | 2023-10-05 14:19:34 +0200 | [diff] [blame] | 4441 | summary_info += {'Relocatable install': get_option('relocatable')} |
Paolo Bonzini | 2a3129a | 2022-04-20 17:34:05 +0200 | [diff] [blame] | 4442 | summary_info += {'vhost-kernel support': have_vhost_kernel} |
| 4443 | summary_info += {'vhost-net support': have_vhost_net} |
| 4444 | summary_info += {'vhost-user support': have_vhost_user} |
| 4445 | summary_info += {'vhost-user-crypto support': have_vhost_user_crypto} |
Philippe Mathieu-Daudé | 1d71886 | 2021-01-21 10:56:11 +0100 | [diff] [blame] | 4446 | summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server} |
Paolo Bonzini | 2a3129a | 2022-04-20 17:34:05 +0200 | [diff] [blame] | 4447 | summary_info += {'vhost-vdpa support': have_vhost_vdpa} |
Paolo Bonzini | 20cf5cb | 2021-10-15 16:47:43 +0200 | [diff] [blame] | 4448 | summary_info += {'build guest agent': have_ga} |
Philippe Mathieu-Daudé | 1d71886 | 2021-01-21 10:56:11 +0100 | [diff] [blame] | 4449 | summary(summary_info, bool_yn: true, section: 'Configurable features') |
| 4450 | |
Philippe Mathieu-Daudé | 2e864b8 | 2021-01-21 10:56:12 +0100 | [diff] [blame] | 4451 | # Compilation information |
Philippe Mathieu-Daudé | e11a0e1 | 2021-01-21 10:56:10 +0100 | [diff] [blame] | 4452 | summary_info = {} |
Philippe Mathieu-Daudé | 2e864b8 | 2021-01-21 10:56:12 +0100 | [diff] [blame] | 4453 | summary_info += {'host CPU': cpu} |
| 4454 | summary_info += {'host endianness': build_machine.endian()} |
Alex Bennée | 63de935 | 2021-05-27 17:03:15 +0100 | [diff] [blame] | 4455 | summary_info += {'C compiler': ' '.join(meson.get_compiler('c').cmd_array())} |
| 4456 | summary_info += {'Host C compiler': ' '.join(meson.get_compiler('c', native: true).cmd_array())} |
Thomas Huth | 785abf0 | 2023-07-06 08:47:36 +0200 | [diff] [blame] | 4457 | if 'cpp' in all_languages |
Alex Bennée | 63de935 | 2021-05-27 17:03:15 +0100 | [diff] [blame] | 4458 | summary_info += {'C++ compiler': ' '.join(meson.get_compiler('cpp').cmd_array())} |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4459 | else |
| 4460 | summary_info += {'C++ compiler': false} |
| 4461 | endif |
Philippe Mathieu-Daudé | da6f554 | 2023-10-09 08:51:29 +0200 | [diff] [blame] | 4462 | if 'objc' in all_languages |
Alex Bennée | 63de935 | 2021-05-27 17:03:15 +0100 | [diff] [blame] | 4463 | summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())} |
Philippe Mathieu-Daudé | da6f554 | 2023-10-09 08:51:29 +0200 | [diff] [blame] | 4464 | else |
| 4465 | summary_info += {'Objective-C compiler': false} |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4466 | endif |
Manos Pitsidianakis | 764a6ee | 2024-10-03 16:28:44 +0300 | [diff] [blame] | 4467 | summary_info += {'Rust support': have_rust} |
| 4468 | if have_rust |
Paolo Bonzini | 1a6ef6f | 2024-10-03 16:28:45 +0300 | [diff] [blame] | 4469 | summary_info += {'rustc version': rustc.version()} |
| 4470 | summary_info += {'rustc': ' '.join(rustc.cmd_array())} |
| 4471 | summary_info += {'Rust target': config_host['RUST_TARGET_TRIPLE']} |
Manos Pitsidianakis | 764a6ee | 2024-10-03 16:28:44 +0300 | [diff] [blame] | 4472 | endif |
Paolo Bonzini | 6a97f39 | 2022-11-02 13:07:23 +0100 | [diff] [blame] | 4473 | option_cflags = (get_option('debug') ? ['-g'] : []) |
| 4474 | if get_option('optimization') != 'plain' |
| 4475 | option_cflags += ['-O' + get_option('optimization')] |
| 4476 | endif |
| 4477 | summary_info += {'CFLAGS': ' '.join(get_option('c_args') + option_cflags)} |
Thomas Huth | 785abf0 | 2023-07-06 08:47:36 +0200 | [diff] [blame] | 4478 | if 'cpp' in all_languages |
Paolo Bonzini | 6a97f39 | 2022-11-02 13:07:23 +0100 | [diff] [blame] | 4479 | summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args') + option_cflags)} |
Paolo Bonzini | 47b3083 | 2020-09-23 05:26:17 -0400 | [diff] [blame] | 4480 | endif |
Philippe Mathieu-Daudé | da6f554 | 2023-10-09 08:51:29 +0200 | [diff] [blame] | 4481 | if 'objc' in all_languages |
Paolo Bonzini | 6a97f39 | 2022-11-02 13:07:23 +0100 | [diff] [blame] | 4482 | summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args') + option_cflags)} |
Philippe Mathieu-Daudé | e910c7d | 2022-01-08 22:38:55 +0100 | [diff] [blame] | 4483 | endif |
Thomas Huth | 785abf0 | 2023-07-06 08:47:36 +0200 | [diff] [blame] | 4484 | link_args = get_option('c_link_args') |
Paolo Bonzini | 47b3083 | 2020-09-23 05:26:17 -0400 | [diff] [blame] | 4485 | if link_args.length() > 0 |
| 4486 | summary_info += {'LDFLAGS': ' '.join(link_args)} |
| 4487 | endif |
Paolo Bonzini | d67212d | 2022-10-12 17:13:23 +0200 | [diff] [blame] | 4488 | summary_info += {'QEMU_CFLAGS': ' '.join(qemu_common_flags + qemu_cflags)} |
Paolo Bonzini | e513402 | 2022-10-12 14:15:06 +0200 | [diff] [blame] | 4489 | if 'cpp' in all_languages |
Paolo Bonzini | d67212d | 2022-10-12 17:13:23 +0200 | [diff] [blame] | 4490 | summary_info += {'QEMU_CXXFLAGS': ' '.join(qemu_common_flags + qemu_cxxflags)} |
Paolo Bonzini | e513402 | 2022-10-12 14:15:06 +0200 | [diff] [blame] | 4491 | endif |
| 4492 | if 'objc' in all_languages |
Paolo Bonzini | 95caf1f | 2022-12-22 09:28:56 +0100 | [diff] [blame] | 4493 | summary_info += {'QEMU_OBJCFLAGS': ' '.join(qemu_common_flags)} |
Paolo Bonzini | e513402 | 2022-10-12 14:15:06 +0200 | [diff] [blame] | 4494 | endif |
Paolo Bonzini | d065177 | 2022-04-20 17:33:34 +0200 | [diff] [blame] | 4495 | summary_info += {'QEMU_LDFLAGS': ' '.join(qemu_ldflags)} |
Daniele Buono | cdad781 | 2020-12-04 18:06:11 -0500 | [diff] [blame] | 4496 | summary_info += {'link-time optimization (LTO)': get_option('b_lto')} |
Philippe Mathieu-Daudé | 2e864b8 | 2021-01-21 10:56:12 +0100 | [diff] [blame] | 4497 | summary_info += {'PIE': get_option('b_pie')} |
Paolo Bonzini | e58e55d | 2023-06-07 10:00:21 +0200 | [diff] [blame] | 4498 | summary_info += {'static build': get_option('prefer_static')} |
Philippe Mathieu-Daudé | 2e864b8 | 2021-01-21 10:56:12 +0100 | [diff] [blame] | 4499 | summary_info += {'malloc trim support': has_malloc_trim} |
Paolo Bonzini | b87df90 | 2021-11-08 13:52:11 +0100 | [diff] [blame] | 4500 | summary_info += {'membarrier': have_membarrier} |
Stefan Hajnoczi | 58a2e3f | 2023-05-01 13:34:43 -0400 | [diff] [blame] | 4501 | summary_info += {'debug graph lock': get_option('debug_graph_lock')} |
Paolo Bonzini | 728c0a2 | 2021-10-13 11:52:03 +0200 | [diff] [blame] | 4502 | summary_info += {'debug stack usage': get_option('debug_stack_usage')} |
Paolo Bonzini | c55cf6a | 2021-10-13 11:46:09 +0200 | [diff] [blame] | 4503 | summary_info += {'mutex debugging': get_option('debug_mutex')} |
Philippe Mathieu-Daudé | 2e864b8 | 2021-01-21 10:56:12 +0100 | [diff] [blame] | 4504 | summary_info += {'memory allocator': get_option('malloc')} |
Paolo Bonzini | 622753d | 2021-11-08 13:38:58 +0100 | [diff] [blame] | 4505 | summary_info += {'avx2 optimization': config_host_data.get('CONFIG_AVX2_OPT')} |
ling xu | 04ffce1 | 2022-11-16 23:29:22 +0800 | [diff] [blame] | 4506 | summary_info += {'avx512bw optimization': config_host_data.get('CONFIG_AVX512BW_OPT')} |
Philippe Mathieu-Daudé | 2e864b8 | 2021-01-21 10:56:12 +0100 | [diff] [blame] | 4507 | summary_info += {'gcov': get_option('b_coverage')} |
Paolo Bonzini | 34f983d | 2023-01-09 15:31:51 +0100 | [diff] [blame] | 4508 | summary_info += {'thread sanitizer': get_option('tsan')} |
Philippe Mathieu-Daudé | 2e864b8 | 2021-01-21 10:56:12 +0100 | [diff] [blame] | 4509 | summary_info += {'CFI support': get_option('cfi')} |
| 4510 | if get_option('cfi') |
| 4511 | summary_info += {'CFI debug support': get_option('cfi_debug')} |
| 4512 | endif |
| 4513 | summary_info += {'strip binaries': get_option('strip')} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4514 | summary_info += {'sparse': sparse} |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4515 | summary_info += {'mingw32 support': host_os == 'windows'} |
Paolo Bonzini | 12640f0 | 2022-06-06 11:48:47 +0200 | [diff] [blame] | 4516 | summary(summary_info, bool_yn: true, section: 'Compilation') |
Alex Bennée | 49e8565 | 2021-02-22 10:14:50 +0000 | [diff] [blame] | 4517 | |
| 4518 | # snarf the cross-compilation information for tests |
Paolo Bonzini | 12640f0 | 2022-06-06 11:48:47 +0200 | [diff] [blame] | 4519 | summary_info = {} |
| 4520 | have_cross = false |
Alex Bennée | 49e8565 | 2021-02-22 10:14:50 +0000 | [diff] [blame] | 4521 | foreach target: target_dirs |
Paolo Bonzini | c7022a7 | 2022-09-29 12:42:07 +0100 | [diff] [blame] | 4522 | tcg_mak = meson.current_build_dir() / 'tests/tcg' / target / 'config-target.mak' |
Alex Bennée | 49e8565 | 2021-02-22 10:14:50 +0000 | [diff] [blame] | 4523 | if fs.exists(tcg_mak) |
| 4524 | config_cross_tcg = keyval.load(tcg_mak) |
Alex Bennée | 85b141e | 2022-05-27 16:35:34 +0100 | [diff] [blame] | 4525 | if 'CC' in config_cross_tcg |
Paolo Bonzini | 12640f0 | 2022-06-06 11:48:47 +0200 | [diff] [blame] | 4526 | summary_info += {config_cross_tcg['TARGET_NAME']: config_cross_tcg['CC']} |
| 4527 | have_cross = true |
Alex Bennée | 49e8565 | 2021-02-22 10:14:50 +0000 | [diff] [blame] | 4528 | endif |
Paolo Bonzini | 12640f0 | 2022-06-06 11:48:47 +0200 | [diff] [blame] | 4529 | endif |
Alex Bennée | 49e8565 | 2021-02-22 10:14:50 +0000 | [diff] [blame] | 4530 | endforeach |
Paolo Bonzini | 12640f0 | 2022-06-06 11:48:47 +0200 | [diff] [blame] | 4531 | if have_cross |
| 4532 | summary(summary_info, bool_yn: true, section: 'Cross compilers') |
| 4533 | endif |
Philippe Mathieu-Daudé | 2e864b8 | 2021-01-21 10:56:12 +0100 | [diff] [blame] | 4534 | |
Philippe Mathieu-Daudé | aa3ca63 | 2021-01-21 10:56:13 +0100 | [diff] [blame] | 4535 | # Targets and accelerators |
Philippe Mathieu-Daudé | 2e864b8 | 2021-01-21 10:56:12 +0100 | [diff] [blame] | 4536 | summary_info = {} |
Philippe Mathieu-Daudé | aa3ca63 | 2021-01-21 10:56:13 +0100 | [diff] [blame] | 4537 | if have_system |
Paolo Bonzini | cfc1a88 | 2023-09-29 11:40:03 +0200 | [diff] [blame] | 4538 | summary_info += {'KVM support': config_all_accel.has_key('CONFIG_KVM')} |
| 4539 | summary_info += {'HVF support': config_all_accel.has_key('CONFIG_HVF')} |
| 4540 | summary_info += {'WHPX support': config_all_accel.has_key('CONFIG_WHPX')} |
| 4541 | summary_info += {'NVMM support': config_all_accel.has_key('CONFIG_NVMM')} |
Paolo Bonzini | 14efd8d | 2022-04-20 17:33:47 +0200 | [diff] [blame] | 4542 | summary_info += {'Xen support': xen.found()} |
| 4543 | if xen.found() |
| 4544 | summary_info += {'xen ctrl version': xen.version()} |
Philippe Mathieu-Daudé | aa3ca63 | 2021-01-21 10:56:13 +0100 | [diff] [blame] | 4545 | endif |
Paolo Bonzini | 0d66549 | 2023-08-31 11:18:24 +0200 | [diff] [blame] | 4546 | summary_info += {'Xen emulation': config_all_devices.has_key('CONFIG_XEN_EMU')} |
Philippe Mathieu-Daudé | aa3ca63 | 2021-01-21 10:56:13 +0100 | [diff] [blame] | 4547 | endif |
Paolo Bonzini | cfc1a88 | 2023-09-29 11:40:03 +0200 | [diff] [blame] | 4548 | summary_info += {'TCG support': config_all_accel.has_key('CONFIG_TCG')} |
| 4549 | if config_all_accel.has_key('CONFIG_TCG') |
Philippe Mathieu-Daudé | 39687ac | 2021-01-25 15:45:29 +0100 | [diff] [blame] | 4550 | if get_option('tcg_interpreter') |
Philippe Mathieu-Daudé | f1f727a | 2021-11-06 12:14:57 +0100 | [diff] [blame] | 4551 | summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, slow)'} |
Philippe Mathieu-Daudé | 39687ac | 2021-01-25 15:45:29 +0100 | [diff] [blame] | 4552 | else |
| 4553 | summary_info += {'TCG backend': 'native (@0@)'.format(cpu)} |
| 4554 | endif |
Paolo Bonzini | 2c13c57 | 2023-08-30 12:20:53 +0200 | [diff] [blame] | 4555 | summary_info += {'TCG plugins': get_option('plugins')} |
Paolo Bonzini | 1d558c9 | 2023-08-28 11:48:30 +0200 | [diff] [blame] | 4556 | summary_info += {'TCG debug enabled': get_option('debug_tcg')} |
Ilya Leoshkevich | 1f2355f | 2024-03-12 01:23:30 +0100 | [diff] [blame] | 4557 | if have_linux_user or have_bsd_user |
| 4558 | summary_info += {'syscall buffer debugging support': get_option('debug_remap')} |
| 4559 | endif |
Philippe Mathieu-Daudé | aa3ca63 | 2021-01-21 10:56:13 +0100 | [diff] [blame] | 4560 | endif |
Philippe Mathieu-Daudé | 2e864b8 | 2021-01-21 10:56:12 +0100 | [diff] [blame] | 4561 | summary_info += {'target list': ' '.join(target_dirs)} |
Philippe Mathieu-Daudé | aa3ca63 | 2021-01-21 10:56:13 +0100 | [diff] [blame] | 4562 | if have_system |
| 4563 | summary_info += {'default devices': get_option('default_devices')} |
Paolo Bonzini | 106ad1f | 2021-02-17 16:24:25 +0100 | [diff] [blame] | 4564 | summary_info += {'out of process emulation': multiprocess_allowed} |
Jagannathan Raman | 5511696 | 2022-06-13 16:26:24 -0400 | [diff] [blame] | 4565 | summary_info += {'vfio-user server': vfio_user_server_allowed} |
Philippe Mathieu-Daudé | aa3ca63 | 2021-01-21 10:56:13 +0100 | [diff] [blame] | 4566 | endif |
| 4567 | summary(summary_info, bool_yn: true, section: 'Targets and accelerators') |
| 4568 | |
Philippe Mathieu-Daudé | 813803a | 2021-01-21 10:56:14 +0100 | [diff] [blame] | 4569 | # Block layer |
| 4570 | summary_info = {} |
Paolo Bonzini | 6739825 | 2022-10-12 13:19:35 +0200 | [diff] [blame] | 4571 | summary_info += {'coroutine backend': coroutine_backend} |
Paolo Bonzini | 728c0a2 | 2021-10-13 11:52:03 +0200 | [diff] [blame] | 4572 | summary_info += {'coroutine pool': have_coroutine_pool} |
Philippe Mathieu-Daudé | 813803a | 2021-01-21 10:56:14 +0100 | [diff] [blame] | 4573 | if have_block |
Paolo Bonzini | 622d64f | 2022-04-20 17:33:53 +0200 | [diff] [blame] | 4574 | summary_info += {'Block whitelist (rw)': get_option('block_drv_rw_whitelist')} |
| 4575 | summary_info += {'Block whitelist (ro)': get_option('block_drv_ro_whitelist')} |
Paolo Bonzini | c55cf6a | 2021-10-13 11:46:09 +0200 | [diff] [blame] | 4576 | summary_info += {'Use block whitelist in tools': get_option('block_drv_whitelist_in_tools')} |
Christian Schoenebeck | 3887702 | 2023-05-11 16:12:34 +0200 | [diff] [blame] | 4577 | summary_info += {'VirtFS (9P) support': have_virtfs} |
Paolo Bonzini | 406523f | 2021-10-13 11:43:54 +0200 | [diff] [blame] | 4578 | summary_info += {'replication support': config_host_data.get('CONFIG_REPLICATION')} |
Paolo Bonzini | ed793c2 | 2021-10-13 11:42:25 +0200 | [diff] [blame] | 4579 | summary_info += {'bochs support': get_option('bochs').allowed()} |
| 4580 | summary_info += {'cloop support': get_option('cloop').allowed()} |
| 4581 | summary_info += {'dmg support': get_option('dmg').allowed()} |
| 4582 | summary_info += {'qcow v1 support': get_option('qcow1').allowed()} |
| 4583 | summary_info += {'vdi support': get_option('vdi').allowed()} |
Vladimir Sementsov-Ogievskiy | 11cea42 | 2023-04-21 12:27:58 +0300 | [diff] [blame] | 4584 | summary_info += {'vhdx support': get_option('vhdx').allowed()} |
| 4585 | summary_info += {'vmdk support': get_option('vmdk').allowed()} |
| 4586 | summary_info += {'vpc support': get_option('vpc').allowed()} |
Paolo Bonzini | ed793c2 | 2021-10-13 11:42:25 +0200 | [diff] [blame] | 4587 | summary_info += {'vvfat support': get_option('vvfat').allowed()} |
| 4588 | summary_info += {'qed support': get_option('qed').allowed()} |
| 4589 | summary_info += {'parallels support': get_option('parallels').allowed()} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4590 | summary_info += {'FUSE exports': fuse} |
Xie Yongji | 2a2359b | 2022-05-23 16:46:09 +0800 | [diff] [blame] | 4591 | summary_info += {'VDUSE block exports': have_vduse_blk_export} |
Philippe Mathieu-Daudé | 813803a | 2021-01-21 10:56:14 +0100 | [diff] [blame] | 4592 | endif |
| 4593 | summary(summary_info, bool_yn: true, section: 'Block layer support') |
| 4594 | |
Philippe Mathieu-Daudé | aa58028 | 2021-01-21 10:56:15 +0100 | [diff] [blame] | 4595 | # Crypto |
Philippe Mathieu-Daudé | aa3ca63 | 2021-01-21 10:56:13 +0100 | [diff] [blame] | 4596 | summary_info = {} |
Paolo Bonzini | 41f2ae2 | 2022-04-20 17:33:52 +0200 | [diff] [blame] | 4597 | summary_info += {'TLS priority': get_option('tls_priority')} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4598 | summary_info += {'GNUTLS support': gnutls} |
| 4599 | if gnutls.found() |
| 4600 | summary_info += {' GNUTLS crypto': gnutls_crypto.found()} |
| 4601 | endif |
| 4602 | summary_info += {'libgcrypt': gcrypt} |
| 4603 | summary_info += {'nettle': nettle} |
Paolo Bonzini | 5761251 | 2021-06-03 11:15:26 +0200 | [diff] [blame] | 4604 | if nettle.found() |
| 4605 | summary_info += {' XTS': xts != 'private'} |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4606 | endif |
Hyman Huang | 52ed9f4 | 2023-12-07 23:47:35 +0800 | [diff] [blame] | 4607 | summary_info += {'SM4 ALG support': crypto_sm4} |
Paolo Bonzini | 34b5261 | 2021-11-08 14:02:42 +0100 | [diff] [blame] | 4608 | summary_info += {'AF_ALG support': have_afalg} |
Paolo Bonzini | c55cf6a | 2021-10-13 11:46:09 +0200 | [diff] [blame] | 4609 | summary_info += {'rng-none': get_option('rng_none')} |
Paolo Bonzini | 2edd2c0 | 2022-04-20 17:33:42 +0200 | [diff] [blame] | 4610 | summary_info += {'Linux keyring': have_keyring} |
Thomas Huth | c64023b | 2023-08-24 11:42:08 +0200 | [diff] [blame] | 4611 | summary_info += {'Linux keyutils': keyutils} |
Philippe Mathieu-Daudé | aa58028 | 2021-01-21 10:56:15 +0100 | [diff] [blame] | 4612 | summary(summary_info, bool_yn: true, section: 'Crypto') |
| 4613 | |
Thomas Huth | 9e48afa | 2023-06-02 19:18:30 +0200 | [diff] [blame] | 4614 | # UI |
Philippe Mathieu-Daudé | aa58028 | 2021-01-21 10:56:15 +0100 | [diff] [blame] | 4615 | summary_info = {} |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4616 | if host_os == 'darwin' |
Vladislav Yaroshchuk | e2c1d78 | 2022-03-17 20:28:33 +0300 | [diff] [blame] | 4617 | summary_info += {'Cocoa support': cocoa} |
Philippe Mathieu-Daudé | aa58028 | 2021-01-21 10:56:15 +0100 | [diff] [blame] | 4618 | endif |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4619 | summary_info += {'SDL support': sdl} |
| 4620 | summary_info += {'SDL image support': sdl_image} |
| 4621 | summary_info += {'GTK support': gtk} |
| 4622 | summary_info += {'pixman': pixman} |
| 4623 | summary_info += {'VTE support': vte} |
Kshitij Suri | 95f8510 | 2022-04-08 07:13:34 +0000 | [diff] [blame] | 4624 | summary_info += {'PNG support': png} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4625 | summary_info += {'VNC support': vnc} |
Paolo Bonzini | a0b9323 | 2020-02-06 15:48:52 +0100 | [diff] [blame] | 4626 | if vnc.found() |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4627 | summary_info += {'VNC SASL support': sasl} |
| 4628 | summary_info += {'VNC JPEG support': jpeg} |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4629 | endif |
Thomas Huth | 9e48afa | 2023-06-02 19:18:30 +0200 | [diff] [blame] | 4630 | summary_info += {'spice protocol support': spice_protocol} |
| 4631 | if spice_protocol.found() |
| 4632 | summary_info += {' spice server support': spice} |
| 4633 | endif |
| 4634 | summary_info += {'curses support': curses} |
| 4635 | summary_info += {'brlapi support': brlapi} |
| 4636 | summary(summary_info, bool_yn: true, section: 'User interface') |
| 4637 | |
Alex Bennée | f705c1f | 2023-12-22 11:48:46 +0000 | [diff] [blame] | 4638 | # Graphics backends |
| 4639 | summary_info = {} |
| 4640 | summary_info += {'VirGL support': virgl} |
| 4641 | summary_info += {'Rutabaga support': rutabaga} |
| 4642 | summary(summary_info, bool_yn: true, section: 'Graphics backends') |
| 4643 | |
Thomas Huth | aece723 | 2023-06-02 19:18:32 +0200 | [diff] [blame] | 4644 | # Audio backends |
| 4645 | summary_info = {} |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4646 | if host_os not in ['darwin', 'haiku', 'windows'] |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 4647 | summary_info += {'OSS support': oss} |
Alexandre Ratchov | 663df1c | 2022-09-07 15:23:42 +0200 | [diff] [blame] | 4648 | summary_info += {'sndio support': sndio} |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4649 | elif host_os == 'darwin' |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 4650 | summary_info += {'CoreAudio support': coreaudio} |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4651 | elif host_os == 'windows' |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 4652 | summary_info += {'DirectSound support': dsound} |
| 4653 | endif |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4654 | if host_os == 'linux' |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 4655 | summary_info += {'ALSA support': alsa} |
| 4656 | summary_info += {'PulseAudio support': pulse} |
| 4657 | endif |
Marc-André Lureau | 20c5124 | 2023-05-06 20:37:26 +0400 | [diff] [blame] | 4658 | summary_info += {'PipeWire support': pipewire} |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 4659 | summary_info += {'JACK support': jack} |
Thomas Huth | aece723 | 2023-06-02 19:18:32 +0200 | [diff] [blame] | 4660 | summary(summary_info, bool_yn: true, section: 'Audio backends') |
| 4661 | |
Thomas Huth | c3527c5 | 2023-06-02 19:18:31 +0200 | [diff] [blame] | 4662 | # Network backends |
Thomas Huth | 9e48afa | 2023-06-02 19:18:30 +0200 | [diff] [blame] | 4663 | summary_info = {} |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4664 | if host_os == 'darwin' |
Thomas Huth | 9e48afa | 2023-06-02 19:18:30 +0200 | [diff] [blame] | 4665 | summary_info += {'vmnet.framework support': vmnet} |
| 4666 | endif |
Ilya Maximets | cb039ef | 2023-09-13 20:34:37 +0200 | [diff] [blame] | 4667 | summary_info += {'AF_XDP support': libxdp} |
Thomas Huth | 9e48afa | 2023-06-02 19:18:30 +0200 | [diff] [blame] | 4668 | summary_info += {'slirp support': slirp} |
Paolo Bonzini | e172399 | 2021-10-07 15:08:21 +0200 | [diff] [blame] | 4669 | summary_info += {'vde support': vde} |
Paolo Bonzini | 837b84b | 2021-10-07 15:08:22 +0200 | [diff] [blame] | 4670 | summary_info += {'netmap support': have_netmap} |
Thomas Huth | eea9453 | 2021-10-28 20:59:08 +0200 | [diff] [blame] | 4671 | summary_info += {'l2tpv3 support': have_l2tpv3} |
Thomas Huth | c3527c5 | 2023-06-02 19:18:31 +0200 | [diff] [blame] | 4672 | summary(summary_info, bool_yn: true, section: 'Network backends') |
| 4673 | |
| 4674 | # Libraries |
| 4675 | summary_info = {} |
Thomas Huth | 9e48afa | 2023-06-02 19:18:30 +0200 | [diff] [blame] | 4676 | summary_info += {'libtasn1': tasn1} |
| 4677 | summary_info += {'PAM': pam} |
| 4678 | summary_info += {'iconv support': iconv} |
Thomas Huth | 9e48afa | 2023-06-02 19:18:30 +0200 | [diff] [blame] | 4679 | summary_info += {'blkio support': blkio} |
| 4680 | summary_info += {'curl support': curl} |
| 4681 | summary_info += {'Multipath support': mpathpersist} |
Paolo Bonzini | ff66f3e | 2021-10-07 15:08:20 +0200 | [diff] [blame] | 4682 | summary_info += {'Linux AIO support': libaio} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4683 | summary_info += {'Linux io_uring support': linux_io_uring} |
| 4684 | summary_info += {'ATTR/XATTR support': libattr} |
Paolo Bonzini | 3730a73 | 2022-04-20 17:33:41 +0200 | [diff] [blame] | 4685 | summary_info += {'RDMA support': rdma} |
Paolo Bonzini | 7a6f334 | 2024-01-25 12:22:57 +0100 | [diff] [blame] | 4686 | summary_info += {'fdt support': fdt_opt == 'internal' ? 'internal' : fdt} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4687 | summary_info += {'libcap-ng support': libcap_ng} |
| 4688 | summary_info += {'bpf support': libbpf} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4689 | summary_info += {'rbd support': rbd} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4690 | summary_info += {'smartcard support': cacard} |
| 4691 | summary_info += {'U2F support': u2f} |
| 4692 | summary_info += {'libusb': libusb} |
| 4693 | summary_info += {'usb net redir': usbredir} |
Paolo Bonzini | 88b6e61 | 2022-04-20 17:33:40 +0200 | [diff] [blame] | 4694 | summary_info += {'OpenGL support (epoxy)': opengl} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4695 | summary_info += {'GBM': gbm} |
| 4696 | summary_info += {'libiscsi support': libiscsi} |
| 4697 | summary_info += {'libnfs support': libnfs} |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4698 | if host_os == 'windows' |
Paolo Bonzini | 20cf5cb | 2021-10-15 16:47:43 +0200 | [diff] [blame] | 4699 | if have_ga |
Marc-André Lureau | 8821a38 | 2022-02-01 16:53:43 +0400 | [diff] [blame] | 4700 | summary_info += {'QGA VSS support': have_qga_vss} |
Paolo Bonzini | b846ab7 | 2021-01-21 11:49:04 +0100 | [diff] [blame] | 4701 | endif |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4702 | endif |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4703 | summary_info += {'seccomp support': seccomp} |
| 4704 | summary_info += {'GlusterFS support': glusterfs} |
Maciej S. Szmigiero | 0d9e8c0 | 2023-06-12 16:00:54 +0200 | [diff] [blame] | 4705 | summary_info += {'hv-balloon support': hv_balloon} |
Paolo Bonzini | 0d04c4c | 2021-12-21 12:38:27 +0100 | [diff] [blame] | 4706 | summary_info += {'TPM support': have_tpm} |
Thomas Huth | e6a52b3 | 2021-12-09 15:48:01 +0100 | [diff] [blame] | 4707 | summary_info += {'libssh support': libssh} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4708 | summary_info += {'lzo support': lzo} |
| 4709 | summary_info += {'snappy support': snappy} |
| 4710 | summary_info += {'bzip2 support': libbzip2} |
| 4711 | summary_info += {'lzfse support': liblzfse} |
| 4712 | summary_info += {'zstd support': zstd} |
Yuan Liu | b844a2c | 2024-06-10 18:21:06 +0800 | [diff] [blame] | 4713 | summary_info += {'Query Processing Library support': qpl} |
Shameer Kolothum | cfc589a | 2024-06-07 14:53:05 +0100 | [diff] [blame] | 4714 | summary_info += {'UADK Library support': uadk} |
Bryan Zhang | e28ed31 | 2024-08-30 16:27:19 -0700 | [diff] [blame] | 4715 | summary_info += {'qatzip support': qatzip} |
Paolo Bonzini | 488a8c7 | 2021-12-21 12:38:27 +0100 | [diff] [blame] | 4716 | summary_info += {'NUMA host support': numa} |
Thomas Huth | 8360208 | 2022-05-16 16:58:23 +0200 | [diff] [blame] | 4717 | summary_info += {'capstone': capstone} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4718 | summary_info += {'libpmem support': libpmem} |
| 4719 | summary_info += {'libdaxctl support': libdaxctl} |
Dorjoy Chowdhury | bb154e3 | 2024-10-09 03:17:23 +0600 | [diff] [blame] | 4720 | summary_info += {'libcbor support': libcbor} |
Paolo Bonzini | bb647c4 | 2021-06-03 11:24:56 +0200 | [diff] [blame] | 4721 | summary_info += {'libudev': libudev} |
| 4722 | # Dummy dependency, keep .found() |
Max Reitz | df4ea70 | 2020-10-27 20:05:46 +0100 | [diff] [blame] | 4723 | summary_info += {'FUSE lseek': fuse_lseek.found()} |
Richard W.M. Jones | 3d212b4 | 2021-11-15 14:29:43 -0600 | [diff] [blame] | 4724 | summary_info += {'selinux': selinux} |
Ilya Leoshkevich | 7c10cb3 | 2023-01-12 16:20:12 +0100 | [diff] [blame] | 4725 | summary_info += {'libdw': libdw} |
Ilya Leoshkevich | a1a9800 | 2024-02-06 01:22:03 +0100 | [diff] [blame] | 4726 | if host_os == 'freebsd' |
| 4727 | summary_info += {'libinotify-kqueue': inotify} |
| 4728 | endif |
Philippe Mathieu-Daudé | 69a78cc | 2021-01-21 10:56:16 +0100 | [diff] [blame] | 4729 | summary(summary_info, bool_yn: true, section: 'Dependencies') |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4730 | |
Paolo Bonzini | a24f15d | 2023-08-04 11:29:05 +0200 | [diff] [blame] | 4731 | if host_arch == 'unknown' |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4732 | message() |
Paolo Bonzini | a24f15d | 2023-08-04 11:29:05 +0200 | [diff] [blame] | 4733 | warning('UNSUPPORTED HOST CPU') |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4734 | message() |
Paolo Bonzini | a24f15d | 2023-08-04 11:29:05 +0200 | [diff] [blame] | 4735 | message('Support for CPU host architecture ' + cpu + ' is not currently') |
| 4736 | message('maintained. The QEMU project does not guarantee that QEMU will') |
| 4737 | message('compile or work on this host CPU. You can help by volunteering') |
| 4738 | message('to maintain it and providing a build host for our continuous') |
| 4739 | message('integration setup.') |
| 4740 | if get_option('tcg').allowed() and target_dirs.length() > 0 |
| 4741 | message() |
| 4742 | message('configure has succeeded and you can continue to build, but') |
| 4743 | message('QEMU will use a slow interpreter to emulate the target CPU.') |
| 4744 | endif |
Paolo Bonzini | 14ed29d | 2024-10-27 14:07:01 +0100 | [diff] [blame] | 4745 | elif host_arch == 'mips' |
| 4746 | message() |
| 4747 | warning('DEPRECATED HOST CPU') |
| 4748 | message() |
| 4749 | message('Support for CPU host architecture ' + cpu + ' is going to be') |
| 4750 | message('dropped as soon as the QEMU project stops supporting Debian 12') |
| 4751 | message('("Bookworm"). Going forward, the QEMU project will not guarantee') |
| 4752 | message('that QEMU will compile or work on this host CPU.') |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4753 | endif |
| 4754 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4755 | if not supported_oses.contains(host_os) |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4756 | message() |
Paolo Bonzini | a24f15d | 2023-08-04 11:29:05 +0200 | [diff] [blame] | 4757 | warning('UNSUPPORTED HOST OS') |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4758 | message() |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4759 | message('Support for host OS ' + host_os + 'is not currently maintained.') |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4760 | message('configure has succeeded and you can continue to build, but') |
Paolo Bonzini | a24f15d | 2023-08-04 11:29:05 +0200 | [diff] [blame] | 4761 | message('the QEMU project does not guarantee that QEMU will compile or') |
| 4762 | message('work on this operating system. You can help by volunteering') |
| 4763 | message('to maintain it and providing a build host for our continuous') |
| 4764 | message('integration setup. This will ensure that future versions of QEMU') |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4765 | message('will keep working on ' + host_os + '.') |
Paolo Bonzini | a24f15d | 2023-08-04 11:29:05 +0200 | [diff] [blame] | 4766 | endif |
| 4767 | |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4768 | if host_arch == 'unknown' or not supported_oses.contains(host_os) |
Paolo Bonzini | a24f15d | 2023-08-04 11:29:05 +0200 | [diff] [blame] | 4769 | message() |
| 4770 | message('If you want to help supporting QEMU on this platform, please') |
| 4771 | message('contact the developers at qemu-devel@nongnu.org.') |
Paolo Bonzini | f933275 | 2020-02-03 13:28:38 +0100 | [diff] [blame] | 4772 | endif |
Paolo Bonzini | 655e2a7 | 2023-10-05 14:19:34 +0200 | [diff] [blame] | 4773 | |
| 4774 | actually_reloc = get_option('relocatable') |
| 4775 | # check if get_relocated_path() is actually able to relocate paths |
| 4776 | if get_option('relocatable') and \ |
| 4777 | not (get_option('prefix') / get_option('bindir')).startswith(get_option('prefix') / '') |
| 4778 | message() |
| 4779 | warning('bindir not included within prefix, the installation will not be relocatable.') |
| 4780 | actually_reloc = false |
| 4781 | endif |
Paolo Bonzini | d0cda6f | 2023-11-03 09:17:48 +0100 | [diff] [blame] | 4782 | if not actually_reloc and (host_os == 'windows' or get_option('relocatable')) |
| 4783 | if host_os == 'windows' |
Paolo Bonzini | 655e2a7 | 2023-10-05 14:19:34 +0200 | [diff] [blame] | 4784 | message() |
| 4785 | warning('Windows installs should usually be relocatable.') |
| 4786 | endif |
| 4787 | message() |
| 4788 | message('QEMU will have to be installed under ' + get_option('prefix') + '.') |
| 4789 | message('Use --disable-relocatable to remove this warning.') |
| 4790 | endif |