1project('qemu', ['c'], meson_version: '>=1.1.0', 2 default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto', 3 'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true'], 4 version: files('VERSION')) 5 6add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true) 7add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow']) 8add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough']) 9 10meson.add_postconf_script(find_program('scripts/symlink-install-tree.py')) 11 12#################### 13# Global variables # 14#################### 15 16not_found = dependency('', required: false) 17keyval = import('keyval') 18ss = import('sourceset') 19fs = import('fs') 20 21host_os = host_machine.system() 22config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') 23 24# Temporary directory used for files created while 25# configure runs. Since it is in the build directory 26# we can safely blow away any previous version of it 27# (and we need not jump through hoops to try to delete 28# it when configure exits.) 29tmpdir = meson.current_build_dir() / 'meson-private/temp' 30 31if get_option('qemu_suffix').startswith('/') 32 error('qemu_suffix cannot start with a /') 33endif 34 35qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix') 36qemu_datadir = get_option('datadir') / get_option('qemu_suffix') 37qemu_docdir = get_option('docdir') / get_option('qemu_suffix') 38qemu_moddir = get_option('libdir') / get_option('qemu_suffix') 39 40qemu_desktopdir = get_option('datadir') / 'applications' 41qemu_icondir = get_option('datadir') / 'icons' 42 43genh = [] 44qapi_trace_events = [] 45 46bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin'] 47supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux'] 48supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64', 49 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64'] 50 51cpu = host_machine.cpu_family() 52 53target_dirs = config_host['TARGET_DIRS'].split() 54 55############ 56# Programs # 57############ 58 59sh = find_program('sh') 60python = import('python').find_installation() 61 62cc = meson.get_compiler('c') 63all_languages = ['c'] 64if host_os == 'windows' and add_languages('cpp', required: false, native: false) 65 all_languages += ['cpp'] 66 cxx = meson.get_compiler('cpp') 67endif 68if host_os == 'darwin' and \ 69 add_languages('objc', required: true, native: false) 70 all_languages += ['objc'] 71 objc = meson.get_compiler('objc') 72endif 73 74dtrace = not_found 75stap = not_found 76if 'dtrace' in get_option('trace_backends') 77 dtrace = find_program('dtrace', required: true) 78 stap = find_program('stap', required: false) 79 if stap.found() 80 # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol 81 # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility 82 # instead. QEMU --enable-modules depends on this because the SystemTap 83 # semaphores are linked into the main binary and not the module's shared 84 # object. 85 add_global_arguments('-DSTAP_SDT_V2', 86 native: false, language: all_languages) 87 endif 88endif 89 90if get_option('iasl') == '' 91 iasl = find_program('iasl', required: false) 92else 93 iasl = find_program(get_option('iasl'), required: true) 94endif 95 96edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu', 'riscv64-softmmu' ] 97unpack_edk2_blobs = false 98foreach target : edk2_targets 99 if target in target_dirs 100 bzip2 = find_program('bzip2', required: get_option('install_blobs')) 101 unpack_edk2_blobs = bzip2.found() 102 break 103 endif 104endforeach 105 106##################### 107# Option validation # 108##################### 109 110# Fuzzing 111if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \ 112 not cc.links(''' 113 #include <stdint.h> 114 #include <sys/types.h> 115 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); 116 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; } 117 ''', 118 args: ['-Werror', '-fsanitize=fuzzer']) 119 error('Your compiler does not support -fsanitize=fuzzer') 120endif 121 122# Tracing backends 123if 'ftrace' in get_option('trace_backends') and host_os != 'linux' 124 error('ftrace is supported only on Linux') 125endif 126if 'syslog' in get_option('trace_backends') and not cc.compiles(''' 127 #include <syslog.h> 128 int main(void) { 129 openlog("qemu", LOG_PID, LOG_DAEMON); 130 syslog(LOG_INFO, "configure"); 131 return 0; 132 }''') 133 error('syslog is not supported on this system') 134endif 135 136# Miscellaneous Linux-only features 137get_option('mpath') \ 138 .require(host_os == 'linux', error_message: 'Multipath is supported only on Linux') 139 140multiprocess_allowed = get_option('multiprocess') \ 141 .require(host_os == 'linux', error_message: 'Multiprocess QEMU is supported only on Linux') \ 142 .allowed() 143 144vfio_user_server_allowed = get_option('vfio_user_server') \ 145 .require(host_os == 'linux', error_message: 'vfio-user server is supported only on Linux') \ 146 .allowed() 147 148have_tpm = get_option('tpm') \ 149 .require(host_os != 'windows', error_message: 'TPM emulation only available on POSIX systems') \ 150 .allowed() 151 152# vhost 153have_vhost_user = get_option('vhost_user') \ 154 .disable_auto_if(host_os != 'linux') \ 155 .require(host_os != 'windows', 156 error_message: 'vhost-user is not available on Windows').allowed() 157have_vhost_vdpa = get_option('vhost_vdpa') \ 158 .require(host_os == 'linux', 159 error_message: 'vhost-vdpa is only available on Linux').allowed() 160have_vhost_kernel = get_option('vhost_kernel') \ 161 .require(host_os == 'linux', 162 error_message: 'vhost-kernel is only available on Linux').allowed() 163have_vhost_user_crypto = get_option('vhost_crypto') \ 164 .require(have_vhost_user, 165 error_message: 'vhost-crypto requires vhost-user to be enabled').allowed() 166 167have_vhost = have_vhost_user or have_vhost_vdpa or have_vhost_kernel 168 169have_vhost_net_user = have_vhost_user and get_option('vhost_net').allowed() 170have_vhost_net_vdpa = have_vhost_vdpa and get_option('vhost_net').allowed() 171have_vhost_net_kernel = have_vhost_kernel and get_option('vhost_net').allowed() 172have_vhost_net = have_vhost_net_kernel or have_vhost_net_user or have_vhost_net_vdpa 173 174# type of binaries to build 175have_linux_user = false 176have_bsd_user = false 177have_system = false 178foreach target : target_dirs 179 have_linux_user = have_linux_user or target.endswith('linux-user') 180 have_bsd_user = have_bsd_user or target.endswith('bsd-user') 181 have_system = have_system or target.endswith('-softmmu') 182endforeach 183have_user = have_linux_user or have_bsd_user 184 185have_tools = get_option('tools') \ 186 .disable_auto_if(not have_system) \ 187 .allowed() 188have_ga = get_option('guest_agent') \ 189 .disable_auto_if(not have_system and not have_tools) \ 190 .require(host_os in ['sunos', 'linux', 'windows', 'freebsd', 'netbsd', 'openbsd'], 191 error_message: 'unsupported OS for QEMU guest agent') \ 192 .allowed() 193have_block = have_system or have_tools 194 195enable_modules = get_option('modules') \ 196 .require(host_os != 'windows', 197 error_message: 'Modules are not available for Windows') \ 198 .require(not get_option('prefer_static'), 199 error_message: 'Modules are incompatible with static linking') \ 200 .allowed() 201 202####################################### 203# Variables for host and accelerators # 204####################################### 205 206if cpu not in supported_cpus 207 host_arch = 'unknown' 208elif cpu == 'x86' 209 host_arch = 'i386' 210elif cpu == 'mips64' 211 host_arch = 'mips' 212elif cpu in ['riscv32', 'riscv64'] 213 host_arch = 'riscv' 214else 215 host_arch = cpu 216endif 217 218if cpu in ['x86', 'x86_64'] 219 kvm_targets = ['i386-softmmu', 'x86_64-softmmu'] 220elif cpu == 'aarch64' 221 kvm_targets = ['aarch64-softmmu'] 222elif cpu == 's390x' 223 kvm_targets = ['s390x-softmmu'] 224elif cpu in ['ppc', 'ppc64'] 225 kvm_targets = ['ppc-softmmu', 'ppc64-softmmu'] 226elif cpu in ['mips', 'mips64'] 227 kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu'] 228elif cpu in ['riscv32'] 229 kvm_targets = ['riscv32-softmmu'] 230elif cpu in ['riscv64'] 231 kvm_targets = ['riscv64-softmmu'] 232elif cpu in ['loongarch64'] 233 kvm_targets = ['loongarch64-softmmu'] 234else 235 kvm_targets = [] 236endif 237accelerator_targets = { 'CONFIG_KVM': kvm_targets } 238 239if cpu in ['x86', 'x86_64'] 240 xen_targets = ['i386-softmmu', 'x86_64-softmmu'] 241elif cpu in ['arm', 'aarch64'] 242 # i386 emulator provides xenpv machine type for multiple architectures 243 xen_targets = ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu'] 244else 245 xen_targets = [] 246endif 247accelerator_targets += { 'CONFIG_XEN': xen_targets } 248 249if cpu in ['aarch64'] 250 accelerator_targets += { 251 'CONFIG_HVF': ['aarch64-softmmu'] 252 } 253endif 254 255if cpu in ['x86', 'x86_64'] 256 accelerator_targets += { 257 'CONFIG_HVF': ['x86_64-softmmu'], 258 'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'], 259 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'], 260 } 261endif 262 263modular_tcg = [] 264# Darwin does not support references to thread-local variables in modules 265if host_os != 'darwin' 266 modular_tcg = ['i386-softmmu', 'x86_64-softmmu'] 267endif 268 269################## 270# Compiler flags # 271################## 272 273foreach lang : all_languages 274 compiler = meson.get_compiler(lang) 275 if compiler.get_id() == 'gcc' and compiler.version().version_compare('>=7.4') 276 # ok 277 elif compiler.get_id() == 'clang' and compiler.compiles(''' 278 #ifdef __apple_build_version__ 279 # if __clang_major__ < 12 || (__clang_major__ == 12 && __clang_minor__ < 0) 280 # error You need at least XCode Clang v12.0 to compile QEMU 281 # endif 282 #else 283 # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 284 # error You need at least Clang v10.0 to compile QEMU 285 # endif 286 #endif''') 287 # ok 288 else 289 error('You either need GCC v7.4 or Clang v10.0 (or XCode Clang v12.0) to compile QEMU') 290 endif 291endforeach 292 293# default flags for all hosts 294# We use -fwrapv to tell the compiler that we require a C dialect where 295# left shift of signed integers is well defined and has the expected 296# 2s-complement style results. (Both clang and gcc agree that it 297# provides these semantics.) 298 299qemu_common_flags = [ 300 '-D_GNU_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', 301 '-fno-strict-aliasing', '-fno-common', '-fwrapv' ] 302qemu_cflags = [] 303qemu_ldflags = [] 304 305if host_os == 'darwin' 306 # Disable attempts to use ObjectiveC features in os/object.h since they 307 # won't work when we're compiling with gcc as a C compiler. 308 if compiler.get_id() == 'gcc' 309 qemu_common_flags += '-DOS_OBJECT_USE_OBJC=0' 310 endif 311elif host_os == 'sunos' 312 # needed for CMSG_ macros in sys/socket.h 313 qemu_common_flags += '-D_XOPEN_SOURCE=600' 314 # needed for TIOCWIN* defines in termios.h 315 qemu_common_flags += '-D__EXTENSIONS__' 316elif host_os == 'haiku' 317 qemu_common_flags += ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE', '-fPIC'] 318elif host_os == 'windows' 319 if not compiler.compiles('struct x { int y; } __attribute__((gcc_struct));', 320 args: '-Werror') 321 error('Your compiler does not support __attribute__((gcc_struct)) - please use GCC instead of Clang') 322 endif 323endif 324 325# Choose instruction set (currently x86-only) 326 327qemu_isa_flags = [] 328 329# __sync_fetch_and_and requires at least -march=i486. Many toolchains 330# use i686 as default anyway, but for those that don't, an explicit 331# specification is necessary 332if host_arch == 'i386' and not cc.links(''' 333 static int sfaa(int *ptr) 334 { 335 return __sync_fetch_and_and(ptr, 0); 336 } 337 338 int main(void) 339 { 340 int val = 42; 341 val = __sync_val_compare_and_swap(&val, 0, 1); 342 sfaa(&val); 343 return val; 344 }''') 345 qemu_isa_flags += ['-march=i486'] 346endif 347 348# Pick x86-64 baseline version 349if host_arch in ['i386', 'x86_64'] 350 if get_option('x86_version') == '0' and host_arch == 'x86_64' 351 error('x86_64-v1 required for x86-64 hosts') 352 endif 353 354 # add flags for individual instruction set extensions 355 if get_option('x86_version') >= '1' 356 if host_arch == 'i386' 357 qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags 358 else 359 # present on basically all processors but technically not part of 360 # x86-64-v1, so only include -mneeded for x86-64 version 2 and above 361 qemu_isa_flags += ['-mcx16'] 362 endif 363 endif 364 if get_option('x86_version') >= '2' 365 qemu_isa_flags += ['-mpopcnt'] 366 qemu_isa_flags += cc.get_supported_arguments('-mneeded') 367 endif 368 if get_option('x86_version') >= '3' 369 qemu_isa_flags += ['-mmovbe', '-mabm', '-mbmi', '-mbmi2', '-mfma', '-mf16c'] 370 endif 371 372 # add required vector instruction set (each level implies those below) 373 if get_option('x86_version') == '1' 374 qemu_isa_flags += ['-msse2'] 375 elif get_option('x86_version') == '2' 376 qemu_isa_flags += ['-msse4.2'] 377 elif get_option('x86_version') == '3' 378 qemu_isa_flags += ['-mavx2'] 379 elif get_option('x86_version') == '4' 380 qemu_isa_flags += ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl'] 381 endif 382endif 383 384qemu_common_flags = qemu_isa_flags + qemu_common_flags 385 386if get_option('prefer_static') 387 qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static' 388endif 389 390# Meson currently only handles pie as a boolean for now, so if the user 391# has explicitly disabled PIE we need to extend our cflags. 392# 393# -no-pie is supposedly a linker flag that has no effect on the compiler 394# command line, but some distros, that didn't quite know what they were 395# doing, made local changes to gcc's specs file that turned it into 396# a compiler command-line flag. 397# 398# What about linker flags? For a static build, no PIE is implied by -static 399# which we added above (and if it's not because of the same specs patching, 400# there's nothing we can do: compilation will fail, report a bug to your 401# distro and do not use --disable-pie in the meanwhile). For dynamic linking, 402# instead, we can't add -no-pie because it overrides -shared: the linker then 403# tries to build an executable instead of a shared library and fails. So 404# don't add -no-pie anywhere and cross fingers. :( 405if not get_option('b_pie') 406 qemu_common_flags += cc.get_supported_arguments('-fno-pie', '-no-pie') 407endif 408 409if not get_option('stack_protector').disabled() 410 stack_protector_probe = ''' 411 int main(int argc, char *argv[]) 412 { 413 char arr[64], *p = arr, *c = argv[argc - 1]; 414 while (*c) { 415 *p++ = *c++; 416 } 417 return 0; 418 }''' 419 have_stack_protector = false 420 foreach arg : ['-fstack-protector-strong', '-fstack-protector-all'] 421 # We need to check both a compile and a link, since some compiler 422 # setups fail only on a .c->.o compile and some only at link time 423 if cc.compiles(stack_protector_probe, args: ['-Werror', arg]) and \ 424 cc.links(stack_protector_probe, args: ['-Werror', arg]) 425 have_stack_protector = true 426 qemu_cflags += arg 427 qemu_ldflags += arg 428 break 429 endif 430 endforeach 431 get_option('stack_protector') \ 432 .require(have_stack_protector, error_message: 'Stack protector not supported') 433endif 434 435coroutine_backend = get_option('coroutine_backend') 436ucontext_probe = ''' 437 #include <ucontext.h> 438 #ifdef __stub_makecontext 439 #error Ignoring glibc stub makecontext which will always fail 440 #endif 441 int main(void) { makecontext(0, 0, 0); return 0; }''' 442 443# On Windows the only valid backend is the Windows specific one. 444# For POSIX prefer ucontext, but it's not always possible. The fallback 445# is sigcontext. 446supported_backends = [] 447if host_os == 'windows' 448 supported_backends += ['windows'] 449else 450 if host_os != 'darwin' and cc.links(ucontext_probe) 451 supported_backends += ['ucontext'] 452 endif 453 supported_backends += ['sigaltstack'] 454endif 455 456if coroutine_backend == 'auto' 457 coroutine_backend = supported_backends[0] 458elif coroutine_backend not in supported_backends 459 error('"@0@" backend requested but not available. Available backends: @1@' \ 460 .format(coroutine_backend, ', '.join(supported_backends))) 461endif 462 463# Compiles if SafeStack *not* enabled 464safe_stack_probe = ''' 465 int main(void) 466 { 467 #if defined(__has_feature) 468 #if __has_feature(safe_stack) 469 #error SafeStack Enabled 470 #endif 471 #endif 472 return 0; 473 }''' 474if get_option('safe_stack') != not cc.compiles(safe_stack_probe) 475 safe_stack_arg = get_option('safe_stack') ? '-fsanitize=safe-stack' : '-fno-sanitize=safe-stack' 476 if get_option('safe_stack') != not cc.compiles(safe_stack_probe, args: safe_stack_arg) 477 error(get_option('safe_stack') \ 478 ? 'SafeStack not supported by your compiler' \ 479 : 'Cannot disable SafeStack') 480 endif 481 qemu_cflags += safe_stack_arg 482 qemu_ldflags += safe_stack_arg 483endif 484if get_option('safe_stack') and coroutine_backend != 'ucontext' 485 error('SafeStack is only supported with the ucontext coroutine backend') 486endif 487 488if get_option('sanitizers') 489 if cc.has_argument('-fsanitize=address') 490 qemu_cflags = ['-fsanitize=address'] + qemu_cflags 491 qemu_ldflags = ['-fsanitize=address'] + qemu_ldflags 492 endif 493 494 # Detect static linking issue with ubsan - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 495 if cc.links('int main(int argc, char **argv) { return argc + 1; }', 496 args: [qemu_ldflags, '-fsanitize=undefined']) 497 qemu_cflags = ['-fsanitize=undefined'] + qemu_cflags 498 qemu_ldflags = ['-fsanitize=undefined'] + qemu_ldflags 499 endif 500endif 501 502# Thread sanitizer is, for now, much noisier than the other sanitizers; 503# keep it separate until that is not the case. 504if get_option('tsan') 505 if get_option('sanitizers') 506 error('TSAN is not supported with other sanitizers') 507 endif 508 if not cc.has_function('__tsan_create_fiber', 509 args: '-fsanitize=thread', 510 prefix: '#include <sanitizer/tsan_interface.h>') 511 error('Cannot enable TSAN due to missing fiber annotation interface') 512 endif 513 qemu_cflags = ['-fsanitize=thread'] + qemu_cflags 514 qemu_ldflags = ['-fsanitize=thread'] + qemu_ldflags 515endif 516 517# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 518# The combination is known as "full relro", because .got.plt is read-only too. 519qemu_ldflags += cc.get_supported_link_arguments('-Wl,-z,relro', '-Wl,-z,now') 520 521if host_os == 'windows' 522 qemu_ldflags += cc.get_supported_link_arguments('-Wl,--no-seh', '-Wl,--nxcompat') 523 qemu_ldflags += cc.get_supported_link_arguments('-Wl,--dynamicbase', '-Wl,--high-entropy-va') 524endif 525 526if get_option('fuzzing') 527 # Specify a filter to only instrument code that is directly related to 528 # virtual-devices. 529 configure_file(output: 'instrumentation-filter', 530 input: 'scripts/oss-fuzz/instrumentation-filter-template', 531 copy: true) 532 533 if cc.compiles('int main () { return 0; }', 534 name: '-fsanitize-coverage-allowlist=/dev/null', 535 args: ['-fsanitize-coverage-allowlist=/dev/null', 536 '-fsanitize-coverage=trace-pc'] ) 537 qemu_common_flags += ['-fsanitize-coverage-allowlist=instrumentation-filter'] 538 endif 539 540 if get_option('fuzzing_engine') == '' 541 # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the 542 # compiled code. To build non-fuzzer binaries with --enable-fuzzing, link 543 # everything with fsanitize=fuzzer-no-link. Otherwise, the linker will be 544 # unable to bind the fuzzer-related callbacks added by instrumentation. 545 qemu_common_flags += ['-fsanitize=fuzzer-no-link'] 546 qemu_ldflags += ['-fsanitize=fuzzer-no-link'] 547 # For the actual fuzzer binaries, we need to link against the libfuzzer 548 # library. They need to be configurable, to support OSS-Fuzz 549 fuzz_exe_ldflags = ['-fsanitize=fuzzer'] 550 else 551 # LIB_FUZZING_ENGINE was set; assume we are running on OSS-Fuzz, and 552 # the needed CFLAGS have already been provided 553 fuzz_exe_ldflags = get_option('fuzzing_engine').split() 554 endif 555endif 556 557if get_option('cfi') 558 cfi_flags=[] 559 # Check for dependency on LTO 560 if not get_option('b_lto') 561 error('Selected Control-Flow Integrity but LTO is disabled') 562 endif 563 if enable_modules 564 error('Selected Control-Flow Integrity is not compatible with modules') 565 endif 566 # Check for cfi flags. CFI requires LTO so we can't use 567 # get_supported_arguments, but need a more complex "compiles" which allows 568 # custom arguments 569 if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall', 570 args: ['-flto', '-fsanitize=cfi-icall'] ) 571 cfi_flags += '-fsanitize=cfi-icall' 572 else 573 error('-fsanitize=cfi-icall is not supported by the compiler') 574 endif 575 if cc.compiles('int main () { return 0; }', 576 name: '-fsanitize-cfi-icall-generalize-pointers', 577 args: ['-flto', '-fsanitize=cfi-icall', 578 '-fsanitize-cfi-icall-generalize-pointers'] ) 579 cfi_flags += '-fsanitize-cfi-icall-generalize-pointers' 580 else 581 error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler') 582 endif 583 if get_option('cfi_debug') 584 if cc.compiles('int main () { return 0; }', 585 name: '-fno-sanitize-trap=cfi-icall', 586 args: ['-flto', '-fsanitize=cfi-icall', 587 '-fno-sanitize-trap=cfi-icall'] ) 588 cfi_flags += '-fno-sanitize-trap=cfi-icall' 589 else 590 error('-fno-sanitize-trap=cfi-icall is not supported by the compiler') 591 endif 592 endif 593 add_global_arguments(cfi_flags, native: false, language: all_languages) 594 add_global_link_arguments(cfi_flags, native: false, language: all_languages) 595endif 596 597# Check further flags that make QEMU more robust against malicious parties 598 599hardening_flags = [ 600 # Initialize all stack variables to zero. This makes 601 # it harder to take advantage of uninitialized stack 602 # data to drive exploits 603 '-ftrivial-auto-var-init=zero', 604] 605 606# Zero out registers used during a function call 607# upon its return. This makes it harder to assemble 608# ROP gadgets into something usable 609# 610# NB: Clang 17 is broken and SEGVs 611# https://github.com/llvm/llvm-project/issues/75168 612# 613# NB2: This clashes with the "retguard" extension of OpenBSD's Clang 614# https://gitlab.com/qemu-project/qemu/-/issues/2278 615if host_os != 'openbsd' and \ 616 cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }', 617 name: '-fzero-call-used-regs=used-gpr', 618 args: ['-O2', '-fzero-call-used-regs=used-gpr']) 619 hardening_flags += '-fzero-call-used-regs=used-gpr' 620endif 621 622qemu_common_flags += cc.get_supported_arguments(hardening_flags) 623 624add_global_arguments(qemu_common_flags, native: false, language: all_languages) 625add_global_link_arguments(qemu_ldflags, native: false, language: all_languages) 626 627# Collect warning flags we want to set, sorted alphabetically 628warn_flags = [ 629 # First enable interesting warnings 630 '-Wempty-body', 631 '-Wendif-labels', 632 '-Wexpansion-to-defined', 633 '-Wformat-security', 634 '-Wformat-y2k', 635 '-Wignored-qualifiers', 636 '-Wimplicit-fallthrough=2', 637 '-Winit-self', 638 '-Wmissing-format-attribute', 639 '-Wmissing-prototypes', 640 '-Wnested-externs', 641 '-Wold-style-declaration', 642 '-Wold-style-definition', 643 '-Wredundant-decls', 644 '-Wshadow=local', 645 '-Wstrict-prototypes', 646 '-Wtype-limits', 647 '-Wundef', 648 '-Wvla', 649 '-Wwrite-strings', 650 651 # Then disable some undesirable warnings 652 '-Wno-gnu-variable-sized-type-not-at-end', 653 '-Wno-initializer-overrides', 654 '-Wno-missing-include-dirs', 655 '-Wno-psabi', 656 '-Wno-shift-negative-value', 657 '-Wno-string-plus-int', 658 '-Wno-tautological-type-limit-compare', 659 '-Wno-typedef-redefinition', 660] 661 662if host_os != 'darwin' 663 tsa_has_cleanup = cc.compiles(''' 664 struct __attribute__((capability("mutex"))) mutex {}; 665 void lock(struct mutex *m) __attribute__((acquire_capability(m))); 666 void unlock(struct mutex *m) __attribute__((release_capability(m))); 667 668 void test(void) { 669 struct mutex __attribute__((cleanup(unlock))) m; 670 lock(&m); 671 } 672 ''', args: ['-Wthread-safety', '-Werror']) 673 if tsa_has_cleanup 674 warn_flags += ['-Wthread-safety'] 675 endif 676endif 677 678# Set up C++ compiler flags 679qemu_cxxflags = [] 680if 'cpp' in all_languages 681 qemu_cxxflags = ['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'] + qemu_cflags 682endif 683 684add_project_arguments(qemu_cflags, native: false, language: 'c') 685add_project_arguments(cc.get_supported_arguments(warn_flags), native: false, language: 'c') 686if 'cpp' in all_languages 687 add_project_arguments(qemu_cxxflags, native: false, language: 'cpp') 688 add_project_arguments(cxx.get_supported_arguments(warn_flags), native: false, language: 'cpp') 689endif 690if 'objc' in all_languages 691 # Note sanitizer flags are not applied to Objective-C sources! 692 add_project_arguments(objc.get_supported_arguments(warn_flags), native: false, language: 'objc') 693endif 694if host_os == 'linux' 695 add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers', 696 '-isystem', 'linux-headers', 697 language: all_languages) 698endif 699 700add_project_arguments('-iquote', '.', 701 '-iquote', meson.current_source_dir(), 702 '-iquote', meson.current_source_dir() / 'include', 703 language: all_languages) 704 705# If a host-specific include directory exists, list that first... 706host_include = meson.current_source_dir() / 'host/include/' 707if fs.is_dir(host_include / host_arch) 708 add_project_arguments('-iquote', host_include / host_arch, 709 language: all_languages) 710endif 711# ... followed by the generic fallback. 712add_project_arguments('-iquote', host_include / 'generic', 713 language: all_languages) 714 715sparse = find_program('cgcc', required: get_option('sparse')) 716if sparse.found() 717 run_target('sparse', 718 command: [find_program('scripts/check_sparse.py'), 719 'compile_commands.json', sparse.full_path(), '-Wbitwise', 720 '-Wno-transparent-union', '-Wno-old-initializer', 721 '-Wno-non-pointer-null']) 722endif 723 724##################################### 725# Host-specific libraries and flags # 726##################################### 727 728libm = cc.find_library('m', required: false) 729threads = dependency('threads') 730util = cc.find_library('util', required: false) 731winmm = [] 732socket = [] 733version_res = [] 734coref = [] 735iokit = [] 736emulator_link_args = [] 737midl = not_found 738widl = not_found 739pathcch = not_found 740host_dsosuf = '.so' 741if host_os == 'windows' 742 midl = find_program('midl', required: false) 743 widl = find_program('widl', required: false) 744 pathcch = cc.find_library('pathcch') 745 socket = cc.find_library('ws2_32') 746 winmm = cc.find_library('winmm') 747 748 win = import('windows') 749 version_res = win.compile_resources('version.rc', 750 depend_files: files('pc-bios/qemu-nsis.ico'), 751 include_directories: include_directories('.')) 752 host_dsosuf = '.dll' 753elif host_os == 'darwin' 754 coref = dependency('appleframeworks', modules: 'CoreFoundation') 755 iokit = dependency('appleframeworks', modules: 'IOKit', required: false) 756 host_dsosuf = '.dylib' 757elif host_os == 'sunos' 758 socket = [cc.find_library('socket'), 759 cc.find_library('nsl'), 760 cc.find_library('resolv')] 761elif host_os == 'haiku' 762 socket = [cc.find_library('posix_error_mapper'), 763 cc.find_library('network'), 764 cc.find_library('bsd')] 765elif host_os == 'openbsd' 766 if get_option('tcg').allowed() and target_dirs.length() > 0 767 # Disable OpenBSD W^X if available 768 emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded') 769 endif 770endif 771 772############################################### 773# Host-specific configuration of accelerators # 774############################################### 775 776accelerators = [] 777if get_option('kvm').allowed() and host_os == 'linux' 778 accelerators += 'CONFIG_KVM' 779endif 780if get_option('whpx').allowed() and host_os == 'windows' 781 if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64' 782 error('WHPX requires 64-bit host') 783 elif cc.has_header('winhvplatform.h', required: get_option('whpx')) and \ 784 cc.has_header('winhvemulation.h', required: get_option('whpx')) 785 accelerators += 'CONFIG_WHPX' 786 endif 787endif 788 789hvf = not_found 790if get_option('hvf').allowed() 791 hvf = dependency('appleframeworks', modules: 'Hypervisor', 792 required: get_option('hvf')) 793 if hvf.found() 794 accelerators += 'CONFIG_HVF' 795 endif 796endif 797 798nvmm = not_found 799if host_os == 'netbsd' 800 nvmm = cc.find_library('nvmm', required: get_option('nvmm')) 801 if nvmm.found() 802 accelerators += 'CONFIG_NVMM' 803 endif 804endif 805 806tcg_arch = host_arch 807if get_option('tcg').allowed() 808 if host_arch == 'unknown' 809 if not get_option('tcg_interpreter') 810 error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu)) 811 endif 812 elif get_option('tcg_interpreter') 813 warning('Use of the TCG interpreter is not recommended on this host') 814 warning('architecture. There is a native TCG execution backend available') 815 warning('which provides substantially better performance and reliability.') 816 warning('It is strongly recommended to remove the --enable-tcg-interpreter') 817 warning('configuration option on this architecture to use the native') 818 warning('backend.') 819 endif 820 if get_option('tcg_interpreter') 821 tcg_arch = 'tci' 822 elif host_arch == 'x86_64' 823 tcg_arch = 'i386' 824 elif host_arch == 'ppc64' 825 tcg_arch = 'ppc' 826 endif 827 add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch, 828 language: all_languages) 829 830 accelerators += 'CONFIG_TCG' 831endif 832 833if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled() 834 error('KVM not available on this platform') 835endif 836if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled() 837 error('HVF not available on this platform') 838endif 839if 'CONFIG_NVMM' not in accelerators and get_option('nvmm').enabled() 840 error('NVMM not available on this platform') 841endif 842if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled() 843 error('WHPX not available on this platform') 844endif 845 846xen = not_found 847if get_option('xen').enabled() or (get_option('xen').auto() and have_system) 848 xencontrol = dependency('xencontrol', required: false, 849 method: 'pkg-config') 850 if xencontrol.found() 851 xen_pc = declare_dependency(version: xencontrol.version(), 852 dependencies: [ 853 xencontrol, 854 # disabler: true makes xen_pc.found() return false if any is not found 855 dependency('xenstore', required: false, 856 method: 'pkg-config', 857 disabler: true), 858 dependency('xenforeignmemory', required: false, 859 method: 'pkg-config', 860 disabler: true), 861 dependency('xengnttab', required: false, 862 method: 'pkg-config', 863 disabler: true), 864 dependency('xenevtchn', required: false, 865 method: 'pkg-config', 866 disabler: true), 867 dependency('xendevicemodel', required: false, 868 method: 'pkg-config', 869 disabler: true), 870 # optional, no "disabler: true" 871 dependency('xentoolcore', required: false, 872 method: 'pkg-config')]) 873 if xen_pc.found() 874 xen = xen_pc 875 endif 876 endif 877 if not xen.found() 878 xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1' ] 879 xen_libs = { 880 '4.11.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ], 881 '4.10.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ], 882 '4.9.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ], 883 '4.8.0': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ], 884 '4.7.1': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ], 885 } 886 xen_deps = {} 887 foreach ver: xen_tests 888 # cache the various library tests to avoid polluting the logs 889 xen_test_deps = [] 890 foreach l: xen_libs[ver] 891 if l not in xen_deps 892 xen_deps += { l: cc.find_library(l, required: false) } 893 endif 894 xen_test_deps += xen_deps[l] 895 endforeach 896 897 # Use -D to pick just one of the test programs in scripts/xen-detect.c 898 xen_version = ver.split('.') 899 xen_ctrl_version = xen_version[0] + \ 900 ('0' + xen_version[1]).substring(-2) + \ 901 ('0' + xen_version[2]).substring(-2) 902 if cc.links(files('scripts/xen-detect.c'), 903 args: '-DCONFIG_XEN_CTRL_INTERFACE_VERSION=' + xen_ctrl_version, 904 dependencies: xen_test_deps) 905 xen = declare_dependency(version: ver, dependencies: xen_test_deps) 906 break 907 endif 908 endforeach 909 endif 910 if xen.found() 911 accelerators += 'CONFIG_XEN' 912 elif get_option('xen').enabled() 913 error('could not compile and link Xen test program') 914 endif 915endif 916have_xen_pci_passthrough = get_option('xen_pci_passthrough') \ 917 .require(xen.found(), 918 error_message: 'Xen PCI passthrough requested but Xen not enabled') \ 919 .require(host_os == 'linux', 920 error_message: 'Xen PCI passthrough not available on this platform') \ 921 .require(cpu == 'x86' or cpu == 'x86_64', 922 error_message: 'Xen PCI passthrough not available on this platform') \ 923 .allowed() 924 925################ 926# Dependencies # 927################ 928 929# When bumping glib minimum version, please check also whether to increase 930# the _WIN32_WINNT setting in osdep.h according to the value from glib 931glib_req_ver = '>=2.66.0' 932glib_pc = dependency('glib-2.0', version: glib_req_ver, required: true, 933 method: 'pkg-config') 934glib_cflags = [] 935if enable_modules 936 gmodule = dependency('gmodule-export-2.0', version: glib_req_ver, required: true, 937 method: 'pkg-config') 938elif get_option('plugins') 939 gmodule = dependency('gmodule-no-export-2.0', version: glib_req_ver, required: true, 940 method: 'pkg-config') 941else 942 gmodule = not_found 943endif 944 945# This workaround is required due to a bug in pkg-config file for glib as it 946# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 947if host_os == 'windows' and get_option('prefer_static') 948 glib_cflags += ['-DGLIB_STATIC_COMPILATION'] 949endif 950 951# Sanity check that the current size_t matches the 952# size that glib thinks it should be. This catches 953# problems on multi-arch where people try to build 954# 32-bit QEMU while pointing at 64-bit glib headers 955 956if not cc.compiles(''' 957 #include <glib.h> 958 #include <unistd.h> 959 960 #define QEMU_BUILD_BUG_ON(x) \ 961 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 962 963 int main(void) { 964 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 965 return 0; 966 }''', dependencies: glib_pc, args: glib_cflags) 967 error('''sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T. 968 You probably need to set PKG_CONFIG_LIBDIR" to point 969 to the right pkg-config files for your build target.''') 970endif 971 972glib = declare_dependency(dependencies: [glib_pc, gmodule], 973 compile_args: glib_cflags, 974 version: glib_pc.version()) 975 976# Check whether glib has gslice, which we have to avoid for correctness. 977# TODO: remove this check and the corresponding workaround (qtree) when 978# the minimum supported glib is >= 2.75.3 979glib_has_gslice = glib.version().version_compare('<2.75.3') 980 981# override glib dep to include the above refinements 982meson.override_dependency('glib-2.0', glib) 983 984# The path to glib.h is added to all compilation commands. 985add_project_dependencies(glib.partial_dependency(compile_args: true, includes: true), 986 native: false, language: all_languages) 987 988gio = not_found 989gdbus_codegen = not_found 990gdbus_codegen_error = '@0@ requires gdbus-codegen, please install libgio' 991if not get_option('gio').auto() or have_system 992 gio = dependency('gio-2.0', required: get_option('gio'), 993 method: 'pkg-config') 994 if gio.found() and not cc.links(''' 995 #include <gio/gio.h> 996 int main(void) 997 { 998 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0); 999 return 0; 1000 }''', dependencies: [glib, gio]) 1001 if get_option('gio').enabled() 1002 error('The installed libgio is broken for static linking') 1003 endif 1004 gio = not_found 1005 endif 1006 if gio.found() 1007 gdbus_codegen = find_program(gio.get_variable('gdbus_codegen'), 1008 required: get_option('gio')) 1009 gio_unix = dependency('gio-unix-2.0', required: get_option('gio'), 1010 method: 'pkg-config') 1011 gio = declare_dependency(dependencies: [gio, gio_unix], 1012 version: gio.version()) 1013 endif 1014endif 1015if gdbus_codegen.found() and get_option('cfi') 1016 gdbus_codegen = not_found 1017 gdbus_codegen_error = '@0@ uses gdbus-codegen, which does not support control flow integrity' 1018endif 1019 1020xml_pp = find_program('scripts/xml-preprocess.py') 1021 1022lttng = not_found 1023if 'ust' in get_option('trace_backends') 1024 lttng = dependency('lttng-ust', required: true, version: '>= 2.1', 1025 method: 'pkg-config') 1026endif 1027pixman = not_found 1028if not get_option('pixman').auto() or have_system or have_tools 1029 pixman = dependency('pixman-1', required: get_option('pixman'), version:'>=0.21.8', 1030 method: 'pkg-config') 1031endif 1032 1033zlib = dependency('zlib', required: true) 1034 1035libaio = not_found 1036if not get_option('linux_aio').auto() or have_block 1037 libaio = cc.find_library('aio', has_headers: ['libaio.h'], 1038 required: get_option('linux_aio')) 1039endif 1040 1041linux_io_uring_test = ''' 1042 #include <liburing.h> 1043 #include <linux/errqueue.h> 1044 1045 int main(void) { return 0; }''' 1046 1047linux_io_uring = not_found 1048if not get_option('linux_io_uring').auto() or have_block 1049 linux_io_uring = dependency('liburing', version: '>=0.3', 1050 required: get_option('linux_io_uring'), 1051 method: 'pkg-config') 1052 if not cc.links(linux_io_uring_test) 1053 linux_io_uring = not_found 1054 endif 1055endif 1056 1057libnfs = not_found 1058if not get_option('libnfs').auto() or have_block 1059 libnfs = dependency('libnfs', version: '>=1.9.3', 1060 required: get_option('libnfs'), 1061 method: 'pkg-config') 1062endif 1063 1064libattr_test = ''' 1065 #include <stddef.h> 1066 #include <sys/types.h> 1067 #ifdef CONFIG_LIBATTR 1068 #include <attr/xattr.h> 1069 #else 1070 #include <sys/xattr.h> 1071 #endif 1072 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }''' 1073 1074libattr = not_found 1075have_old_libattr = false 1076if get_option('attr').allowed() 1077 if cc.links(libattr_test) 1078 libattr = declare_dependency() 1079 else 1080 libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'], 1081 required: get_option('attr')) 1082 if libattr.found() and not \ 1083 cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR') 1084 libattr = not_found 1085 if get_option('attr').enabled() 1086 error('could not link libattr') 1087 else 1088 warning('could not link libattr, disabling') 1089 endif 1090 else 1091 have_old_libattr = libattr.found() 1092 endif 1093 endif 1094endif 1095 1096cocoa = dependency('appleframeworks', 1097 modules: ['Cocoa', 'CoreVideo', 'QuartzCore'], 1098 required: get_option('cocoa')) 1099 1100vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet')) 1101if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h', 1102 'VMNET_BRIDGED_MODE', 1103 dependencies: vmnet) 1104 vmnet = not_found 1105 if get_option('vmnet').enabled() 1106 error('vmnet.framework API is outdated') 1107 else 1108 warning('vmnet.framework API is outdated, disabling') 1109 endif 1110endif 1111 1112seccomp = not_found 1113seccomp_has_sysrawrc = false 1114if not get_option('seccomp').auto() or have_system or have_tools 1115 seccomp = dependency('libseccomp', version: '>=2.3.0', 1116 required: get_option('seccomp'), 1117 method: 'pkg-config') 1118 if seccomp.found() 1119 seccomp_has_sysrawrc = cc.has_header_symbol('seccomp.h', 1120 'SCMP_FLTATR_API_SYSRAWRC', 1121 dependencies: seccomp) 1122 endif 1123endif 1124 1125libcap_ng = not_found 1126if not get_option('cap_ng').auto() or have_system or have_tools 1127 libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'], 1128 required: get_option('cap_ng')) 1129endif 1130if libcap_ng.found() and not cc.links(''' 1131 #include <cap-ng.h> 1132 int main(void) 1133 { 1134 capng_capability_to_name(CAPNG_EFFECTIVE); 1135 return 0; 1136 }''', dependencies: libcap_ng) 1137 libcap_ng = not_found 1138 if get_option('cap_ng').enabled() 1139 error('could not link libcap-ng') 1140 else 1141 warning('could not link libcap-ng, disabling') 1142 endif 1143endif 1144 1145if get_option('xkbcommon').auto() and not have_system and not have_tools 1146 xkbcommon = not_found 1147else 1148 xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'), 1149 method: 'pkg-config') 1150endif 1151 1152slirp = not_found 1153if not get_option('slirp').auto() or have_system 1154 slirp = dependency('slirp', required: get_option('slirp'), 1155 method: 'pkg-config') 1156 # slirp < 4.7 is incompatible with CFI support in QEMU. This is because 1157 # it passes function pointers within libslirp as callbacks for timers. 1158 # When using a system-wide shared libslirp, the type information for the 1159 # callback is missing and the timer call produces a false positive with CFI. 1160 # Do not use the "version" keyword argument to produce a better error. 1161 # with control-flow integrity. 1162 if get_option('cfi') and slirp.found() and slirp.version().version_compare('<4.7') 1163 if get_option('slirp').enabled() 1164 error('Control-Flow Integrity requires libslirp 4.7.') 1165 else 1166 warning('Cannot use libslirp since Control-Flow Integrity requires libslirp >= 4.7.') 1167 slirp = not_found 1168 endif 1169 endif 1170endif 1171 1172vde = not_found 1173if not get_option('vde').auto() or have_system or have_tools 1174 vde = cc.find_library('vdeplug', has_headers: ['libvdeplug.h'], 1175 required: get_option('vde')) 1176endif 1177if vde.found() and not cc.links(''' 1178 #include <libvdeplug.h> 1179 int main(void) 1180 { 1181 struct vde_open_args a = {0, 0, 0}; 1182 char s[] = ""; 1183 vde_open(s, s, &a); 1184 return 0; 1185 }''', dependencies: vde) 1186 vde = not_found 1187 if get_option('cap_ng').enabled() 1188 error('could not link libvdeplug') 1189 else 1190 warning('could not link libvdeplug, disabling') 1191 endif 1192endif 1193 1194pulse = not_found 1195if not get_option('pa').auto() or (host_os == 'linux' and have_system) 1196 pulse = dependency('libpulse', required: get_option('pa'), 1197 method: 'pkg-config') 1198endif 1199alsa = not_found 1200if not get_option('alsa').auto() or (host_os == 'linux' and have_system) 1201 alsa = dependency('alsa', required: get_option('alsa'), 1202 method: 'pkg-config') 1203endif 1204jack = not_found 1205if not get_option('jack').auto() or have_system 1206 jack = dependency('jack', required: get_option('jack'), 1207 method: 'pkg-config') 1208endif 1209pipewire = not_found 1210if not get_option('pipewire').auto() or (host_os == 'linux' and have_system) 1211 pipewire = dependency('libpipewire-0.3', version: '>=0.3.60', 1212 required: get_option('pipewire'), 1213 method: 'pkg-config') 1214endif 1215sndio = not_found 1216if not get_option('sndio').auto() or have_system 1217 sndio = dependency('sndio', required: get_option('sndio'), 1218 method: 'pkg-config') 1219endif 1220 1221spice_protocol = not_found 1222if not get_option('spice_protocol').auto() or have_system 1223 spice_protocol = dependency('spice-protocol', version: '>=0.14.0', 1224 required: get_option('spice_protocol'), 1225 method: 'pkg-config') 1226endif 1227spice = not_found 1228if get_option('spice') \ 1229 .disable_auto_if(not have_system) \ 1230 .require(pixman.found(), 1231 error_message: 'cannot enable SPICE if pixman is not available') \ 1232 .allowed() 1233 spice = dependency('spice-server', version: '>=0.14.0', 1234 required: get_option('spice'), 1235 method: 'pkg-config') 1236endif 1237spice_headers = spice.partial_dependency(compile_args: true, includes: true) 1238 1239rt = cc.find_library('rt', required: false) 1240 1241libiscsi = not_found 1242if not get_option('libiscsi').auto() or have_block 1243 libiscsi = dependency('libiscsi', version: '>=1.9.0', 1244 required: get_option('libiscsi'), 1245 method: 'pkg-config') 1246endif 1247zstd = not_found 1248if not get_option('zstd').auto() or have_block 1249 zstd = dependency('libzstd', version: '>=1.4.0', 1250 required: get_option('zstd'), 1251 method: 'pkg-config') 1252endif 1253qpl = not_found 1254if not get_option('qpl').auto() or have_system 1255 qpl = dependency('qpl', version: '>=1.5.0', 1256 required: get_option('qpl'), 1257 method: 'pkg-config') 1258endif 1259uadk = not_found 1260if not get_option('uadk').auto() or have_system 1261 libwd = dependency('libwd', version: '>=2.6', 1262 required: get_option('uadk'), 1263 method: 'pkg-config') 1264 libwd_comp = dependency('libwd_comp', version: '>=2.6', 1265 required: get_option('uadk'), 1266 method: 'pkg-config') 1267 if libwd.found() and libwd_comp.found() 1268 uadk = declare_dependency(dependencies: [libwd, libwd_comp]) 1269 endif 1270endif 1271virgl = not_found 1272 1273have_vhost_user_gpu = have_tools and host_os == 'linux' and pixman.found() 1274if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu 1275 virgl = dependency('virglrenderer', 1276 method: 'pkg-config', 1277 required: get_option('virglrenderer')) 1278endif 1279rutabaga = not_found 1280if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu 1281 rutabaga = dependency('rutabaga_gfx_ffi', 1282 method: 'pkg-config', 1283 required: get_option('rutabaga_gfx')) 1284endif 1285blkio = not_found 1286if not get_option('blkio').auto() or have_block 1287 blkio = dependency('blkio', 1288 method: 'pkg-config', 1289 required: get_option('blkio')) 1290endif 1291curl = not_found 1292if not get_option('curl').auto() or have_block 1293 curl = dependency('libcurl', version: '>=7.29.0', 1294 method: 'pkg-config', 1295 required: get_option('curl')) 1296endif 1297libudev = not_found 1298if host_os == 'linux' and (have_system or have_tools) 1299 libudev = dependency('libudev', 1300 method: 'pkg-config', 1301 required: get_option('libudev')) 1302endif 1303 1304mpathlibs = [libudev] 1305mpathpersist = not_found 1306if host_os == 'linux' and have_tools and get_option('mpath').allowed() 1307 mpath_test_source = ''' 1308 #include <libudev.h> 1309 #include <mpath_persist.h> 1310 unsigned mpath_mx_alloc_len = 1024; 1311 int logsink; 1312 static struct config *multipath_conf; 1313 extern struct udev *udev; 1314 extern struct config *get_multipath_config(void); 1315 extern void put_multipath_config(struct config *conf); 1316 struct udev *udev; 1317 struct config *get_multipath_config(void) { return multipath_conf; } 1318 void put_multipath_config(struct config *conf) { } 1319 int main(void) { 1320 udev = udev_new(); 1321 multipath_conf = mpath_lib_init(); 1322 return 0; 1323 }''' 1324 libmpathpersist = cc.find_library('mpathpersist', 1325 required: get_option('mpath')) 1326 if libmpathpersist.found() 1327 mpathlibs += libmpathpersist 1328 if get_option('prefer_static') 1329 mpathlibs += cc.find_library('devmapper', 1330 required: get_option('mpath')) 1331 endif 1332 mpathlibs += cc.find_library('multipath', 1333 required: get_option('mpath')) 1334 foreach lib: mpathlibs 1335 if not lib.found() 1336 mpathlibs = [] 1337 break 1338 endif 1339 endforeach 1340 if mpathlibs.length() == 0 1341 msg = 'Dependencies missing for libmpathpersist' 1342 elif cc.links(mpath_test_source, dependencies: mpathlibs) 1343 mpathpersist = declare_dependency(dependencies: mpathlibs) 1344 else 1345 msg = 'Cannot detect libmpathpersist API' 1346 endif 1347 if not mpathpersist.found() 1348 if get_option('mpath').enabled() 1349 error(msg) 1350 else 1351 warning(msg + ', disabling') 1352 endif 1353 endif 1354 endif 1355endif 1356 1357iconv = not_found 1358curses = not_found 1359if have_system and get_option('curses').allowed() 1360 curses_test = ''' 1361 #if defined(__APPLE__) || defined(__OpenBSD__) 1362 #define _XOPEN_SOURCE_EXTENDED 1 1363 #endif 1364 #include <locale.h> 1365 #include <curses.h> 1366 #include <wchar.h> 1367 int main(void) { 1368 wchar_t wch = L'w'; 1369 setlocale(LC_ALL, ""); 1370 resize_term(0, 0); 1371 addwstr(L"wide chars\n"); 1372 addnwstr(&wch, 1); 1373 add_wch(WACS_DEGREE); 1374 return 0; 1375 }''' 1376 1377 curses_dep_list = host_os == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw'] 1378 curses = dependency(curses_dep_list, 1379 required: false, 1380 method: 'pkg-config') 1381 msg = get_option('curses').enabled() ? 'curses library not found' : '' 1382 curses_compile_args = ['-DNCURSES_WIDECHAR=1'] 1383 if curses.found() 1384 if cc.links(curses_test, args: curses_compile_args, dependencies: [curses]) 1385 curses = declare_dependency(compile_args: curses_compile_args, dependencies: [curses], 1386 version: curses.version()) 1387 else 1388 msg = 'curses package not usable' 1389 curses = not_found 1390 endif 1391 endif 1392 if not curses.found() 1393 has_curses_h = cc.has_header('curses.h', args: curses_compile_args) 1394 if host_os != 'windows' and not has_curses_h 1395 message('Trying with /usr/include/ncursesw') 1396 curses_compile_args += ['-I/usr/include/ncursesw'] 1397 has_curses_h = cc.has_header('curses.h', args: curses_compile_args) 1398 endif 1399 if has_curses_h 1400 curses_libname_list = (host_os == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw']) 1401 foreach curses_libname : curses_libname_list 1402 libcurses = cc.find_library(curses_libname, 1403 required: false) 1404 if libcurses.found() 1405 if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses) 1406 curses = declare_dependency(compile_args: curses_compile_args, 1407 dependencies: [libcurses]) 1408 break 1409 else 1410 msg = 'curses library not usable' 1411 endif 1412 endif 1413 endforeach 1414 endif 1415 endif 1416 if get_option('iconv').allowed() 1417 foreach link_args : [ ['-liconv'], [] ] 1418 # Programs will be linked with glib and this will bring in libiconv on FreeBSD. 1419 # We need to use libiconv if available because mixing libiconv's headers with 1420 # the system libc does not work. 1421 # However, without adding glib to the dependencies -L/usr/local/lib will not be 1422 # included in the command line and libiconv will not be found. 1423 if cc.links(''' 1424 #include <iconv.h> 1425 int main(void) { 1426 iconv_t conv = iconv_open("WCHAR_T", "UCS-2"); 1427 return conv != (iconv_t) -1; 1428 }''', args: link_args, dependencies: glib) 1429 iconv = declare_dependency(link_args: link_args, dependencies: glib) 1430 break 1431 endif 1432 endforeach 1433 endif 1434 if curses.found() and not iconv.found() 1435 if get_option('iconv').enabled() 1436 error('iconv not available') 1437 endif 1438 msg = 'iconv required for curses UI but not available' 1439 curses = not_found 1440 endif 1441 if not curses.found() and msg != '' 1442 if get_option('curses').enabled() 1443 error(msg) 1444 else 1445 warning(msg + ', disabling') 1446 endif 1447 endif 1448endif 1449 1450brlapi = not_found 1451if not get_option('brlapi').auto() or have_system 1452 brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'], 1453 required: get_option('brlapi')) 1454 if brlapi.found() and not cc.links(''' 1455 #include <brlapi.h> 1456 #include <stddef.h> 1457 int main(void) { return brlapi__openConnection (NULL, NULL, NULL); }''', dependencies: brlapi) 1458 brlapi = not_found 1459 if get_option('brlapi').enabled() 1460 error('could not link brlapi') 1461 else 1462 warning('could not link brlapi, disabling') 1463 endif 1464 endif 1465endif 1466 1467sdl = not_found 1468if not get_option('sdl').auto() or have_system 1469 sdl = dependency('sdl2', required: get_option('sdl')) 1470 sdl_image = not_found 1471endif 1472if sdl.found() 1473 # Some versions of SDL have problems with -Wundef 1474 if not cc.compiles(''' 1475 #include <SDL.h> 1476 #include <SDL_syswm.h> 1477 int main(int argc, char *argv[]) { return 0; } 1478 ''', dependencies: sdl, args: '-Werror=undef') 1479 sdl = declare_dependency(compile_args: '-Wno-undef', 1480 dependencies: sdl, 1481 version: sdl.version()) 1482 endif 1483 sdl_image = dependency('SDL2_image', required: get_option('sdl_image'), 1484 method: 'pkg-config') 1485else 1486 if get_option('sdl_image').enabled() 1487 error('sdl-image required, but SDL was @0@'.format( 1488 get_option('sdl').disabled() ? 'disabled' : 'not found')) 1489 endif 1490 sdl_image = not_found 1491endif 1492 1493rbd = not_found 1494if not get_option('rbd').auto() or have_block 1495 librados = cc.find_library('rados', required: get_option('rbd')) 1496 librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'], 1497 required: get_option('rbd')) 1498 if librados.found() and librbd.found() 1499 if cc.links(''' 1500 #include <stdio.h> 1501 #include <rbd/librbd.h> 1502 int main(void) { 1503 rados_t cluster; 1504 rados_create(&cluster, NULL); 1505 #if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 12, 0) 1506 #error 1507 #endif 1508 return 0; 1509 }''', dependencies: [librbd, librados]) 1510 rbd = declare_dependency(dependencies: [librbd, librados]) 1511 elif get_option('rbd').enabled() 1512 error('librbd >= 1.12.0 required') 1513 else 1514 warning('librbd >= 1.12.0 not found, disabling') 1515 endif 1516 endif 1517endif 1518 1519glusterfs = not_found 1520glusterfs_ftruncate_has_stat = false 1521glusterfs_iocb_has_stat = false 1522if not get_option('glusterfs').auto() or have_block 1523 glusterfs = dependency('glusterfs-api', version: '>=3', 1524 required: get_option('glusterfs'), 1525 method: 'pkg-config') 1526 if glusterfs.found() 1527 glusterfs_ftruncate_has_stat = cc.links(''' 1528 #include <glusterfs/api/glfs.h> 1529 1530 int 1531 main(void) 1532 { 1533 /* new glfs_ftruncate() passes two additional args */ 1534 return glfs_ftruncate(NULL, 0, NULL, NULL); 1535 } 1536 ''', dependencies: glusterfs) 1537 glusterfs_iocb_has_stat = cc.links(''' 1538 #include <glusterfs/api/glfs.h> 1539 1540 /* new glfs_io_cbk() passes two additional glfs_stat structs */ 1541 static void 1542 glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data) 1543 {} 1544 1545 int 1546 main(void) 1547 { 1548 glfs_io_cbk iocb = &glusterfs_iocb; 1549 iocb(NULL, 0 , NULL, NULL, NULL); 1550 return 0; 1551 } 1552 ''', dependencies: glusterfs) 1553 endif 1554endif 1555 1556hv_balloon = false 1557if get_option('hv_balloon').allowed() and have_system 1558 if cc.links(''' 1559 #include <string.h> 1560 #include <gmodule.h> 1561 int main(void) { 1562 GTree *tree; 1563 1564 tree = g_tree_new((GCompareFunc)strcmp); 1565 (void)g_tree_node_first(tree); 1566 g_tree_destroy(tree); 1567 return 0; 1568 } 1569 ''', dependencies: glib) 1570 hv_balloon = true 1571 else 1572 if get_option('hv_balloon').enabled() 1573 error('could not enable hv-balloon, update your glib') 1574 else 1575 warning('could not find glib support for hv-balloon, disabling') 1576 endif 1577 endif 1578endif 1579 1580libssh = not_found 1581if not get_option('libssh').auto() or have_block 1582 libssh = dependency('libssh', version: '>=0.8.7', 1583 method: 'pkg-config', 1584 required: get_option('libssh')) 1585endif 1586 1587libbzip2 = not_found 1588if not get_option('bzip2').auto() or have_block 1589 libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'], 1590 required: get_option('bzip2')) 1591 if libbzip2.found() and not cc.links(''' 1592 #include <bzlib.h> 1593 int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2) 1594 libbzip2 = not_found 1595 if get_option('bzip2').enabled() 1596 error('could not link libbzip2') 1597 else 1598 warning('could not link libbzip2, disabling') 1599 endif 1600 endif 1601endif 1602 1603liblzfse = not_found 1604if not get_option('lzfse').auto() or have_block 1605 liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'], 1606 required: get_option('lzfse')) 1607endif 1608if liblzfse.found() and not cc.links(''' 1609 #include <lzfse.h> 1610 int main(void) { lzfse_decode_scratch_size(); return 0; }''', dependencies: liblzfse) 1611 liblzfse = not_found 1612 if get_option('lzfse').enabled() 1613 error('could not link liblzfse') 1614 else 1615 warning('could not link liblzfse, disabling') 1616 endif 1617endif 1618 1619oss = not_found 1620if get_option('oss').allowed() and have_system 1621 if not cc.has_header('sys/soundcard.h') 1622 # not found 1623 elif host_os == 'netbsd' 1624 oss = cc.find_library('ossaudio', required: get_option('oss')) 1625 else 1626 oss = declare_dependency() 1627 endif 1628 1629 if not oss.found() 1630 if get_option('oss').enabled() 1631 error('OSS not found') 1632 endif 1633 endif 1634endif 1635dsound = not_found 1636if not get_option('dsound').auto() or (host_os == 'windows' and have_system) 1637 if cc.has_header('dsound.h') 1638 dsound = declare_dependency(link_args: ['-lole32', '-ldxguid']) 1639 endif 1640 1641 if not dsound.found() 1642 if get_option('dsound').enabled() 1643 error('DirectSound not found') 1644 endif 1645 endif 1646endif 1647 1648coreaudio = not_found 1649if not get_option('coreaudio').auto() or (host_os == 'darwin' and have_system) 1650 coreaudio = dependency('appleframeworks', modules: 'CoreAudio', 1651 required: get_option('coreaudio')) 1652endif 1653 1654opengl = not_found 1655if not get_option('opengl').auto() or have_system or have_vhost_user_gpu 1656 epoxy = dependency('epoxy', method: 'pkg-config', 1657 required: get_option('opengl')) 1658 if cc.has_header('epoxy/egl.h', dependencies: epoxy) 1659 opengl = epoxy 1660 elif get_option('opengl').enabled() 1661 error('epoxy/egl.h not found') 1662 endif 1663endif 1664gbm = not_found 1665if (have_system or have_tools) and (virgl.found() or opengl.found()) 1666 gbm = dependency('gbm', method: 'pkg-config', required: false) 1667endif 1668have_vhost_user_gpu = have_vhost_user_gpu and virgl.found() and opengl.found() and gbm.found() 1669 1670gnutls = not_found 1671gnutls_crypto = not_found 1672if get_option('gnutls').enabled() or (get_option('gnutls').auto() and have_system) 1673 # For general TLS support our min gnutls matches 1674 # that implied by our platform support matrix 1675 # 1676 # For the crypto backends, we look for a newer 1677 # gnutls: 1678 # 1679 # Version 3.6.8 is needed to get XTS 1680 # Version 3.6.13 is needed to get PBKDF 1681 # Version 3.6.14 is needed to get HW accelerated XTS 1682 # 1683 # If newer enough gnutls isn't available, we can 1684 # still use a different crypto backend to satisfy 1685 # the platform support requirements 1686 gnutls_crypto = dependency('gnutls', version: '>=3.6.14', 1687 method: 'pkg-config', 1688 required: false) 1689 if gnutls_crypto.found() 1690 gnutls = gnutls_crypto 1691 else 1692 # Our min version if all we need is TLS 1693 gnutls = dependency('gnutls', version: '>=3.5.18', 1694 method: 'pkg-config', 1695 required: get_option('gnutls')) 1696 endif 1697endif 1698 1699# We prefer use of gnutls for crypto, unless the options 1700# explicitly asked for nettle or gcrypt. 1701# 1702# If gnutls isn't available for crypto, then we'll prefer 1703# gcrypt over nettle for performance reasons. 1704gcrypt = not_found 1705nettle = not_found 1706hogweed = not_found 1707crypto_sm4 = not_found 1708xts = 'none' 1709 1710if get_option('nettle').enabled() and get_option('gcrypt').enabled() 1711 error('Only one of gcrypt & nettle can be enabled') 1712endif 1713 1714# Explicit nettle/gcrypt request, so ignore gnutls for crypto 1715if get_option('nettle').enabled() or get_option('gcrypt').enabled() 1716 gnutls_crypto = not_found 1717endif 1718 1719if not gnutls_crypto.found() 1720 if (not get_option('gcrypt').auto() or have_system) and not get_option('nettle').enabled() 1721 gcrypt = dependency('libgcrypt', version: '>=1.8', 1722 required: get_option('gcrypt')) 1723 # Debian has removed -lgpg-error from libgcrypt-config 1724 # as it "spreads unnecessary dependencies" which in 1725 # turn breaks static builds... 1726 if gcrypt.found() and get_option('prefer_static') 1727 gcrypt = declare_dependency(dependencies: 1728 [gcrypt, 1729 cc.find_library('gpg-error', required: true)], 1730 version: gcrypt.version()) 1731 endif 1732 crypto_sm4 = gcrypt 1733 # SM4 ALG is available in libgcrypt >= 1.9 1734 if gcrypt.found() and not cc.links(''' 1735 #include <gcrypt.h> 1736 int main(void) { 1737 gcry_cipher_hd_t handler; 1738 gcry_cipher_open(&handler, GCRY_CIPHER_SM4, GCRY_CIPHER_MODE_ECB, 0); 1739 return 0; 1740 }''', dependencies: gcrypt) 1741 crypto_sm4 = not_found 1742 endif 1743 endif 1744 if (not get_option('nettle').auto() or have_system) and not gcrypt.found() 1745 nettle = dependency('nettle', version: '>=3.4', 1746 method: 'pkg-config', 1747 required: get_option('nettle')) 1748 if nettle.found() and not cc.has_header('nettle/xts.h', dependencies: nettle) 1749 xts = 'private' 1750 endif 1751 crypto_sm4 = nettle 1752 # SM4 ALG is available in nettle >= 3.9 1753 if nettle.found() and not cc.links(''' 1754 #include <nettle/sm4.h> 1755 int main(void) { 1756 struct sm4_ctx ctx; 1757 unsigned char key[16] = {0}; 1758 sm4_set_encrypt_key(&ctx, key); 1759 return 0; 1760 }''', dependencies: nettle) 1761 crypto_sm4 = not_found 1762 endif 1763 endif 1764endif 1765 1766capstone = not_found 1767if not get_option('capstone').auto() or have_system or have_user 1768 capstone = dependency('capstone', version: '>=3.0.5', 1769 method: 'pkg-config', 1770 required: get_option('capstone')) 1771 1772 # Some versions of capstone have broken pkg-config file 1773 # that reports a wrong -I path, causing the #include to 1774 # fail later. If the system has such a broken version 1775 # do not use it. 1776 if capstone.found() and not cc.compiles('#include <capstone.h>', 1777 dependencies: [capstone]) 1778 capstone = not_found 1779 if get_option('capstone').enabled() 1780 error('capstone requested, but it does not appear to work') 1781 endif 1782 endif 1783endif 1784 1785gmp = dependency('gmp', required: false, method: 'pkg-config') 1786if nettle.found() and gmp.found() 1787 hogweed = dependency('hogweed', version: '>=3.4', 1788 method: 'pkg-config', 1789 required: get_option('nettle')) 1790endif 1791 1792 1793gtk = not_found 1794gtkx11 = not_found 1795vte = not_found 1796have_gtk_clipboard = get_option('gtk_clipboard').enabled() 1797 1798if get_option('gtk') \ 1799 .disable_auto_if(not have_system) \ 1800 .require(pixman.found(), 1801 error_message: 'cannot enable GTK if pixman is not available') \ 1802 .allowed() 1803 gtk = dependency('gtk+-3.0', version: '>=3.22.0', 1804 method: 'pkg-config', 1805 required: get_option('gtk')) 1806 if gtk.found() 1807 gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0', 1808 method: 'pkg-config', 1809 required: false) 1810 gtk = declare_dependency(dependencies: [gtk, gtkx11], 1811 version: gtk.version()) 1812 1813 if not get_option('vte').auto() or have_system 1814 vte = dependency('vte-2.91', 1815 method: 'pkg-config', 1816 required: get_option('vte')) 1817 endif 1818 elif have_gtk_clipboard 1819 error('GTK clipboard requested, but GTK not found') 1820 endif 1821endif 1822 1823x11 = not_found 1824if gtkx11.found() 1825 x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found()) 1826endif 1827png = not_found 1828if get_option('png').allowed() and have_system 1829 png = dependency('libpng', version: '>=1.6.34', required: get_option('png'), 1830 method: 'pkg-config') 1831endif 1832vnc = not_found 1833jpeg = not_found 1834sasl = not_found 1835if get_option('vnc') \ 1836 .disable_auto_if(not have_system) \ 1837 .require(pixman.found(), 1838 error_message: 'cannot enable VNC if pixman is not available') \ 1839 .allowed() 1840 vnc = declare_dependency() # dummy dependency 1841 jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'), 1842 method: 'pkg-config') 1843 sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'], 1844 required: get_option('vnc_sasl')) 1845 if sasl.found() 1846 sasl = declare_dependency(dependencies: sasl, 1847 compile_args: '-DSTRUCT_IOVEC_DEFINED') 1848 endif 1849endif 1850 1851pam = not_found 1852if not get_option('auth_pam').auto() or have_system 1853 pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'], 1854 required: get_option('auth_pam')) 1855endif 1856if pam.found() and not cc.links(''' 1857 #include <stddef.h> 1858 #include <security/pam_appl.h> 1859 int main(void) { 1860 const char *service_name = "qemu"; 1861 const char *user = "frank"; 1862 const struct pam_conv pam_conv = { 0 }; 1863 pam_handle_t *pamh = NULL; 1864 pam_start(service_name, user, &pam_conv, &pamh); 1865 return 0; 1866 }''', dependencies: pam) 1867 pam = not_found 1868 if get_option('auth_pam').enabled() 1869 error('could not link libpam') 1870 else 1871 warning('could not link libpam, disabling') 1872 endif 1873endif 1874 1875snappy = not_found 1876if not get_option('snappy').auto() or have_system 1877 snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'], 1878 required: get_option('snappy')) 1879endif 1880if snappy.found() and not cc.links(''' 1881 #include <snappy-c.h> 1882 int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy) 1883 snappy = not_found 1884 if get_option('snappy').enabled() 1885 error('could not link libsnappy') 1886 else 1887 warning('could not link libsnappy, disabling') 1888 endif 1889endif 1890 1891lzo = not_found 1892if not get_option('lzo').auto() or have_system 1893 lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'], 1894 required: get_option('lzo')) 1895endif 1896if lzo.found() and not cc.links(''' 1897 #include <lzo/lzo1x.h> 1898 int main(void) { lzo_version(); return 0; }''', dependencies: lzo) 1899 lzo = not_found 1900 if get_option('lzo').enabled() 1901 error('could not link liblzo2') 1902 else 1903 warning('could not link liblzo2, disabling') 1904 endif 1905endif 1906 1907numa = not_found 1908if not get_option('numa').auto() or have_system or have_tools 1909 numa = cc.find_library('numa', has_headers: ['numa.h'], 1910 required: get_option('numa')) 1911endif 1912if numa.found() and not cc.links(''' 1913 #include <numa.h> 1914 int main(void) { return numa_available(); } 1915 ''', dependencies: numa) 1916 numa = not_found 1917 if get_option('numa').enabled() 1918 error('could not link numa') 1919 else 1920 warning('could not link numa, disabling') 1921 endif 1922endif 1923 1924fdt = not_found 1925fdt_opt = get_option('fdt') 1926if fdt_opt == 'enabled' and get_option('wrap_mode') == 'nodownload' 1927 fdt_opt = 'system' 1928endif 1929if fdt_opt in ['enabled', 'system'] or (fdt_opt == 'auto' and have_system) 1930 fdt = cc.find_library('fdt', required: fdt_opt == 'system') 1931 if fdt.found() and cc.links(''' 1932 #include <libfdt.h> 1933 #include <libfdt_env.h> 1934 int main(void) { fdt_find_max_phandle(NULL, NULL); return 0; }''', 1935 dependencies: fdt) 1936 fdt_opt = 'system' 1937 elif fdt_opt != 'system' 1938 fdt_opt = get_option('wrap_mode') == 'nodownload' ? 'disabled' : 'internal' 1939 fdt = not_found 1940 else 1941 error('system libfdt is too old (1.5.1 or newer required)') 1942 endif 1943endif 1944if fdt_opt == 'internal' 1945 assert(not fdt.found()) 1946 libfdt_proj = subproject('dtc', required: true, 1947 default_options: ['tools=false', 'yaml=disabled', 1948 'python=disabled', 'default_library=static']) 1949 fdt = libfdt_proj.get_variable('libfdt_dep') 1950endif 1951 1952rdma = not_found 1953if not get_option('rdma').auto() or have_system 1954 rdma_libs = [cc.find_library('rdmacm', has_headers: ['rdma/rdma_cma.h'], 1955 required: get_option('rdma')), 1956 cc.find_library('ibverbs', required: get_option('rdma'))] 1957 rdma = declare_dependency(dependencies: rdma_libs) 1958 foreach lib: rdma_libs 1959 if not lib.found() 1960 rdma = not_found 1961 endif 1962 endforeach 1963endif 1964 1965cacard = not_found 1966if not get_option('smartcard').auto() or have_system 1967 cacard = dependency('libcacard', required: get_option('smartcard'), 1968 version: '>=2.5.1', method: 'pkg-config') 1969endif 1970u2f = not_found 1971if not get_option('u2f').auto() or have_system 1972 u2f = dependency('u2f-emu', required: get_option('u2f'), 1973 method: 'pkg-config') 1974endif 1975canokey = not_found 1976if not get_option('canokey').auto() or have_system 1977 canokey = dependency('canokey-qemu', required: get_option('canokey'), 1978 method: 'pkg-config') 1979endif 1980usbredir = not_found 1981if not get_option('usb_redir').auto() or have_system 1982 usbredir = dependency('libusbredirparser-0.5', required: get_option('usb_redir'), 1983 version: '>=0.6', method: 'pkg-config') 1984endif 1985libusb = not_found 1986if not get_option('libusb').auto() or have_system 1987 libusb = dependency('libusb-1.0', required: get_option('libusb'), 1988 version: '>=1.0.13', method: 'pkg-config') 1989endif 1990 1991libpmem = not_found 1992if not get_option('libpmem').auto() or have_system 1993 libpmem = dependency('libpmem', required: get_option('libpmem'), 1994 method: 'pkg-config') 1995endif 1996libdaxctl = not_found 1997if not get_option('libdaxctl').auto() or have_system 1998 libdaxctl = dependency('libdaxctl', required: get_option('libdaxctl'), 1999 version: '>=57', method: 'pkg-config') 2000endif 2001tasn1 = not_found 2002if gnutls.found() 2003 tasn1 = dependency('libtasn1', 2004 required: false, 2005 method: 'pkg-config') 2006endif 2007keyutils = not_found 2008if not get_option('libkeyutils').auto() or have_block 2009 keyutils = dependency('libkeyutils', required: get_option('libkeyutils'), 2010 method: 'pkg-config') 2011endif 2012 2013has_gettid = cc.has_function('gettid') 2014 2015# libselinux 2016selinux = dependency('libselinux', 2017 required: get_option('selinux'), 2018 method: 'pkg-config') 2019 2020# Malloc tests 2021 2022malloc = [] 2023if get_option('malloc') == 'system' 2024 has_malloc_trim = \ 2025 get_option('malloc_trim').allowed() and \ 2026 cc.has_function('malloc_trim', prefix: '#include <malloc.h>') 2027else 2028 has_malloc_trim = false 2029 malloc = cc.find_library(get_option('malloc'), required: true) 2030endif 2031if not has_malloc_trim and get_option('malloc_trim').enabled() 2032 if get_option('malloc') == 'system' 2033 error('malloc_trim not available on this platform.') 2034 else 2035 error('malloc_trim not available with non-libc memory allocator') 2036 endif 2037endif 2038 2039gnu_source_prefix = ''' 2040 #ifndef _GNU_SOURCE 2041 #define _GNU_SOURCE 2042 #endif 2043''' 2044 2045# Check whether the glibc provides STATX_BASIC_STATS 2046 2047has_statx = cc.has_header_symbol('sys/stat.h', 'STATX_BASIC_STATS', prefix: gnu_source_prefix) 2048 2049# Check whether statx() provides mount ID information 2050 2051has_statx_mnt_id = cc.has_header_symbol('sys/stat.h', 'STATX_MNT_ID', prefix: gnu_source_prefix) 2052 2053have_vhost_user_blk_server = get_option('vhost_user_blk_server') \ 2054 .require(host_os == 'linux', 2055 error_message: 'vhost_user_blk_server requires linux') \ 2056 .require(have_vhost_user, 2057 error_message: 'vhost_user_blk_server requires vhost-user support') \ 2058 .disable_auto_if(not have_tools and not have_system) \ 2059 .allowed() 2060 2061if get_option('fuse').disabled() and get_option('fuse_lseek').enabled() 2062 error('Cannot enable fuse-lseek while fuse is disabled') 2063endif 2064 2065fuse = dependency('fuse3', required: get_option('fuse'), 2066 version: '>=3.1', method: 'pkg-config') 2067 2068fuse_lseek = not_found 2069if get_option('fuse_lseek').allowed() 2070 if fuse.version().version_compare('>=3.8') 2071 # Dummy dependency 2072 fuse_lseek = declare_dependency() 2073 elif get_option('fuse_lseek').enabled() 2074 if fuse.found() 2075 error('fuse-lseek requires libfuse >=3.8, found ' + fuse.version()) 2076 else 2077 error('fuse-lseek requires libfuse, which was not found') 2078 endif 2079 endif 2080endif 2081 2082have_libvduse = (host_os == 'linux') 2083if get_option('libvduse').enabled() 2084 if host_os != 'linux' 2085 error('libvduse requires linux') 2086 endif 2087elif get_option('libvduse').disabled() 2088 have_libvduse = false 2089endif 2090 2091have_vduse_blk_export = (have_libvduse and host_os == 'linux') 2092if get_option('vduse_blk_export').enabled() 2093 if host_os != 'linux' 2094 error('vduse_blk_export requires linux') 2095 elif not have_libvduse 2096 error('vduse_blk_export requires libvduse support') 2097 endif 2098elif get_option('vduse_blk_export').disabled() 2099 have_vduse_blk_export = false 2100endif 2101 2102# libbpf 2103bpf_version = '1.1.0' 2104libbpf = dependency('libbpf', version: '>=' + bpf_version, required: get_option('bpf'), method: 'pkg-config') 2105if libbpf.found() and not cc.links(''' 2106 #include <bpf/libbpf.h> 2107 #include <linux/bpf.h> 2108 int main(void) 2109 { 2110 // check flag availability 2111 int flag = BPF_F_MMAPABLE; 2112 bpf_object__destroy_skeleton(NULL); 2113 return 0; 2114 }''', dependencies: libbpf) 2115 libbpf = not_found 2116 if get_option('bpf').enabled() 2117 error('libbpf skeleton/mmaping test failed') 2118 else 2119 warning('libbpf skeleton/mmaping test failed, disabling') 2120 endif 2121endif 2122 2123# libxdp 2124libxdp = not_found 2125if not get_option('af_xdp').auto() or have_system 2126 libxdp = dependency('libxdp', required: get_option('af_xdp'), 2127 version: '>=1.4.0', method: 'pkg-config') 2128endif 2129 2130# libdw 2131libdw = not_found 2132if not get_option('libdw').auto() or \ 2133 (not get_option('prefer_static') and (have_system or have_user)) 2134 libdw = dependency('libdw', 2135 method: 'pkg-config', 2136 required: get_option('libdw')) 2137endif 2138 2139################# 2140# config-host.h # 2141################# 2142 2143config_host_data = configuration_data() 2144 2145audio_drivers_selected = [] 2146if have_system 2147 audio_drivers_available = { 2148 'alsa': alsa.found(), 2149 'coreaudio': coreaudio.found(), 2150 'dsound': dsound.found(), 2151 'jack': jack.found(), 2152 'oss': oss.found(), 2153 'pa': pulse.found(), 2154 'pipewire': pipewire.found(), 2155 'sdl': sdl.found(), 2156 'sndio': sndio.found(), 2157 } 2158 foreach k, v: audio_drivers_available 2159 config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v) 2160 endforeach 2161 2162 # Default to native drivers first, OSS second, SDL third 2163 audio_drivers_priority = \ 2164 [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \ 2165 (host_os == 'linux' ? [] : [ 'sdl' ]) 2166 audio_drivers_default = [] 2167 foreach k: audio_drivers_priority 2168 if audio_drivers_available[k] 2169 audio_drivers_default += k 2170 endif 2171 endforeach 2172 2173 foreach k: get_option('audio_drv_list') 2174 if k == 'default' 2175 audio_drivers_selected += audio_drivers_default 2176 elif not audio_drivers_available[k] 2177 error('Audio driver "@0@" not available.'.format(k)) 2178 else 2179 audio_drivers_selected += k 2180 endif 2181 endforeach 2182endif 2183config_host_data.set('CONFIG_AUDIO_DRIVERS', 2184 '"' + '", "'.join(audio_drivers_selected) + '", ') 2185 2186have_host_block_device = (host_os != 'darwin' or 2187 cc.has_header('IOKit/storage/IOMedia.h')) 2188 2189dbus_display = get_option('dbus_display') \ 2190 .require(gio.version().version_compare('>=2.64'), 2191 error_message: '-display dbus requires glib>=2.64') \ 2192 .require(gdbus_codegen.found(), 2193 error_message: gdbus_codegen_error.format('-display dbus')) \ 2194 .allowed() 2195 2196have_virtfs = get_option('virtfs') \ 2197 .require(host_os == 'linux' or host_os == 'darwin', 2198 error_message: 'virtio-9p (virtfs) requires Linux or macOS') \ 2199 .require(host_os == 'linux' or cc.has_function('pthread_fchdir_np'), 2200 error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \ 2201 .require(host_os == 'darwin' or libattr.found(), 2202 error_message: 'virtio-9p (virtfs) on Linux requires libattr-devel') \ 2203 .disable_auto_if(not have_tools and not have_system) \ 2204 .allowed() 2205 2206have_virtfs_proxy_helper = get_option('virtfs_proxy_helper') \ 2207 .require(host_os != 'darwin', error_message: 'the virtfs proxy helper is incompatible with macOS') \ 2208 .require(have_virtfs, error_message: 'the virtfs proxy helper requires that virtfs is enabled') \ 2209 .disable_auto_if(not have_tools) \ 2210 .require(libcap_ng.found(), error_message: 'the virtfs proxy helper requires libcap-ng') \ 2211 .allowed() 2212 2213qga_fsfreeze = false 2214qga_fstrim = false 2215if host_os == 'linux' 2216 if cc.has_header_symbol('linux/fs.h', 'FIFREEZE') 2217 qga_fsfreeze = true 2218 endif 2219 if cc.has_header_symbol('linux/fs.h', 'FITRIM') 2220 qga_fstrim = true 2221 endif 2222elif host_os == 'freebsd' and cc.has_header_symbol('ufs/ffs/fs.h', 'UFSSUSPEND') 2223 qga_fsfreeze = true 2224endif 2225 2226if get_option('block_drv_ro_whitelist') == '' 2227 config_host_data.set('CONFIG_BDRV_RO_WHITELIST', '') 2228else 2229 config_host_data.set('CONFIG_BDRV_RO_WHITELIST', 2230 '"' + get_option('block_drv_ro_whitelist').replace(',', '", "') + '", ') 2231endif 2232if get_option('block_drv_rw_whitelist') == '' 2233 config_host_data.set('CONFIG_BDRV_RW_WHITELIST', '') 2234else 2235 config_host_data.set('CONFIG_BDRV_RW_WHITELIST', 2236 '"' + get_option('block_drv_rw_whitelist').replace(',', '", "') + '", ') 2237endif 2238 2239foreach k : get_option('trace_backends') 2240 config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true) 2241endforeach 2242config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('trace_file')) 2243config_host_data.set_quoted('CONFIG_TLS_PRIORITY', get_option('tls_priority')) 2244if iasl.found() 2245 config_host_data.set_quoted('CONFIG_IASL', iasl.full_path()) 2246endif 2247config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir')) 2248config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix')) 2249config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir) 2250config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir) 2251config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir) 2252 2253qemu_firmwarepath = '' 2254foreach k : get_option('qemu_firmwarepath') 2255 qemu_firmwarepath += '"' + get_option('prefix') / k + '", ' 2256endforeach 2257config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_firmwarepath) 2258 2259config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir')) 2260config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir) 2261config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir')) 2262config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir')) 2263config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir) 2264config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir')) 2265 2266if enable_modules 2267 config_host_data.set('CONFIG_STAMP', run_command( 2268 meson.current_source_dir() / 'scripts/qemu-stamp.py', 2269 meson.project_version(), get_option('pkgversion'), '--', 2270 meson.current_source_dir() / 'configure', 2271 capture: true, check: true).stdout().strip()) 2272endif 2273 2274have_slirp_smbd = get_option('slirp_smbd') \ 2275 .require(host_os != 'windows', error_message: 'Host smbd not supported on this platform.') \ 2276 .allowed() 2277if have_slirp_smbd 2278 smbd_path = get_option('smbd') 2279 if smbd_path == '' 2280 smbd_path = (host_os == 'sunos' ? '/usr/sfw/sbin/smbd' : '/usr/sbin/smbd') 2281 endif 2282 config_host_data.set_quoted('CONFIG_SMBD_COMMAND', smbd_path) 2283endif 2284 2285config_host_data.set('HOST_' + host_arch.to_upper(), 1) 2286 2287kvm_targets_c = '""' 2288if get_option('kvm').allowed() and host_os == 'linux' 2289 kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"' 2290endif 2291config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c) 2292 2293if get_option('module_upgrades') and not enable_modules 2294 error('Cannot enable module-upgrades as modules are not enabled') 2295endif 2296config_host_data.set('CONFIG_MODULE_UPGRADES', get_option('module_upgrades')) 2297 2298config_host_data.set('CONFIG_ATTR', libattr.found()) 2299config_host_data.set('CONFIG_BDRV_WHITELIST_TOOLS', get_option('block_drv_whitelist_in_tools')) 2300config_host_data.set('CONFIG_BRLAPI', brlapi.found()) 2301config_host_data.set('CONFIG_BSD', host_os in bsd_oses) 2302config_host_data.set('CONFIG_FREEBSD', host_os == 'freebsd') 2303config_host_data.set('CONFIG_CAPSTONE', capstone.found()) 2304config_host_data.set('CONFIG_COCOA', cocoa.found()) 2305config_host_data.set('CONFIG_DARWIN', host_os == 'darwin') 2306config_host_data.set('CONFIG_FDT', fdt.found()) 2307config_host_data.set('CONFIG_FUZZ', get_option('fuzzing')) 2308config_host_data.set('CONFIG_GCOV', get_option('b_coverage')) 2309config_host_data.set('CONFIG_LIBUDEV', libudev.found()) 2310config_host_data.set('CONFIG_LINUX', host_os == 'linux') 2311config_host_data.set('CONFIG_POSIX', host_os != 'windows') 2312config_host_data.set('CONFIG_WIN32', host_os == 'windows') 2313config_host_data.set('CONFIG_LZO', lzo.found()) 2314config_host_data.set('CONFIG_MPATH', mpathpersist.found()) 2315config_host_data.set('CONFIG_BLKIO', blkio.found()) 2316if blkio.found() 2317 config_host_data.set('CONFIG_BLKIO_VHOST_VDPA_FD', 2318 blkio.version().version_compare('>=1.3.0')) 2319 config_host_data.set('CONFIG_BLKIO_WRITE_ZEROS_FUA', 2320 blkio.version().version_compare('>=1.4.0')) 2321endif 2322config_host_data.set('CONFIG_CURL', curl.found()) 2323config_host_data.set('CONFIG_CURSES', curses.found()) 2324config_host_data.set('CONFIG_GBM', gbm.found()) 2325config_host_data.set('CONFIG_GIO', gio.found()) 2326config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found()) 2327if glusterfs.found() 2328 config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().version_compare('>=4')) 2329 config_host_data.set('CONFIG_GLUSTERFS_DISCARD', glusterfs.version().version_compare('>=5')) 2330 config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().version_compare('>=6')) 2331 config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().version_compare('>=6')) 2332 config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat) 2333 config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat) 2334endif 2335config_host_data.set('CONFIG_GTK', gtk.found()) 2336config_host_data.set('CONFIG_VTE', vte.found()) 2337config_host_data.set('CONFIG_GTK_CLIPBOARD', have_gtk_clipboard) 2338config_host_data.set('CONFIG_HEXAGON_IDEF_PARSER', get_option('hexagon_idef_parser')) 2339config_host_data.set('CONFIG_LIBATTR', have_old_libattr) 2340config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found()) 2341config_host_data.set('CONFIG_EBPF', libbpf.found()) 2342config_host_data.set('CONFIG_AF_XDP', libxdp.found()) 2343config_host_data.set('CONFIG_LIBDAXCTL', libdaxctl.found()) 2344config_host_data.set('CONFIG_LIBISCSI', libiscsi.found()) 2345config_host_data.set('CONFIG_LIBNFS', libnfs.found()) 2346config_host_data.set('CONFIG_LIBSSH', libssh.found()) 2347config_host_data.set('CONFIG_LINUX_AIO', libaio.found()) 2348config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found()) 2349config_host_data.set('CONFIG_LIBPMEM', libpmem.found()) 2350config_host_data.set('CONFIG_MODULES', enable_modules) 2351config_host_data.set('CONFIG_NUMA', numa.found()) 2352if numa.found() 2353 config_host_data.set('HAVE_NUMA_HAS_PREFERRED_MANY', 2354 cc.has_function('numa_has_preferred_many', 2355 dependencies: numa)) 2356endif 2357config_host_data.set('CONFIG_OPENGL', opengl.found()) 2358config_host_data.set('CONFIG_PLUGIN', get_option('plugins')) 2359config_host_data.set('CONFIG_RBD', rbd.found()) 2360config_host_data.set('CONFIG_RDMA', rdma.found()) 2361config_host_data.set('CONFIG_RELOCATABLE', get_option('relocatable')) 2362config_host_data.set('CONFIG_SAFESTACK', get_option('safe_stack')) 2363config_host_data.set('CONFIG_SDL', sdl.found()) 2364config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found()) 2365config_host_data.set('CONFIG_SECCOMP', seccomp.found()) 2366if seccomp.found() 2367 config_host_data.set('CONFIG_SECCOMP_SYSRAWRC', seccomp_has_sysrawrc) 2368endif 2369config_host_data.set('CONFIG_PIXMAN', pixman.found()) 2370config_host_data.set('CONFIG_SLIRP', slirp.found()) 2371config_host_data.set('CONFIG_SNAPPY', snappy.found()) 2372config_host_data.set('CONFIG_SOLARIS', host_os == 'sunos') 2373if get_option('tcg').allowed() 2374 config_host_data.set('CONFIG_TCG', 1) 2375 config_host_data.set('CONFIG_TCG_INTERPRETER', tcg_arch == 'tci') 2376endif 2377config_host_data.set('CONFIG_TPM', have_tpm) 2378config_host_data.set('CONFIG_TSAN', get_option('tsan')) 2379config_host_data.set('CONFIG_USB_LIBUSB', libusb.found()) 2380config_host_data.set('CONFIG_VDE', vde.found()) 2381config_host_data.set('CONFIG_VHOST', have_vhost) 2382config_host_data.set('CONFIG_VHOST_NET', have_vhost_net) 2383config_host_data.set('CONFIG_VHOST_NET_USER', have_vhost_net_user) 2384config_host_data.set('CONFIG_VHOST_NET_VDPA', have_vhost_net_vdpa) 2385config_host_data.set('CONFIG_VHOST_KERNEL', have_vhost_kernel) 2386config_host_data.set('CONFIG_VHOST_USER', have_vhost_user) 2387config_host_data.set('CONFIG_VHOST_CRYPTO', have_vhost_user_crypto) 2388config_host_data.set('CONFIG_VHOST_VDPA', have_vhost_vdpa) 2389config_host_data.set('CONFIG_VMNET', vmnet.found()) 2390config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server) 2391config_host_data.set('CONFIG_VDUSE_BLK_EXPORT', have_vduse_blk_export) 2392config_host_data.set('CONFIG_PNG', png.found()) 2393config_host_data.set('CONFIG_VNC', vnc.found()) 2394config_host_data.set('CONFIG_VNC_JPEG', jpeg.found()) 2395config_host_data.set('CONFIG_VNC_SASL', sasl.found()) 2396if virgl.found() 2397 config_host_data.set('HAVE_VIRGL_D3D_INFO_EXT', 2398 cc.has_member('struct virgl_renderer_resource_info_ext', 'd3d_tex2d', 2399 prefix: '#include <virglrenderer.h>', 2400 dependencies: virgl)) 2401endif 2402config_host_data.set('CONFIG_VIRTFS', have_virtfs) 2403config_host_data.set('CONFIG_VTE', vte.found()) 2404config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found()) 2405config_host_data.set('CONFIG_KEYUTILS', keyutils.found()) 2406config_host_data.set('CONFIG_GETTID', has_gettid) 2407config_host_data.set('CONFIG_GNUTLS', gnutls.found()) 2408config_host_data.set('CONFIG_GNUTLS_CRYPTO', gnutls_crypto.found()) 2409config_host_data.set('CONFIG_TASN1', tasn1.found()) 2410config_host_data.set('CONFIG_GCRYPT', gcrypt.found()) 2411config_host_data.set('CONFIG_NETTLE', nettle.found()) 2412config_host_data.set('CONFIG_CRYPTO_SM4', crypto_sm4.found()) 2413config_host_data.set('CONFIG_HOGWEED', hogweed.found()) 2414config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts == 'private') 2415config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim) 2416config_host_data.set('CONFIG_STATX', has_statx) 2417config_host_data.set('CONFIG_STATX_MNT_ID', has_statx_mnt_id) 2418config_host_data.set('CONFIG_ZSTD', zstd.found()) 2419config_host_data.set('CONFIG_QPL', qpl.found()) 2420config_host_data.set('CONFIG_UADK', uadk.found()) 2421config_host_data.set('CONFIG_FUSE', fuse.found()) 2422config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found()) 2423config_host_data.set('CONFIG_SPICE_PROTOCOL', spice_protocol.found()) 2424if spice_protocol.found() 2425config_host_data.set('CONFIG_SPICE_PROTOCOL_MAJOR', spice_protocol.version().split('.')[0]) 2426config_host_data.set('CONFIG_SPICE_PROTOCOL_MINOR', spice_protocol.version().split('.')[1]) 2427config_host_data.set('CONFIG_SPICE_PROTOCOL_MICRO', spice_protocol.version().split('.')[2]) 2428endif 2429config_host_data.set('CONFIG_SPICE', spice.found()) 2430config_host_data.set('CONFIG_X11', x11.found()) 2431config_host_data.set('CONFIG_DBUS_DISPLAY', dbus_display) 2432config_host_data.set('CONFIG_CFI', get_option('cfi')) 2433config_host_data.set('CONFIG_SELINUX', selinux.found()) 2434config_host_data.set('CONFIG_XEN_BACKEND', xen.found()) 2435config_host_data.set('CONFIG_LIBDW', libdw.found()) 2436if xen.found() 2437 # protect from xen.version() having less than three components 2438 xen_version = xen.version().split('.') + ['0', '0'] 2439 xen_ctrl_version = xen_version[0] + \ 2440 ('0' + xen_version[1]).substring(-2) + \ 2441 ('0' + xen_version[2]).substring(-2) 2442 config_host_data.set('CONFIG_XEN_CTRL_INTERFACE_VERSION', xen_ctrl_version) 2443endif 2444config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version())) 2445config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0]) 2446config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1]) 2447config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2]) 2448 2449config_host_data.set_quoted('CONFIG_HOST_DSOSUF', host_dsosuf) 2450config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device) 2451 2452have_coroutine_pool = get_option('coroutine_pool') 2453if get_option('debug_stack_usage') and have_coroutine_pool 2454 message('Disabling coroutine pool to measure stack usage') 2455 have_coroutine_pool = false 2456endif 2457config_host_data.set('CONFIG_COROUTINE_POOL', have_coroutine_pool) 2458config_host_data.set('CONFIG_DEBUG_GRAPH_LOCK', get_option('debug_graph_lock')) 2459config_host_data.set('CONFIG_DEBUG_MUTEX', get_option('debug_mutex')) 2460config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_option('debug_stack_usage')) 2461config_host_data.set('CONFIG_DEBUG_TCG', get_option('debug_tcg')) 2462config_host_data.set('CONFIG_DEBUG_REMAP', get_option('debug_remap')) 2463config_host_data.set('CONFIG_QOM_CAST_DEBUG', get_option('qom_cast_debug')) 2464config_host_data.set('CONFIG_REPLICATION', get_option('replication').allowed()) 2465config_host_data.set('CONFIG_FSFREEZE', qga_fsfreeze) 2466config_host_data.set('CONFIG_FSTRIM', qga_fstrim) 2467 2468# has_header 2469config_host_data.set('CONFIG_EPOLL', cc.has_header('sys/epoll.h')) 2470config_host_data.set('CONFIG_LINUX_MAGIC_H', cc.has_header('linux/magic.h')) 2471config_host_data.set('CONFIG_VALGRIND_H', cc.has_header('valgrind/valgrind.h')) 2472config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h')) 2473config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h')) 2474config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h')) 2475config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h')) 2476config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) 2477config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) 2478if host_os == 'windows' 2479 config_host_data.set('HAVE_AFUNIX_H', cc.has_header('afunix.h')) 2480endif 2481 2482# has_function 2483config_host_data.set('CONFIG_CLOSE_RANGE', cc.has_function('close_range')) 2484config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4')) 2485config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime')) 2486config_host_data.set('CONFIG_DUP3', cc.has_function('dup3')) 2487config_host_data.set('CONFIG_FALLOCATE', cc.has_function('fallocate')) 2488config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate')) 2489config_host_data.set('CONFIG_GETCPU', cc.has_function('getcpu', prefix: gnu_source_prefix)) 2490config_host_data.set('CONFIG_SCHED_GETCPU', cc.has_function('sched_getcpu', prefix: '#include <sched.h>')) 2491# Note that we need to specify prefix: here to avoid incorrectly 2492# thinking that Windows has posix_memalign() 2493config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include <stdlib.h>')) 2494config_host_data.set('CONFIG_ALIGNED_MALLOC', cc.has_function('_aligned_malloc')) 2495config_host_data.set('CONFIG_VALLOC', cc.has_function('valloc')) 2496config_host_data.set('CONFIG_MEMALIGN', cc.has_function('memalign')) 2497config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll')) 2498config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>')) 2499config_host_data.set('CONFIG_PTHREAD_FCHDIR_NP', cc.has_function('pthread_fchdir_np')) 2500config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile')) 2501config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare')) 2502config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs')) 2503config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range')) 2504config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create')) 2505config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range')) 2506config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs')) 2507config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice) 2508config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util)) 2509config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul')) 2510config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>')) 2511if rbd.found() 2512 config_host_data.set('HAVE_RBD_NAMESPACE_EXISTS', 2513 cc.has_function('rbd_namespace_exists', 2514 dependencies: rbd, 2515 prefix: '#include <rbd/librbd.h>')) 2516endif 2517if rdma.found() 2518 config_host_data.set('HAVE_IBV_ADVISE_MR', 2519 cc.has_function('ibv_advise_mr', 2520 dependencies: rdma, 2521 prefix: '#include <infiniband/verbs.h>')) 2522endif 2523 2524have_asan_fiber = false 2525if get_option('sanitizers') and \ 2526 not cc.has_function('__sanitizer_start_switch_fiber', 2527 args: '-fsanitize=address', 2528 prefix: '#include <sanitizer/asan_interface.h>') 2529 warning('Missing ASAN due to missing fiber annotation interface') 2530 warning('Without code annotation, the report may be inferior.') 2531else 2532 have_asan_fiber = true 2533endif 2534config_host_data.set('CONFIG_ASAN_IFACE_FIBER', have_asan_fiber) 2535 2536have_inotify_init = cc.has_header_symbol('sys/inotify.h', 'inotify_init') 2537have_inotify_init1 = cc.has_header_symbol('sys/inotify.h', 'inotify_init1') 2538inotify = not_found 2539if (have_inotify_init or have_inotify_init1) and host_os == 'freebsd' 2540 # libinotify-kqueue 2541 inotify = cc.find_library('inotify') 2542 if have_inotify_init 2543 have_inotify_init = inotify.found() 2544 endif 2545 if have_inotify_init1 2546 have_inotify_init1 = inotify.found() 2547 endif 2548endif 2549config_host_data.set('CONFIG_INOTIFY', have_inotify_init) 2550config_host_data.set('CONFIG_INOTIFY1', have_inotify_init1) 2551 2552# has_header_symbol 2553config_host_data.set('CONFIG_BLKZONED', 2554 cc.has_header_symbol('linux/blkzoned.h', 'BLKOPENZONE')) 2555config_host_data.set('CONFIG_EPOLL_CREATE1', 2556 cc.has_header_symbol('sys/epoll.h', 'epoll_create1')) 2557config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE', 2558 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_PUNCH_HOLE') and 2559 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_KEEP_SIZE')) 2560config_host_data.set('CONFIG_FALLOCATE_ZERO_RANGE', 2561 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_ZERO_RANGE')) 2562config_host_data.set('CONFIG_FIEMAP', 2563 cc.has_header('linux/fiemap.h') and 2564 cc.has_header_symbol('linux/fs.h', 'FS_IOC_FIEMAP')) 2565config_host_data.set('CONFIG_GETRANDOM', 2566 cc.has_function('getrandom') and 2567 cc.has_header_symbol('sys/random.h', 'GRND_NONBLOCK')) 2568config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK', 2569 cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK')) 2570config_host_data.set('CONFIG_RTNETLINK', 2571 cc.has_header_symbol('linux/rtnetlink.h', 'IFLA_PROTO_DOWN')) 2572config_host_data.set('CONFIG_SYSMACROS', 2573 cc.has_header_symbol('sys/sysmacros.h', 'makedev')) 2574config_host_data.set('HAVE_OPTRESET', 2575 cc.has_header_symbol('getopt.h', 'optreset')) 2576config_host_data.set('HAVE_IPPROTO_MPTCP', 2577 cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP')) 2578 2579# has_member 2580config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID', 2581 cc.has_member('struct sigevent', 'sigev_notify_thread_id', 2582 prefix: '#include <signal.h>')) 2583config_host_data.set('HAVE_STRUCT_STAT_ST_ATIM', 2584 cc.has_member('struct stat', 'st_atim', 2585 prefix: '#include <sys/stat.h>')) 2586config_host_data.set('HAVE_BLK_ZONE_REP_CAPACITY', 2587 cc.has_member('struct blk_zone', 'capacity', 2588 prefix: '#include <linux/blkzoned.h>')) 2589 2590# has_type 2591config_host_data.set('CONFIG_IOVEC', 2592 cc.has_type('struct iovec', 2593 prefix: '#include <sys/uio.h>')) 2594config_host_data.set('HAVE_UTMPX', 2595 cc.has_type('struct utmpx', 2596 prefix: '#include <utmpx.h>')) 2597 2598config_host_data.set('CONFIG_EVENTFD', cc.links(''' 2599 #include <sys/eventfd.h> 2600 int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }''')) 2601config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + ''' 2602 #include <unistd.h> 2603 int main(void) { 2604 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0 2605 return fdatasync(0); 2606 #else 2607 #error Not supported 2608 #endif 2609 }''')) 2610 2611has_madvise = cc.links(gnu_source_prefix + ''' 2612 #include <sys/types.h> 2613 #include <sys/mman.h> 2614 #include <stddef.h> 2615 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }''') 2616missing_madvise_proto = false 2617if has_madvise 2618 # Some platforms (illumos and Solaris before Solaris 11) provide madvise() 2619 # but forget to prototype it. In this case, has_madvise will be true (the 2620 # test program links despite a compile warning). To detect the 2621 # missing-prototype case, we try again with a definitely-bogus prototype. 2622 # This will only compile if the system headers don't provide the prototype; 2623 # otherwise the conflicting prototypes will cause a compiler error. 2624 missing_madvise_proto = cc.links(gnu_source_prefix + ''' 2625 #include <sys/types.h> 2626 #include <sys/mman.h> 2627 #include <stddef.h> 2628 extern int madvise(int); 2629 int main(void) { return madvise(0); }''') 2630endif 2631config_host_data.set('CONFIG_MADVISE', has_madvise) 2632config_host_data.set('HAVE_MADVISE_WITHOUT_PROTOTYPE', missing_madvise_proto) 2633 2634config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + ''' 2635 #include <sys/mman.h> 2636 int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }''')) 2637config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + ''' 2638 #include <fcntl.h> 2639 #if !defined(AT_EMPTY_PATH) 2640 # error missing definition 2641 #else 2642 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); } 2643 #endif''')) 2644 2645# On Darwin posix_madvise() has the same return semantics as plain madvise(), 2646# i.e. errno is set and -1 is returned. That's not really how POSIX defines the 2647# function. On the flip side, it has madvise() which is preferred anyways. 2648if host_os != 'darwin' 2649 config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + ''' 2650 #include <sys/mman.h> 2651 #include <stddef.h> 2652 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }''')) 2653endif 2654 2655config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(gnu_source_prefix + ''' 2656 #include <pthread.h> 2657 2658 static void *f(void *p) { return NULL; } 2659 int main(void) 2660 { 2661 pthread_t thread; 2662 pthread_create(&thread, 0, f, 0); 2663 pthread_setname_np(thread, "QEMU"); 2664 return 0; 2665 }''', dependencies: threads)) 2666config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_prefix + ''' 2667 #include <pthread.h> 2668 2669 static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; } 2670 int main(void) 2671 { 2672 pthread_t thread; 2673 pthread_create(&thread, 0, f, 0); 2674 return 0; 2675 }''', dependencies: threads)) 2676config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(gnu_source_prefix + ''' 2677 #include <pthread.h> 2678 #include <pthread_np.h> 2679 2680 static void *f(void *p) { return NULL; } 2681 int main(void) 2682 { 2683 pthread_t thread; 2684 pthread_create(&thread, 0, f, 0); 2685 pthread_set_name_np(thread, "QEMU"); 2686 return 0; 2687 }''', dependencies: threads)) 2688config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(gnu_source_prefix + ''' 2689 #include <pthread.h> 2690 #include <time.h> 2691 2692 int main(void) 2693 { 2694 pthread_condattr_t attr 2695 pthread_condattr_init(&attr); 2696 pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); 2697 return 0; 2698 }''', dependencies: threads)) 2699config_host_data.set('CONFIG_PTHREAD_AFFINITY_NP', cc.links(gnu_source_prefix + ''' 2700 #include <pthread.h> 2701 2702 static void *f(void *p) { return NULL; } 2703 int main(void) 2704 { 2705 int setsize = CPU_ALLOC_SIZE(64); 2706 pthread_t thread; 2707 cpu_set_t *cpuset; 2708 pthread_create(&thread, 0, f, 0); 2709 cpuset = CPU_ALLOC(64); 2710 CPU_ZERO_S(setsize, cpuset); 2711 pthread_setaffinity_np(thread, setsize, cpuset); 2712 pthread_getaffinity_np(thread, setsize, cpuset); 2713 CPU_FREE(cpuset); 2714 return 0; 2715 }''', dependencies: threads)) 2716config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + ''' 2717 #include <sys/signalfd.h> 2718 #include <stddef.h> 2719 int main(void) { return signalfd(-1, NULL, SFD_CLOEXEC); }''')) 2720config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + ''' 2721 #include <unistd.h> 2722 #include <fcntl.h> 2723 #include <limits.h> 2724 2725 int main(void) 2726 { 2727 int len, fd = 0; 2728 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK); 2729 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE); 2730 return 0; 2731 }''')) 2732 2733config_host_data.set('HAVE_MLOCKALL', cc.links(gnu_source_prefix + ''' 2734 #include <sys/mman.h> 2735 int main(void) { 2736 return mlockall(MCL_FUTURE); 2737 }''')) 2738 2739have_l2tpv3 = false 2740if get_option('l2tpv3').allowed() and have_system 2741 have_l2tpv3 = cc.has_type('struct mmsghdr', 2742 prefix: gnu_source_prefix + ''' 2743 #include <sys/socket.h> 2744 #include <linux/ip.h>''') 2745endif 2746config_host_data.set('CONFIG_L2TPV3', have_l2tpv3) 2747 2748have_netmap = false 2749if get_option('netmap').allowed() and have_system 2750 have_netmap = cc.compiles(''' 2751 #include <inttypes.h> 2752 #include <net/if.h> 2753 #include <net/netmap.h> 2754 #include <net/netmap_user.h> 2755 #if (NETMAP_API < 11) || (NETMAP_API > 15) 2756 #error 2757 #endif 2758 int main(void) { return 0; }''') 2759 if not have_netmap and get_option('netmap').enabled() 2760 error('Netmap headers not available') 2761 endif 2762endif 2763config_host_data.set('CONFIG_NETMAP', have_netmap) 2764 2765# Work around a system header bug with some kernel/XFS header 2766# versions where they both try to define 'struct fsxattr': 2767# xfs headers will not try to redefine structs from linux headers 2768# if this macro is set. 2769config_host_data.set('HAVE_FSXATTR', cc.links(''' 2770 #include <linux/fs.h> 2771 struct fsxattr foo; 2772 int main(void) { 2773 return 0; 2774 }''')) 2775 2776# Some versions of Mac OS X incorrectly define SIZE_MAX 2777config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles(''' 2778 #include <stdint.h> 2779 #include <stdio.h> 2780 int main(void) { 2781 return printf("%zu", SIZE_MAX); 2782 }''', args: ['-Werror'])) 2783 2784# See if 64-bit atomic operations are supported. 2785# Note that without __atomic builtins, we can only 2786# assume atomic loads/stores max at pointer size. 2787config_host_data.set('CONFIG_ATOMIC64', cc.links(''' 2788 #include <stdint.h> 2789 int main(void) 2790 { 2791 uint64_t x = 0, y = 0; 2792 y = __atomic_load_n(&x, __ATOMIC_RELAXED); 2793 __atomic_store_n(&x, y, __ATOMIC_RELAXED); 2794 __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED); 2795 __atomic_exchange_n(&x, y, __ATOMIC_RELAXED); 2796 __atomic_fetch_add(&x, y, __ATOMIC_RELAXED); 2797 return 0; 2798 }''', args: qemu_isa_flags)) 2799 2800has_int128_type = cc.compiles(''' 2801 __int128_t a; 2802 __uint128_t b; 2803 int main(void) { b = a; }''') 2804config_host_data.set('CONFIG_INT128_TYPE', has_int128_type) 2805 2806has_int128 = has_int128_type and cc.links(''' 2807 __int128_t a; 2808 __uint128_t b; 2809 int main (void) { 2810 a = a + b; 2811 b = a * b; 2812 a = a * a; 2813 return 0; 2814 }''') 2815config_host_data.set('CONFIG_INT128', has_int128) 2816 2817if has_int128_type 2818 # "do we have 128-bit atomics which are handled inline and specifically not 2819 # via libatomic". The reason we can't use libatomic is documented in the 2820 # comment starting "GCC is a house divided" in include/qemu/atomic128.h. 2821 # We only care about these operations on 16-byte aligned pointers, so 2822 # force 16-byte alignment of the pointer, which may be greater than 2823 # __alignof(unsigned __int128) for the host. 2824 atomic_test_128 = ''' 2825 int main(int ac, char **av) { 2826 __uint128_t *p = __builtin_assume_aligned(av[ac - 1], 16); 2827 p[1] = __atomic_load_n(&p[0], __ATOMIC_RELAXED); 2828 __atomic_store_n(&p[2], p[3], __ATOMIC_RELAXED); 2829 __atomic_compare_exchange_n(&p[4], &p[5], p[6], 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED); 2830 return 0; 2831 }''' 2832 has_atomic128 = cc.links(atomic_test_128, args: qemu_isa_flags) 2833 2834 config_host_data.set('CONFIG_ATOMIC128', has_atomic128) 2835 2836 if not has_atomic128 2837 # Even with __builtin_assume_aligned, the above test may have failed 2838 # without optimization enabled. Try again with optimizations locally 2839 # enabled for the function. See 2840 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107389 2841 has_atomic128_opt = cc.links('__attribute__((optimize("O1")))' + atomic_test_128, 2842 args: qemu_isa_flags) 2843 config_host_data.set('CONFIG_ATOMIC128_OPT', has_atomic128_opt) 2844 2845 if not has_atomic128_opt 2846 config_host_data.set('CONFIG_CMPXCHG128', cc.links(''' 2847 int main(void) 2848 { 2849 __uint128_t x = 0, y = 0; 2850 __sync_val_compare_and_swap_16(&x, y, x); 2851 return 0; 2852 } 2853 ''', args: qemu_isa_flags)) 2854 endif 2855 endif 2856endif 2857 2858config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + ''' 2859 #include <sys/auxv.h> 2860 int main(void) { 2861 return getauxval(AT_HWCAP) == 0; 2862 }''')) 2863 2864config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(gnu_source_prefix + ''' 2865 #include <sys/auxv.h> 2866 int main(void) { 2867 unsigned long hwcap = 0; 2868 elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); 2869 return hwcap; 2870 }''')) 2871 2872config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles(''' 2873 #include <linux/usbdevice_fs.h> 2874 2875 #ifndef USBDEVFS_GET_CAPABILITIES 2876 #error "USBDEVFS_GET_CAPABILITIES undefined" 2877 #endif 2878 2879 #ifndef USBDEVFS_DISCONNECT_CLAIM 2880 #error "USBDEVFS_DISCONNECT_CLAIM undefined" 2881 #endif 2882 2883 int main(void) { return 0; }''')) 2884 2885have_keyring = get_option('keyring') \ 2886 .require(host_os == 'linux', error_message: 'keyring is only available on Linux') \ 2887 .require(cc.compiles(''' 2888 #include <errno.h> 2889 #include <asm/unistd.h> 2890 #include <linux/keyctl.h> 2891 #include <sys/syscall.h> 2892 #include <unistd.h> 2893 int main(void) { 2894 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0); 2895 }'''), error_message: 'keyctl syscall not available on this system').allowed() 2896config_host_data.set('CONFIG_SECRET_KEYRING', have_keyring) 2897 2898have_cpuid_h = cc.links(''' 2899 #include <cpuid.h> 2900 int main(void) { 2901 unsigned a, b, c, d; 2902 unsigned max = __get_cpuid_max(0, 0); 2903 2904 if (max >= 1) { 2905 __cpuid(1, a, b, c, d); 2906 } 2907 2908 if (max >= 7) { 2909 __cpuid_count(7, 0, a, b, c, d); 2910 } 2911 2912 return 0; 2913 }''') 2914config_host_data.set('CONFIG_CPUID_H', have_cpuid_h) 2915 2916# Don't bother to advertise asm/hwprobe.h for old versions that do 2917# not contain RISCV_HWPROBE_EXT_ZBA. 2918config_host_data.set('CONFIG_ASM_HWPROBE_H', 2919 cc.has_header_symbol('asm/hwprobe.h', 2920 'RISCV_HWPROBE_EXT_ZBA')) 2921 2922config_host_data.set('CONFIG_AVX2_OPT', get_option('avx2') \ 2923 .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX2') \ 2924 .require(cc.links(''' 2925 #include <cpuid.h> 2926 #include <immintrin.h> 2927 static int __attribute__((target("avx2"))) bar(void *a) { 2928 __m256i x = *(__m256i *)a; 2929 return _mm256_testz_si256(x, x); 2930 } 2931 int main(int argc, char *argv[]) { return bar(argv[argc - 1]); } 2932 '''), error_message: 'AVX2 not available').allowed()) 2933 2934config_host_data.set('CONFIG_AVX512BW_OPT', get_option('avx512bw') \ 2935 .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512BW') \ 2936 .require(cc.links(''' 2937 #include <cpuid.h> 2938 #include <immintrin.h> 2939 static int __attribute__((target("avx512bw"))) bar(void *a) { 2940 __m512i *x = a; 2941 __m512i res= _mm512_abs_epi8(*x); 2942 return res[1]; 2943 } 2944 int main(int argc, char *argv[]) { return bar(argv[0]); } 2945 '''), error_message: 'AVX512BW not available').allowed()) 2946 2947# For both AArch64 and AArch32, detect if builtins are available. 2948config_host_data.set('CONFIG_ARM_AES_BUILTIN', cc.compiles(''' 2949 #include <arm_neon.h> 2950 #ifndef __ARM_FEATURE_AES 2951 __attribute__((target("+crypto"))) 2952 #endif 2953 void foo(uint8x16_t *p) { *p = vaesmcq_u8(*p); } 2954 ''')) 2955 2956if get_option('membarrier').disabled() 2957 have_membarrier = false 2958elif host_os == 'windows' 2959 have_membarrier = true 2960elif host_os == 'linux' 2961 have_membarrier = cc.compiles(''' 2962 #include <linux/membarrier.h> 2963 #include <sys/syscall.h> 2964 #include <unistd.h> 2965 #include <stdlib.h> 2966 int main(void) { 2967 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0); 2968 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0); 2969 exit(0); 2970 }''') 2971endif 2972config_host_data.set('CONFIG_MEMBARRIER', get_option('membarrier') \ 2973 .require(have_membarrier, error_message: 'membarrier system call not available') \ 2974 .allowed()) 2975 2976have_afalg = get_option('crypto_afalg') \ 2977 .require(cc.compiles(gnu_source_prefix + ''' 2978 #include <errno.h> 2979 #include <sys/types.h> 2980 #include <sys/socket.h> 2981 #include <linux/if_alg.h> 2982 int main(void) { 2983 int sock; 2984 sock = socket(AF_ALG, SOCK_SEQPACKET, 0); 2985 return sock; 2986 } 2987 '''), error_message: 'AF_ALG requested but could not be detected').allowed() 2988config_host_data.set('CONFIG_AF_ALG', have_afalg) 2989 2990config_host_data.set('CONFIG_AF_VSOCK', cc.has_header_symbol( 2991 'linux/vm_sockets.h', 'AF_VSOCK', 2992 prefix: '#include <sys/socket.h>', 2993)) 2994 2995have_vss = false 2996have_vss_sdk = false # old xp/2003 SDK 2997if host_os == 'windows' and 'cpp' in all_languages 2998 have_vss = cxx.compiles(''' 2999 #define __MIDL_user_allocate_free_DEFINED__ 3000 #include <vss.h> 3001 int main(void) { return VSS_CTX_BACKUP; }''') 3002 have_vss_sdk = cxx.has_header('vscoordint.h') 3003endif 3004config_host_data.set('HAVE_VSS_SDK', have_vss_sdk) 3005 3006# Older versions of MinGW do not import _lock_file and _unlock_file properly. 3007# This was fixed for v6.0.0 with commit b48e3ac8969d. 3008if host_os == 'windows' 3009 config_host_data.set('HAVE__LOCK_FILE', cc.links(''' 3010 #include <stdio.h> 3011 int main(void) { 3012 _lock_file(NULL); 3013 _unlock_file(NULL); 3014 return 0; 3015 }''', name: '_lock_file and _unlock_file')) 3016endif 3017 3018if host_os == 'windows' 3019 mingw_has_setjmp_longjmp = cc.links(''' 3020 #include <setjmp.h> 3021 int main(void) { 3022 /* 3023 * These functions are not available in setjmp header, but may be 3024 * available at link time, from libmingwex.a. 3025 */ 3026 extern int __mingw_setjmp(jmp_buf); 3027 extern void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int); 3028 jmp_buf env; 3029 __mingw_setjmp(env); 3030 __mingw_longjmp(env, 0); 3031 } 3032 ''', name: 'mingw setjmp and longjmp') 3033 3034 if cpu == 'aarch64' and not mingw_has_setjmp_longjmp 3035 error('mingw must provide setjmp/longjmp for windows-arm64') 3036 endif 3037endif 3038 3039######################## 3040# Target configuration # 3041######################## 3042 3043minikconf = find_program('scripts/minikconf.py') 3044 3045config_all_accel = {} 3046config_all_devices = {} 3047config_devices_mak_list = [] 3048config_devices_h = {} 3049config_target_h = {} 3050config_target_mak = {} 3051 3052disassemblers = { 3053 'alpha' : ['CONFIG_ALPHA_DIS'], 3054 'avr' : ['CONFIG_AVR_DIS'], 3055 'cris' : ['CONFIG_CRIS_DIS'], 3056 'hexagon' : ['CONFIG_HEXAGON_DIS'], 3057 'hppa' : ['CONFIG_HPPA_DIS'], 3058 'i386' : ['CONFIG_I386_DIS'], 3059 'x86_64' : ['CONFIG_I386_DIS'], 3060 'm68k' : ['CONFIG_M68K_DIS'], 3061 'microblaze' : ['CONFIG_MICROBLAZE_DIS'], 3062 'mips' : ['CONFIG_MIPS_DIS'], 3063 'or1k' : ['CONFIG_OPENRISC_DIS'], 3064 'ppc' : ['CONFIG_PPC_DIS'], 3065 'riscv' : ['CONFIG_RISCV_DIS'], 3066 'rx' : ['CONFIG_RX_DIS'], 3067 's390' : ['CONFIG_S390_DIS'], 3068 'sh4' : ['CONFIG_SH4_DIS'], 3069 'sparc' : ['CONFIG_SPARC_DIS'], 3070 'xtensa' : ['CONFIG_XTENSA_DIS'], 3071 'loongarch' : ['CONFIG_LOONGARCH_DIS'], 3072} 3073 3074have_ivshmem = config_host_data.get('CONFIG_EVENTFD') 3075host_kconfig = \ 3076 (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \ 3077 (have_tpm ? ['CONFIG_TPM=y'] : []) + \ 3078 (pixman.found() ? ['CONFIG_PIXMAN=y'] : []) + \ 3079 (spice.found() ? ['CONFIG_SPICE=y'] : []) + \ 3080 (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \ 3081 (opengl.found() ? ['CONFIG_OPENGL=y'] : []) + \ 3082 (x11.found() ? ['CONFIG_X11=y'] : []) + \ 3083 (fdt.found() ? ['CONFIG_FDT=y'] : []) + \ 3084 (have_vhost_user ? ['CONFIG_VHOST_USER=y'] : []) + \ 3085 (have_vhost_vdpa ? ['CONFIG_VHOST_VDPA=y'] : []) + \ 3086 (have_vhost_kernel ? ['CONFIG_VHOST_KERNEL=y'] : []) + \ 3087 (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \ 3088 (host_os == 'linux' ? ['CONFIG_LINUX=y'] : []) + \ 3089 (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : []) + \ 3090 (vfio_user_server_allowed ? ['CONFIG_VFIO_USER_SERVER_ALLOWED=y'] : []) + \ 3091 (hv_balloon ? ['CONFIG_HV_BALLOON_POSSIBLE=y'] : []) 3092 3093ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ] 3094 3095default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host 3096actual_target_dirs = [] 3097fdt_required = [] 3098foreach target : target_dirs 3099 config_target = { 'TARGET_NAME': target.split('-')[0] } 3100 if target.endswith('linux-user') 3101 if host_os != 'linux' 3102 if default_targets 3103 continue 3104 endif 3105 error('Target @0@ is only available on a Linux host'.format(target)) 3106 endif 3107 config_target += { 'CONFIG_LINUX_USER': 'y' } 3108 elif target.endswith('bsd-user') 3109 if host_os not in bsd_oses 3110 if default_targets 3111 continue 3112 endif 3113 error('Target @0@ is only available on a BSD host'.format(target)) 3114 endif 3115 config_target += { 'CONFIG_BSD_USER': 'y' } 3116 elif target.endswith('softmmu') 3117 config_target += { 'CONFIG_SYSTEM_ONLY': 'y' } 3118 config_target += { 'CONFIG_SOFTMMU': 'y' } 3119 endif 3120 if target.endswith('-user') 3121 config_target += { 3122 'CONFIG_USER_ONLY': 'y', 3123 'CONFIG_QEMU_INTERP_PREFIX': 3124 get_option('interp_prefix').replace('%M', config_target['TARGET_NAME']) 3125 } 3126 endif 3127 3128 target_kconfig = [] 3129 foreach sym: accelerators 3130 if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, []) 3131 config_target += { sym: 'y' } 3132 config_all_accel += { sym: 'y' } 3133 if target in modular_tcg 3134 config_target += { 'CONFIG_TCG_MODULAR': 'y' } 3135 else 3136 config_target += { 'CONFIG_TCG_BUILTIN': 'y' } 3137 endif 3138 target_kconfig += [ sym + '=y' ] 3139 endif 3140 endforeach 3141 if target_kconfig.length() == 0 3142 if default_targets 3143 continue 3144 endif 3145 error('No accelerator available for target @0@'.format(target)) 3146 endif 3147 3148 config_target += keyval.load('configs/targets' / target + '.mak') 3149 config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' } 3150 3151 if 'TARGET_NEED_FDT' in config_target and not fdt.found() 3152 if default_targets 3153 warning('Disabling ' + target + ' due to missing libfdt') 3154 else 3155 fdt_required += target 3156 endif 3157 continue 3158 endif 3159 3160 actual_target_dirs += target 3161 3162 # Add default keys 3163 if 'TARGET_BASE_ARCH' not in config_target 3164 config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']} 3165 endif 3166 if 'TARGET_ABI_DIR' not in config_target 3167 config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']} 3168 endif 3169 if 'TARGET_BIG_ENDIAN' not in config_target 3170 config_target += {'TARGET_BIG_ENDIAN': 'n'} 3171 endif 3172 3173 foreach k, v: disassemblers 3174 if host_arch.startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k) 3175 foreach sym: v 3176 config_target += { sym: 'y' } 3177 endforeach 3178 endif 3179 endforeach 3180 3181 config_target_data = configuration_data() 3182 foreach k, v: config_target 3183 if not k.startswith('TARGET_') and not k.startswith('CONFIG_') 3184 # do nothing 3185 elif ignored.contains(k) 3186 # do nothing 3187 elif k == 'TARGET_BASE_ARCH' 3188 # Note that TARGET_BASE_ARCH ends up in config-target.h but it is 3189 # not used to select files from sourcesets. 3190 config_target_data.set('TARGET_' + v.to_upper(), 1) 3191 elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX' 3192 config_target_data.set_quoted(k, v) 3193 elif v == 'y' 3194 config_target_data.set(k, 1) 3195 elif v == 'n' 3196 config_target_data.set(k, 0) 3197 else 3198 config_target_data.set(k, v) 3199 endif 3200 endforeach 3201 config_target_data.set('QEMU_ARCH', 3202 'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper()) 3203 config_target_h += {target: configure_file(output: target + '-config-target.h', 3204 configuration: config_target_data)} 3205 3206 if target.endswith('-softmmu') 3207 target_kconfig += 'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y' 3208 target_kconfig += 'CONFIG_TARGET_BIG_ENDIAN=' + config_target['TARGET_BIG_ENDIAN'] 3209 3210 config_input = meson.get_external_property(target, 'default') 3211 config_devices_mak = target + '-config-devices.mak' 3212 config_devices_mak = configure_file( 3213 input: ['configs/devices' / target / config_input + '.mak', 'Kconfig'], 3214 output: config_devices_mak, 3215 depfile: config_devices_mak + '.d', 3216 capture: true, 3217 command: [minikconf, 3218 get_option('default_devices') ? '--defconfig' : '--allnoconfig', 3219 config_devices_mak, '@DEPFILE@', '@INPUT@', 3220 host_kconfig, target_kconfig]) 3221 3222 config_devices_data = configuration_data() 3223 config_devices = keyval.load(config_devices_mak) 3224 foreach k, v: config_devices 3225 config_devices_data.set(k, 1) 3226 endforeach 3227 config_devices_mak_list += config_devices_mak 3228 config_devices_h += {target: configure_file(output: target + '-config-devices.h', 3229 configuration: config_devices_data)} 3230 config_target += config_devices 3231 config_all_devices += config_devices 3232 endif 3233 config_target_mak += {target: config_target} 3234endforeach 3235target_dirs = actual_target_dirs 3236 3237target_configs_h = [] 3238foreach target: target_dirs 3239 target_configs_h += config_target_h[target] 3240 target_configs_h += config_devices_h.get(target, []) 3241endforeach 3242genh += custom_target('config-poison.h', 3243 input: [target_configs_h], 3244 output: 'config-poison.h', 3245 capture: true, 3246 command: [find_program('scripts/make-config-poison.sh'), 3247 target_configs_h]) 3248 3249if fdt_required.length() > 0 3250 error('fdt disabled but required by targets ' + ', '.join(fdt_required)) 3251endif 3252 3253############### 3254# Subprojects # 3255############### 3256 3257libvfio_user_dep = not_found 3258if have_system and vfio_user_server_allowed 3259 libvfio_user_proj = subproject('libvfio-user', required: true) 3260 libvfio_user_dep = libvfio_user_proj.get_variable('libvfio_user_dep') 3261endif 3262 3263vhost_user = not_found 3264if host_os == 'linux' and have_vhost_user 3265 libvhost_user = subproject('libvhost-user') 3266 vhost_user = libvhost_user.get_variable('vhost_user_dep') 3267endif 3268 3269libvduse = not_found 3270if have_libvduse 3271 libvduse_proj = subproject('libvduse') 3272 libvduse = libvduse_proj.get_variable('libvduse_dep') 3273endif 3274 3275##################### 3276# Generated sources # 3277##################### 3278 3279genh += configure_file(output: 'config-host.h', configuration: config_host_data) 3280 3281hxtool = find_program('scripts/hxtool') 3282shaderinclude = find_program('scripts/shaderinclude.py') 3283qapi_gen = find_program('scripts/qapi-gen.py') 3284qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py', 3285 meson.current_source_dir() / 'scripts/qapi/commands.py', 3286 meson.current_source_dir() / 'scripts/qapi/common.py', 3287 meson.current_source_dir() / 'scripts/qapi/error.py', 3288 meson.current_source_dir() / 'scripts/qapi/events.py', 3289 meson.current_source_dir() / 'scripts/qapi/expr.py', 3290 meson.current_source_dir() / 'scripts/qapi/gen.py', 3291 meson.current_source_dir() / 'scripts/qapi/introspect.py', 3292 meson.current_source_dir() / 'scripts/qapi/main.py', 3293 meson.current_source_dir() / 'scripts/qapi/parser.py', 3294 meson.current_source_dir() / 'scripts/qapi/schema.py', 3295 meson.current_source_dir() / 'scripts/qapi/source.py', 3296 meson.current_source_dir() / 'scripts/qapi/types.py', 3297 meson.current_source_dir() / 'scripts/qapi/visit.py', 3298 meson.current_source_dir() / 'scripts/qapi-gen.py' 3299] 3300 3301tracetool = [ 3302 python, files('scripts/tracetool.py'), 3303 '--backend=' + ','.join(get_option('trace_backends')) 3304] 3305tracetool_depends = files( 3306 'scripts/tracetool/backend/log.py', 3307 'scripts/tracetool/backend/__init__.py', 3308 'scripts/tracetool/backend/dtrace.py', 3309 'scripts/tracetool/backend/ftrace.py', 3310 'scripts/tracetool/backend/simple.py', 3311 'scripts/tracetool/backend/syslog.py', 3312 'scripts/tracetool/backend/ust.py', 3313 'scripts/tracetool/format/ust_events_c.py', 3314 'scripts/tracetool/format/ust_events_h.py', 3315 'scripts/tracetool/format/__init__.py', 3316 'scripts/tracetool/format/d.py', 3317 'scripts/tracetool/format/simpletrace_stap.py', 3318 'scripts/tracetool/format/c.py', 3319 'scripts/tracetool/format/h.py', 3320 'scripts/tracetool/format/log_stap.py', 3321 'scripts/tracetool/format/stap.py', 3322 'scripts/tracetool/__init__.py', 3323) 3324 3325qemu_version_cmd = [find_program('scripts/qemu-version.sh'), 3326 meson.current_source_dir(), 3327 get_option('pkgversion'), meson.project_version()] 3328qemu_version = custom_target('qemu-version.h', 3329 output: 'qemu-version.h', 3330 command: qemu_version_cmd, 3331 capture: true, 3332 build_by_default: true, 3333 build_always_stale: true) 3334genh += qemu_version 3335 3336hxdep = [] 3337hx_headers = [ 3338 ['qemu-options.hx', 'qemu-options.def'], 3339 ['qemu-img-cmds.hx', 'qemu-img-cmds.h'], 3340] 3341if have_system 3342 hx_headers += [ 3343 ['hmp-commands.hx', 'hmp-commands.h'], 3344 ['hmp-commands-info.hx', 'hmp-commands-info.h'], 3345 ] 3346endif 3347foreach d : hx_headers 3348 hxdep += custom_target(d[1], 3349 input: files(d[0]), 3350 output: d[1], 3351 capture: true, 3352 command: [hxtool, '-h', '@INPUT0@']) 3353endforeach 3354genh += hxdep 3355 3356############### 3357# Trace files # 3358############### 3359 3360# TODO: add each directory to the subdirs from its own meson.build, once 3361# we have those 3362trace_events_subdirs = [ 3363 'crypto', 3364 'qapi', 3365 'qom', 3366 'monitor', 3367 'util', 3368 'gdbstub', 3369] 3370if have_linux_user 3371 trace_events_subdirs += [ 'linux-user' ] 3372endif 3373if have_bsd_user 3374 trace_events_subdirs += [ 'bsd-user' ] 3375endif 3376if have_block 3377 trace_events_subdirs += [ 3378 'authz', 3379 'block', 3380 'chardev', 3381 'io', 3382 'nbd', 3383 'scsi', 3384 ] 3385endif 3386if have_system 3387 trace_events_subdirs += [ 3388 'accel/kvm', 3389 'audio', 3390 'backends', 3391 'backends/tpm', 3392 'ebpf', 3393 'hw/9pfs', 3394 'hw/acpi', 3395 'hw/adc', 3396 'hw/alpha', 3397 'hw/arm', 3398 'hw/audio', 3399 'hw/block', 3400 'hw/char', 3401 'hw/display', 3402 'hw/dma', 3403 'hw/fsi', 3404 'hw/hyperv', 3405 'hw/i2c', 3406 'hw/i386', 3407 'hw/i386/xen', 3408 'hw/i386/kvm', 3409 'hw/ide', 3410 'hw/input', 3411 'hw/intc', 3412 'hw/isa', 3413 'hw/mem', 3414 'hw/mips', 3415 'hw/misc', 3416 'hw/misc/macio', 3417 'hw/net', 3418 'hw/net/can', 3419 'hw/nubus', 3420 'hw/nvme', 3421 'hw/nvram', 3422 'hw/pci', 3423 'hw/pci-host', 3424 'hw/ppc', 3425 'hw/rtc', 3426 'hw/s390x', 3427 'hw/scsi', 3428 'hw/sd', 3429 'hw/sh4', 3430 'hw/sparc', 3431 'hw/sparc64', 3432 'hw/ssi', 3433 'hw/timer', 3434 'hw/tpm', 3435 'hw/ufs', 3436 'hw/usb', 3437 'hw/vfio', 3438 'hw/virtio', 3439 'hw/watchdog', 3440 'hw/xen', 3441 'hw/gpio', 3442 'migration', 3443 'net', 3444 'system', 3445 'ui', 3446 'hw/remote', 3447 ] 3448endif 3449if have_system or have_user 3450 trace_events_subdirs += [ 3451 'accel/tcg', 3452 'hw/core', 3453 'target/arm', 3454 'target/arm/hvf', 3455 'target/hppa', 3456 'target/i386', 3457 'target/i386/kvm', 3458 'target/loongarch', 3459 'target/mips/tcg', 3460 'target/ppc', 3461 'target/riscv', 3462 'target/s390x', 3463 'target/s390x/kvm', 3464 'target/sparc', 3465 ] 3466endif 3467 3468################### 3469# Collect sources # 3470################### 3471 3472authz_ss = ss.source_set() 3473blockdev_ss = ss.source_set() 3474block_ss = ss.source_set() 3475chardev_ss = ss.source_set() 3476common_ss = ss.source_set() 3477crypto_ss = ss.source_set() 3478hwcore_ss = ss.source_set() 3479io_ss = ss.source_set() 3480qmp_ss = ss.source_set() 3481qom_ss = ss.source_set() 3482system_ss = ss.source_set() 3483specific_fuzz_ss = ss.source_set() 3484specific_ss = ss.source_set() 3485stub_ss = ss.source_set() 3486trace_ss = ss.source_set() 3487user_ss = ss.source_set() 3488util_ss = ss.source_set() 3489 3490# accel modules 3491qtest_module_ss = ss.source_set() 3492tcg_module_ss = ss.source_set() 3493 3494modules = {} 3495target_modules = {} 3496hw_arch = {} 3497target_arch = {} 3498target_system_arch = {} 3499target_user_arch = {} 3500 3501# NOTE: the trace/ subdirectory needs the qapi_trace_events variable 3502# that is filled in by qapi/. 3503subdir('qapi') 3504subdir('qobject') 3505subdir('stubs') 3506subdir('trace') 3507subdir('util') 3508subdir('qom') 3509subdir('authz') 3510subdir('crypto') 3511subdir('ui') 3512subdir('gdbstub') 3513if have_system 3514 subdir('hw') 3515else 3516 subdir('hw/core') 3517endif 3518 3519if enable_modules 3520 libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO') 3521 modulecommon = declare_dependency(objects: libmodulecommon.extract_all_objects(recursive: false), compile_args: '-DBUILD_DSO') 3522endif 3523 3524qom_ss = qom_ss.apply({}) 3525libqom = static_library('qom', qom_ss.sources() + genh, 3526 dependencies: [qom_ss.dependencies()], 3527 build_by_default: false) 3528qom = declare_dependency(objects: libqom.extract_all_objects(recursive: false), 3529 dependencies: qom_ss.dependencies()) 3530 3531event_loop_base = files('event-loop-base.c') 3532event_loop_base = static_library('event-loop-base', 3533 sources: event_loop_base + genh, 3534 build_by_default: false) 3535event_loop_base = declare_dependency(objects: event_loop_base.extract_all_objects(recursive: false), 3536 dependencies: [qom]) 3537 3538stub_ss = stub_ss.apply({}) 3539 3540util_ss.add_all(trace_ss) 3541util_ss = util_ss.apply({}) 3542libqemuutil = static_library('qemuutil', 3543 build_by_default: false, 3544 sources: util_ss.sources() + stub_ss.sources() + genh, 3545 dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc]) 3546qemuutil = declare_dependency(link_with: libqemuutil, 3547 sources: genh + version_res, 3548 dependencies: [event_loop_base]) 3549 3550if have_system or have_user 3551 decodetree = generator(find_program('scripts/decodetree.py'), 3552 output: 'decode-@BASENAME@.c.inc', 3553 arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@']) 3554 subdir('libdecnumber') 3555 subdir('target') 3556endif 3557 3558subdir('audio') 3559subdir('io') 3560subdir('chardev') 3561subdir('fsdev') 3562subdir('dump') 3563 3564if have_block 3565 block_ss.add(files( 3566 'block.c', 3567 'blockjob.c', 3568 'job.c', 3569 'qemu-io-cmds.c', 3570 )) 3571 if config_host_data.get('CONFIG_REPLICATION') 3572 block_ss.add(files('replication.c')) 3573 endif 3574 3575 subdir('nbd') 3576 subdir('scsi') 3577 subdir('block') 3578 3579 blockdev_ss.add(files( 3580 'blockdev.c', 3581 'blockdev-nbd.c', 3582 'iothread.c', 3583 'job-qmp.c', 3584 )) 3585 3586 # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon, 3587 # os-win32.c does not 3588 if host_os == 'windows' 3589 system_ss.add(files('os-win32.c')) 3590 else 3591 blockdev_ss.add(files('os-posix.c')) 3592 endif 3593endif 3594 3595common_ss.add(files('cpu-common.c')) 3596specific_ss.add(files('cpu-target.c')) 3597 3598subdir('system') 3599 3600# Work around a gcc bug/misfeature wherein constant propagation looks 3601# through an alias: 3602# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99696 3603# to guess that a const variable is always zero. Without lto, this is 3604# impossible, as the alias is restricted to page-vary-common.c. Indeed, 3605# without lto, not even the alias is required -- we simply use different 3606# declarations in different compilation units. 3607pagevary = files('page-vary-common.c') 3608if get_option('b_lto') 3609 pagevary_flags = ['-fno-lto'] 3610 if get_option('cfi') 3611 pagevary_flags += '-fno-sanitize=cfi-icall' 3612 endif 3613 pagevary = static_library('page-vary-common', sources: pagevary + genh, 3614 c_args: pagevary_flags) 3615 pagevary = declare_dependency(link_with: pagevary) 3616endif 3617common_ss.add(pagevary) 3618specific_ss.add(files('page-target.c', 'page-vary-target.c')) 3619 3620subdir('backends') 3621subdir('disas') 3622subdir('migration') 3623subdir('monitor') 3624subdir('net') 3625subdir('replay') 3626subdir('semihosting') 3627subdir('stats') 3628subdir('tcg') 3629subdir('fpu') 3630subdir('accel') 3631subdir('plugins') 3632subdir('ebpf') 3633 3634common_user_inc = [] 3635 3636subdir('common-user') 3637subdir('bsd-user') 3638subdir('linux-user') 3639 3640# needed for fuzzing binaries 3641subdir('tests/qtest/libqos') 3642subdir('tests/qtest/fuzz') 3643 3644# accel modules 3645tcg_real_module_ss = ss.source_set() 3646tcg_real_module_ss.add_all(when: 'CONFIG_TCG_MODULAR', if_true: tcg_module_ss) 3647specific_ss.add_all(when: 'CONFIG_TCG_BUILTIN', if_true: tcg_module_ss) 3648target_modules += { 'accel' : { 'qtest': qtest_module_ss, 3649 'tcg': tcg_real_module_ss }} 3650 3651############################################## 3652# Internal static_libraries and dependencies # 3653############################################## 3654 3655modinfo_collect = find_program('scripts/modinfo-collect.py') 3656modinfo_generate = find_program('scripts/modinfo-generate.py') 3657modinfo_files = [] 3658 3659block_mods = [] 3660system_mods = [] 3661emulator_modules = [] 3662foreach d, list : modules 3663 if not (d == 'block' ? have_block : have_system) 3664 continue 3665 endif 3666 3667 foreach m, module_ss : list 3668 if enable_modules 3669 module_ss.add(modulecommon) 3670 module_ss = module_ss.apply(config_all_devices, strict: false) 3671 sl = static_library(d + '-' + m, [genh, module_ss.sources()], 3672 dependencies: module_ss.dependencies(), pic: true) 3673 if d == 'block' 3674 block_mods += sl 3675 else 3676 system_mods += sl 3677 endif 3678 emulator_modules += shared_module(sl.name(), 3679 name_prefix: '', 3680 objects: sl.extract_all_objects(recursive: false), 3681 dependencies: module_ss.dependencies(), 3682 install: true, 3683 install_dir: qemu_moddir) 3684 if module_ss.sources() != [] 3685 # FIXME: Should use sl.extract_all_objects(recursive: true) as 3686 # input. Sources can be used multiple times but objects are 3687 # unique when it comes to lookup in compile_commands.json. 3688 # Depnds on a mesion version with 3689 # https://github.com/mesonbuild/meson/pull/8900 3690 modinfo_files += custom_target(d + '-' + m + '.modinfo', 3691 output: d + '-' + m + '.modinfo', 3692 input: module_ss.sources() + genh, 3693 capture: true, 3694 command: [modinfo_collect, module_ss.sources()]) 3695 endif 3696 else 3697 if d == 'block' 3698 block_ss.add_all(module_ss) 3699 else 3700 system_ss.add_all(module_ss) 3701 endif 3702 endif 3703 endforeach 3704endforeach 3705 3706foreach d, list : target_modules 3707 foreach m, module_ss : list 3708 if enable_modules 3709 module_ss.add(modulecommon) 3710 foreach target : target_dirs 3711 if target.endswith('-softmmu') 3712 config_target = config_target_mak[target] 3713 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])] 3714 c_args = ['-DCOMPILING_PER_TARGET', 3715 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target), 3716 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)] 3717 target_module_ss = module_ss.apply(config_target, strict: false) 3718 if target_module_ss.sources() != [] 3719 module_name = d + '-' + m + '-' + config_target['TARGET_NAME'] 3720 sl = static_library(module_name, 3721 [genh, target_module_ss.sources()], 3722 dependencies: target_module_ss.dependencies(), 3723 include_directories: target_inc, 3724 c_args: c_args, 3725 pic: true) 3726 system_mods += sl 3727 emulator_modules += shared_module(sl.name(), 3728 name_prefix: '', 3729 objects: sl.extract_all_objects(recursive: false), 3730 dependencies: target_module_ss.dependencies(), 3731 install: true, 3732 install_dir: qemu_moddir) 3733 # FIXME: Should use sl.extract_all_objects(recursive: true) too. 3734 modinfo_files += custom_target(module_name + '.modinfo', 3735 output: module_name + '.modinfo', 3736 input: target_module_ss.sources() + genh, 3737 capture: true, 3738 command: [modinfo_collect, '--target', target, target_module_ss.sources()]) 3739 endif 3740 endif 3741 endforeach 3742 else 3743 specific_ss.add_all(module_ss) 3744 endif 3745 endforeach 3746endforeach 3747 3748if enable_modules 3749 foreach target : target_dirs 3750 if target.endswith('-softmmu') 3751 config_target = config_target_mak[target] 3752 config_devices_mak = target + '-config-devices.mak' 3753 modinfo_src = custom_target('modinfo-' + target + '.c', 3754 output: 'modinfo-' + target + '.c', 3755 input: modinfo_files, 3756 command: [modinfo_generate, '--devices', config_devices_mak, '@INPUT@'], 3757 capture: true) 3758 3759 modinfo_lib = static_library('modinfo-' + target + '.c', modinfo_src) 3760 modinfo_dep = declare_dependency(link_with: modinfo_lib) 3761 3762 arch = config_target['TARGET_NAME'] == 'sparc64' ? 'sparc64' : config_target['TARGET_BASE_ARCH'] 3763 hw_arch[arch].add(modinfo_dep) 3764 endif 3765 endforeach 3766 3767 if emulator_modules.length() > 0 3768 alias_target('modules', emulator_modules) 3769 endif 3770endif 3771 3772nm = find_program('nm') 3773undefsym = find_program('scripts/undefsym.py') 3774block_syms = custom_target('block.syms', output: 'block.syms', 3775 input: [libqemuutil, block_mods], 3776 capture: true, 3777 command: [undefsym, nm, '@INPUT@']) 3778qemu_syms = custom_target('qemu.syms', output: 'qemu.syms', 3779 input: [libqemuutil, system_mods], 3780 capture: true, 3781 command: [undefsym, nm, '@INPUT@']) 3782 3783authz_ss = authz_ss.apply({}) 3784libauthz = static_library('authz', authz_ss.sources() + genh, 3785 dependencies: [authz_ss.dependencies()], 3786 build_by_default: false) 3787 3788authz = declare_dependency(objects: libauthz.extract_all_objects(recursive: false), 3789 dependencies: [authz_ss.dependencies(), qom]) 3790 3791crypto_ss = crypto_ss.apply({}) 3792libcrypto = static_library('crypto', crypto_ss.sources() + genh, 3793 dependencies: [crypto_ss.dependencies()], 3794 build_by_default: false) 3795 3796crypto = declare_dependency(objects: libcrypto.extract_all_objects(recursive: false), 3797 dependencies: [crypto_ss.dependencies(), authz, qom]) 3798 3799io_ss = io_ss.apply({}) 3800libio = static_library('io', io_ss.sources() + genh, 3801 dependencies: [io_ss.dependencies()], 3802 link_with: libqemuutil, 3803 build_by_default: false) 3804 3805io = declare_dependency(objects: libio.extract_all_objects(recursive: false), 3806 dependencies: [io_ss.dependencies(), crypto, qom]) 3807 3808libmigration = static_library('migration', sources: migration_files + genh, 3809 build_by_default: false) 3810migration = declare_dependency(objects: libmigration.extract_all_objects(recursive: false), 3811 dependencies: [qom, io]) 3812system_ss.add(migration) 3813 3814block_ss = block_ss.apply({}) 3815libblock = static_library('block', block_ss.sources() + genh, 3816 dependencies: block_ss.dependencies(), 3817 build_by_default: false) 3818 3819block = declare_dependency(objects: libblock.extract_all_objects(recursive: false), 3820 dependencies: [block_ss.dependencies(), crypto, io]) 3821 3822blockdev_ss = blockdev_ss.apply({}) 3823libblockdev = static_library('blockdev', blockdev_ss.sources() + genh, 3824 dependencies: blockdev_ss.dependencies(), 3825 build_by_default: false) 3826 3827blockdev = declare_dependency(objects: libblockdev.extract_all_objects(recursive: false), 3828 dependencies: [blockdev_ss.dependencies(), block, event_loop_base]) 3829 3830qmp_ss = qmp_ss.apply({}) 3831libqmp = static_library('qmp', qmp_ss.sources() + genh, 3832 dependencies: qmp_ss.dependencies(), 3833 build_by_default: false) 3834 3835qmp = declare_dependency(objects: libqmp.extract_all_objects(recursive: false), 3836 dependencies: qmp_ss.dependencies()) 3837 3838libchardev = static_library('chardev', chardev_ss.sources() + genh, 3839 dependencies: chardev_ss.dependencies(), 3840 build_by_default: false) 3841 3842chardev = declare_dependency(objects: libchardev.extract_all_objects(recursive: false), 3843 dependencies: chardev_ss.dependencies()) 3844 3845hwcore_ss = hwcore_ss.apply({}) 3846libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh, 3847 build_by_default: false) 3848hwcore = declare_dependency(objects: libhwcore.extract_all_objects(recursive: false)) 3849common_ss.add(hwcore) 3850 3851########### 3852# Targets # 3853########### 3854 3855system_ss.add(authz, blockdev, chardev, crypto, io, qmp) 3856common_ss.add(qom, qemuutil) 3857 3858common_ss.add_all(when: 'CONFIG_SYSTEM_ONLY', if_true: [system_ss]) 3859common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss) 3860 3861# Note that this library is never used directly (only through extract_objects) 3862# and is not built by default; therefore, source files not used by the build 3863# configuration will be in build.ninja, but are never built by default. 3864common_all = static_library('common', 3865 build_by_default: false, 3866 sources: common_ss.all_sources() + genh, 3867 include_directories: common_user_inc, 3868 implicit_include_directories: false, 3869 dependencies: common_ss.all_dependencies()) 3870 3871feature_to_c = find_program('scripts/feature_to_c.py') 3872 3873if host_os == 'darwin' 3874 entitlement = find_program('scripts/entitlement.sh') 3875endif 3876 3877traceable = [] 3878emulators = {} 3879foreach target : target_dirs 3880 config_target = config_target_mak[target] 3881 target_name = config_target['TARGET_NAME'] 3882 target_base_arch = config_target['TARGET_BASE_ARCH'] 3883 arch_srcs = [config_target_h[target]] 3884 arch_deps = [] 3885 c_args = ['-DCOMPILING_PER_TARGET', 3886 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target), 3887 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)] 3888 link_args = emulator_link_args 3889 3890 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])] 3891 if host_os == 'linux' 3892 target_inc += include_directories('linux-headers', is_system: true) 3893 endif 3894 if target.endswith('-softmmu') 3895 target_type='system' 3896 t = target_system_arch[target_base_arch].apply(config_target, strict: false) 3897 arch_srcs += t.sources() 3898 arch_deps += t.dependencies() 3899 3900 hw_dir = target_name == 'sparc64' ? 'sparc64' : target_base_arch 3901 if hw_arch.has_key(hw_dir) 3902 hw = hw_arch[hw_dir].apply(config_target, strict: false) 3903 arch_srcs += hw.sources() 3904 arch_deps += hw.dependencies() 3905 endif 3906 3907 arch_srcs += config_devices_h[target] 3908 link_args += ['@block.syms', '@qemu.syms'] 3909 else 3910 abi = config_target['TARGET_ABI_DIR'] 3911 target_type='user' 3912 target_inc += common_user_inc 3913 if target_base_arch in target_user_arch 3914 t = target_user_arch[target_base_arch].apply(config_target, strict: false) 3915 arch_srcs += t.sources() 3916 arch_deps += t.dependencies() 3917 endif 3918 if 'CONFIG_LINUX_USER' in config_target 3919 base_dir = 'linux-user' 3920 endif 3921 if 'CONFIG_BSD_USER' in config_target 3922 base_dir = 'bsd-user' 3923 target_inc += include_directories('bsd-user/' / host_os) 3924 target_inc += include_directories('bsd-user/host/' / host_arch) 3925 dir = base_dir / abi 3926 arch_srcs += files(dir / 'signal.c', dir / 'target_arch_cpu.c') 3927 endif 3928 target_inc += include_directories( 3929 base_dir, 3930 base_dir / abi, 3931 ) 3932 if 'CONFIG_LINUX_USER' in config_target 3933 dir = base_dir / abi 3934 arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c') 3935 if config_target.has_key('TARGET_SYSTBL_ABI') 3936 arch_srcs += \ 3937 syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'], 3938 extra_args : config_target['TARGET_SYSTBL_ABI']) 3939 endif 3940 endif 3941 endif 3942 3943 if 'TARGET_XML_FILES' in config_target 3944 gdbstub_xml = custom_target(target + '-gdbstub-xml.c', 3945 output: target + '-gdbstub-xml.c', 3946 input: files(config_target['TARGET_XML_FILES'].split()), 3947 command: [feature_to_c, '@INPUT@'], 3948 capture: true) 3949 arch_srcs += gdbstub_xml 3950 endif 3951 3952 t = target_arch[target_base_arch].apply(config_target, strict: false) 3953 arch_srcs += t.sources() 3954 arch_deps += t.dependencies() 3955 3956 target_common = common_ss.apply(config_target, strict: false) 3957 objects = common_all.extract_objects(target_common.sources()) 3958 arch_deps += target_common.dependencies() 3959 3960 target_specific = specific_ss.apply(config_target, strict: false) 3961 arch_srcs += target_specific.sources() 3962 arch_deps += target_specific.dependencies() 3963 3964 # allow using headers from the dependencies but do not include the sources, 3965 # because this emulator only needs those in "objects". For external 3966 # dependencies, the full dependency is included below in the executable. 3967 lib_deps = [] 3968 foreach dep : arch_deps 3969 lib_deps += dep.partial_dependency(compile_args: true, includes: true) 3970 endforeach 3971 3972 lib = static_library('qemu-' + target, 3973 sources: arch_srcs + genh, 3974 dependencies: lib_deps, 3975 objects: objects, 3976 include_directories: target_inc, 3977 c_args: c_args, 3978 build_by_default: false) 3979 3980 if target.endswith('-softmmu') 3981 execs = [{ 3982 'name': 'qemu-system-' + target_name, 3983 'win_subsystem': 'console', 3984 'sources': files('system/main.c'), 3985 'dependencies': [] 3986 }] 3987 if host_os == 'windows' and (sdl.found() or gtk.found()) 3988 execs += [{ 3989 'name': 'qemu-system-' + target_name + 'w', 3990 'win_subsystem': 'windows', 3991 'sources': files('system/main.c'), 3992 'dependencies': [] 3993 }] 3994 endif 3995 if get_option('fuzzing') 3996 specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false) 3997 execs += [{ 3998 'name': 'qemu-fuzz-' + target_name, 3999 'win_subsystem': 'console', 4000 'sources': specific_fuzz.sources(), 4001 'dependencies': specific_fuzz.dependencies(), 4002 }] 4003 endif 4004 else 4005 execs = [{ 4006 'name': 'qemu-' + target_name, 4007 'win_subsystem': 'console', 4008 'sources': [], 4009 'dependencies': [] 4010 }] 4011 endif 4012 foreach exe: execs 4013 exe_name = exe['name'] 4014 if host_os == 'darwin' 4015 exe_name += '-unsigned' 4016 endif 4017 4018 emulator = executable(exe_name, exe['sources'], 4019 install: true, 4020 c_args: c_args, 4021 dependencies: arch_deps + exe['dependencies'], 4022 objects: lib.extract_all_objects(recursive: true), 4023 link_depends: [block_syms, qemu_syms], 4024 link_args: link_args, 4025 win_subsystem: exe['win_subsystem']) 4026 4027 if host_os == 'darwin' 4028 icon = 'pc-bios/qemu.rsrc' 4029 build_input = [emulator, files(icon)] 4030 install_input = [ 4031 get_option('bindir') / exe_name, 4032 meson.current_source_dir() / icon 4033 ] 4034 if 'CONFIG_HVF' in config_target 4035 entitlements = 'accel/hvf/entitlements.plist' 4036 build_input += files(entitlements) 4037 install_input += meson.current_source_dir() / entitlements 4038 endif 4039 4040 emulators += {exe['name'] : custom_target(exe['name'], 4041 input: build_input, 4042 output: exe['name'], 4043 command: [entitlement, '@OUTPUT@', '@INPUT@']) 4044 } 4045 4046 meson.add_install_script(entitlement, '--install', 4047 get_option('bindir') / exe['name'], 4048 install_input) 4049 else 4050 emulators += {exe['name']: emulator} 4051 endif 4052 4053 traceable += [{ 4054 'exe': exe['name'], 4055 'probe-prefix': 'qemu.' + target_type + '.' + target_name, 4056 }] 4057 4058 endforeach 4059endforeach 4060 4061# Other build targets 4062 4063if get_option('plugins') 4064 install_headers('include/qemu/qemu-plugin.h') 4065 if host_os == 'windows' 4066 # On windows, we want to deliver the qemu_plugin_api.lib file in the qemu installer, 4067 # so that plugin authors can compile against it. 4068 install_data(win32_qemu_plugin_api_lib, install_dir: 'lib') 4069 endif 4070endif 4071 4072subdir('qga') 4073 4074# Don't build qemu-keymap if xkbcommon is not explicitly enabled 4075# when we don't build tools or system 4076if xkbcommon.found() 4077 # used for the update-keymaps target, so include rules even if !have_tools 4078 qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh, 4079 dependencies: [qemuutil, xkbcommon], install: have_tools) 4080endif 4081 4082if have_tools 4083 qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep], 4084 link_args: '@block.syms', link_depends: block_syms, 4085 dependencies: [authz, block, crypto, io, qom, qemuutil], install: true) 4086 qemu_io = executable('qemu-io', files('qemu-io.c'), 4087 link_args: '@block.syms', link_depends: block_syms, 4088 dependencies: [block, qemuutil], install: true) 4089 qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'), 4090 link_args: '@block.syms', link_depends: block_syms, 4091 dependencies: [blockdev, qemuutil, selinux], 4092 install: true) 4093 4094 subdir('storage-daemon') 4095 4096 foreach exe: [ 'qemu-img', 'qemu-io', 'qemu-nbd', 'qemu-storage-daemon'] 4097 traceable += [{ 4098 'exe': exe, 4099 'probe-prefix': 'qemu.' + exe.substring(5).replace('-', '_') 4100 }] 4101 endforeach 4102 4103 subdir('contrib/elf2dmp') 4104 4105 executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'), 4106 dependencies: qemuutil, 4107 install: true) 4108 4109 if have_vhost_user 4110 subdir('contrib/vhost-user-blk') 4111 subdir('contrib/vhost-user-gpu') 4112 subdir('contrib/vhost-user-input') 4113 subdir('contrib/vhost-user-scsi') 4114 endif 4115 4116 if host_os == 'linux' 4117 executable('qemu-bridge-helper', files('qemu-bridge-helper.c'), 4118 dependencies: [qemuutil, libcap_ng], 4119 install: true, 4120 install_dir: get_option('libexecdir')) 4121 4122 executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'), 4123 dependencies: [authz, crypto, io, qom, qemuutil, 4124 libcap_ng, mpathpersist], 4125 install: true) 4126 4127 if cpu in ['x86', 'x86_64'] 4128 executable('qemu-vmsr-helper', files('tools/i386/qemu-vmsr-helper.c'), 4129 dependencies: [authz, crypto, io, qom, qemuutil, 4130 libcap_ng, mpathpersist], 4131 install: true) 4132 endif 4133 endif 4134 4135 if have_ivshmem 4136 subdir('contrib/ivshmem-client') 4137 subdir('contrib/ivshmem-server') 4138 endif 4139endif 4140 4141if stap.found() 4142 foreach t: traceable 4143 foreach stp: [ 4144 {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / t['exe'], 'install': false}, 4145 {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / t['exe'], 'install': true}, 4146 {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true}, 4147 {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true}, 4148 ] 4149 cmd = [ 4150 tracetool, '--group=all', '--format=' + stp['fmt'], 4151 '--binary=' + stp['bin'], 4152 '--probe-prefix=' + t['probe-prefix'], 4153 '@INPUT@', '@OUTPUT@' 4154 ] 4155 4156 custom_target(t['exe'] + stp['ext'], 4157 input: trace_events_all, 4158 output: t['exe'] + stp['ext'], 4159 install: stp['install'], 4160 install_dir: get_option('datadir') / 'systemtap/tapset', 4161 command: cmd, 4162 depend_files: tracetool_depends) 4163 endforeach 4164 endforeach 4165endif 4166 4167subdir('scripts') 4168subdir('tools') 4169subdir('pc-bios') 4170subdir('docs') 4171subdir('tests') 4172if gtk.found() 4173 subdir('po') 4174endif 4175 4176if host_machine.system() == 'windows' 4177 nsis_cmd = [ 4178 find_program('scripts/nsis.py'), 4179 '@OUTPUT@', 4180 get_option('prefix'), 4181 meson.current_source_dir(), 4182 glib_pc.get_variable('bindir'), 4183 host_machine.cpu(), 4184 '--', 4185 '-DDISPLAYVERSION=' + meson.project_version(), 4186 ] 4187 if build_docs 4188 nsis_cmd += '-DCONFIG_DOCUMENTATION=y' 4189 endif 4190 if gtk.found() 4191 nsis_cmd += '-DCONFIG_GTK=y' 4192 endif 4193 4194 nsis = custom_target('nsis', 4195 output: 'qemu-setup-' + meson.project_version() + '.exe', 4196 input: files('qemu.nsi'), 4197 build_always_stale: true, 4198 command: nsis_cmd + ['@INPUT@']) 4199 alias_target('installer', nsis) 4200endif 4201 4202######################### 4203# Configuration summary # 4204######################### 4205 4206# Build environment 4207summary_info = {} 4208summary_info += {'Build directory': meson.current_build_dir()} 4209summary_info += {'Source path': meson.current_source_dir()} 4210summary_info += {'Download dependencies': get_option('wrap_mode') != 'nodownload'} 4211summary(summary_info, bool_yn: true, section: 'Build environment') 4212 4213# Directories 4214summary_info += {'Install prefix': get_option('prefix')} 4215summary_info += {'BIOS directory': qemu_datadir} 4216pathsep = host_os == 'windows' ? ';' : ':' 4217summary_info += {'firmware path': pathsep.join(get_option('qemu_firmwarepath'))} 4218summary_info += {'binary directory': get_option('prefix') / get_option('bindir')} 4219summary_info += {'library directory': get_option('prefix') / get_option('libdir')} 4220summary_info += {'module directory': qemu_moddir} 4221summary_info += {'libexec directory': get_option('prefix') / get_option('libexecdir')} 4222summary_info += {'include directory': get_option('prefix') / get_option('includedir')} 4223summary_info += {'config directory': get_option('prefix') / get_option('sysconfdir')} 4224if host_os != 'windows' 4225 summary_info += {'local state directory': get_option('prefix') / get_option('localstatedir')} 4226 summary_info += {'Manual directory': get_option('prefix') / get_option('mandir')} 4227else 4228 summary_info += {'local state directory': 'queried at runtime'} 4229endif 4230summary_info += {'Doc directory': get_option('prefix') / get_option('docdir')} 4231summary(summary_info, bool_yn: true, section: 'Directories') 4232 4233# Host binaries 4234summary_info = {} 4235summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())} 4236summary_info += {'sphinx-build': sphinx_build} 4237 4238# FIXME: the [binaries] section of machine files, which can be probed 4239# with find_program(), would be great for passing gdb and genisoimage 4240# paths from configure to Meson. However, there seems to be no way to 4241# hide a program (for example if gdb is too old). 4242if config_host.has_key('GDB') 4243 summary_info += {'gdb': config_host['GDB']} 4244endif 4245summary_info += {'iasl': iasl} 4246summary_info += {'genisoimage': config_host['GENISOIMAGE']} 4247if host_os == 'windows' and have_ga 4248 summary_info += {'wixl': wixl} 4249endif 4250if slirp.found() and have_system 4251 summary_info += {'smbd': have_slirp_smbd ? smbd_path : false} 4252endif 4253summary(summary_info, bool_yn: true, section: 'Host binaries') 4254 4255# Configurable features 4256summary_info = {} 4257summary_info += {'Documentation': build_docs} 4258summary_info += {'system-mode emulation': have_system} 4259summary_info += {'user-mode emulation': have_user} 4260summary_info += {'block layer': have_block} 4261summary_info += {'Install blobs': get_option('install_blobs')} 4262summary_info += {'module support': enable_modules} 4263if enable_modules 4264 summary_info += {'alternative module path': get_option('module_upgrades')} 4265endif 4266summary_info += {'fuzzing support': get_option('fuzzing')} 4267if have_system 4268 summary_info += {'Audio drivers': ' '.join(audio_drivers_selected)} 4269endif 4270summary_info += {'Trace backends': ','.join(get_option('trace_backends'))} 4271if 'simple' in get_option('trace_backends') 4272 summary_info += {'Trace output file': get_option('trace_file') + '-<pid>'} 4273endif 4274summary_info += {'D-Bus display': dbus_display} 4275summary_info += {'QOM debugging': get_option('qom_cast_debug')} 4276summary_info += {'Relocatable install': get_option('relocatable')} 4277summary_info += {'vhost-kernel support': have_vhost_kernel} 4278summary_info += {'vhost-net support': have_vhost_net} 4279summary_info += {'vhost-user support': have_vhost_user} 4280summary_info += {'vhost-user-crypto support': have_vhost_user_crypto} 4281summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server} 4282summary_info += {'vhost-vdpa support': have_vhost_vdpa} 4283summary_info += {'build guest agent': have_ga} 4284summary(summary_info, bool_yn: true, section: 'Configurable features') 4285 4286# Compilation information 4287summary_info = {} 4288summary_info += {'host CPU': cpu} 4289summary_info += {'host endianness': build_machine.endian()} 4290summary_info += {'C compiler': ' '.join(meson.get_compiler('c').cmd_array())} 4291summary_info += {'Host C compiler': ' '.join(meson.get_compiler('c', native: true).cmd_array())} 4292if 'cpp' in all_languages 4293 summary_info += {'C++ compiler': ' '.join(meson.get_compiler('cpp').cmd_array())} 4294else 4295 summary_info += {'C++ compiler': false} 4296endif 4297if 'objc' in all_languages 4298 summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())} 4299else 4300 summary_info += {'Objective-C compiler': false} 4301endif 4302option_cflags = (get_option('debug') ? ['-g'] : []) 4303if get_option('optimization') != 'plain' 4304 option_cflags += ['-O' + get_option('optimization')] 4305endif 4306summary_info += {'CFLAGS': ' '.join(get_option('c_args') + option_cflags)} 4307if 'cpp' in all_languages 4308 summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args') + option_cflags)} 4309endif 4310if 'objc' in all_languages 4311 summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args') + option_cflags)} 4312endif 4313link_args = get_option('c_link_args') 4314if link_args.length() > 0 4315 summary_info += {'LDFLAGS': ' '.join(link_args)} 4316endif 4317summary_info += {'QEMU_CFLAGS': ' '.join(qemu_common_flags + qemu_cflags)} 4318if 'cpp' in all_languages 4319 summary_info += {'QEMU_CXXFLAGS': ' '.join(qemu_common_flags + qemu_cxxflags)} 4320endif 4321if 'objc' in all_languages 4322 summary_info += {'QEMU_OBJCFLAGS': ' '.join(qemu_common_flags)} 4323endif 4324summary_info += {'QEMU_LDFLAGS': ' '.join(qemu_ldflags)} 4325summary_info += {'link-time optimization (LTO)': get_option('b_lto')} 4326summary_info += {'PIE': get_option('b_pie')} 4327summary_info += {'static build': get_option('prefer_static')} 4328summary_info += {'malloc trim support': has_malloc_trim} 4329summary_info += {'membarrier': have_membarrier} 4330summary_info += {'debug graph lock': get_option('debug_graph_lock')} 4331summary_info += {'debug stack usage': get_option('debug_stack_usage')} 4332summary_info += {'mutex debugging': get_option('debug_mutex')} 4333summary_info += {'memory allocator': get_option('malloc')} 4334summary_info += {'avx2 optimization': config_host_data.get('CONFIG_AVX2_OPT')} 4335summary_info += {'avx512bw optimization': config_host_data.get('CONFIG_AVX512BW_OPT')} 4336summary_info += {'gcov': get_option('b_coverage')} 4337summary_info += {'thread sanitizer': get_option('tsan')} 4338summary_info += {'CFI support': get_option('cfi')} 4339if get_option('cfi') 4340 summary_info += {'CFI debug support': get_option('cfi_debug')} 4341endif 4342summary_info += {'strip binaries': get_option('strip')} 4343summary_info += {'sparse': sparse} 4344summary_info += {'mingw32 support': host_os == 'windows'} 4345summary(summary_info, bool_yn: true, section: 'Compilation') 4346 4347# snarf the cross-compilation information for tests 4348summary_info = {} 4349have_cross = false 4350foreach target: target_dirs 4351 tcg_mak = meson.current_build_dir() / 'tests/tcg' / target / 'config-target.mak' 4352 if fs.exists(tcg_mak) 4353 config_cross_tcg = keyval.load(tcg_mak) 4354 if 'CC' in config_cross_tcg 4355 summary_info += {config_cross_tcg['TARGET_NAME']: config_cross_tcg['CC']} 4356 have_cross = true 4357 endif 4358 endif 4359endforeach 4360if have_cross 4361 summary(summary_info, bool_yn: true, section: 'Cross compilers') 4362endif 4363 4364# Targets and accelerators 4365summary_info = {} 4366if have_system 4367 summary_info += {'KVM support': config_all_accel.has_key('CONFIG_KVM')} 4368 summary_info += {'HVF support': config_all_accel.has_key('CONFIG_HVF')} 4369 summary_info += {'WHPX support': config_all_accel.has_key('CONFIG_WHPX')} 4370 summary_info += {'NVMM support': config_all_accel.has_key('CONFIG_NVMM')} 4371 summary_info += {'Xen support': xen.found()} 4372 if xen.found() 4373 summary_info += {'xen ctrl version': xen.version()} 4374 endif 4375 summary_info += {'Xen emulation': config_all_devices.has_key('CONFIG_XEN_EMU')} 4376endif 4377summary_info += {'TCG support': config_all_accel.has_key('CONFIG_TCG')} 4378if config_all_accel.has_key('CONFIG_TCG') 4379 if get_option('tcg_interpreter') 4380 summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, slow)'} 4381 else 4382 summary_info += {'TCG backend': 'native (@0@)'.format(cpu)} 4383 endif 4384 summary_info += {'TCG plugins': get_option('plugins')} 4385 summary_info += {'TCG debug enabled': get_option('debug_tcg')} 4386 if have_linux_user or have_bsd_user 4387 summary_info += {'syscall buffer debugging support': get_option('debug_remap')} 4388 endif 4389endif 4390summary_info += {'target list': ' '.join(target_dirs)} 4391if have_system 4392 summary_info += {'default devices': get_option('default_devices')} 4393 summary_info += {'out of process emulation': multiprocess_allowed} 4394 summary_info += {'vfio-user server': vfio_user_server_allowed} 4395endif 4396summary(summary_info, bool_yn: true, section: 'Targets and accelerators') 4397 4398# Block layer 4399summary_info = {} 4400summary_info += {'coroutine backend': coroutine_backend} 4401summary_info += {'coroutine pool': have_coroutine_pool} 4402if have_block 4403 summary_info += {'Block whitelist (rw)': get_option('block_drv_rw_whitelist')} 4404 summary_info += {'Block whitelist (ro)': get_option('block_drv_ro_whitelist')} 4405 summary_info += {'Use block whitelist in tools': get_option('block_drv_whitelist_in_tools')} 4406 summary_info += {'VirtFS (9P) support': have_virtfs} 4407 summary_info += {'VirtFS (9P) Proxy Helper support (deprecated)': have_virtfs_proxy_helper} 4408 summary_info += {'replication support': config_host_data.get('CONFIG_REPLICATION')} 4409 summary_info += {'bochs support': get_option('bochs').allowed()} 4410 summary_info += {'cloop support': get_option('cloop').allowed()} 4411 summary_info += {'dmg support': get_option('dmg').allowed()} 4412 summary_info += {'qcow v1 support': get_option('qcow1').allowed()} 4413 summary_info += {'vdi support': get_option('vdi').allowed()} 4414 summary_info += {'vhdx support': get_option('vhdx').allowed()} 4415 summary_info += {'vmdk support': get_option('vmdk').allowed()} 4416 summary_info += {'vpc support': get_option('vpc').allowed()} 4417 summary_info += {'vvfat support': get_option('vvfat').allowed()} 4418 summary_info += {'qed support': get_option('qed').allowed()} 4419 summary_info += {'parallels support': get_option('parallels').allowed()} 4420 summary_info += {'FUSE exports': fuse} 4421 summary_info += {'VDUSE block exports': have_vduse_blk_export} 4422endif 4423summary(summary_info, bool_yn: true, section: 'Block layer support') 4424 4425# Crypto 4426summary_info = {} 4427summary_info += {'TLS priority': get_option('tls_priority')} 4428summary_info += {'GNUTLS support': gnutls} 4429if gnutls.found() 4430 summary_info += {' GNUTLS crypto': gnutls_crypto.found()} 4431endif 4432summary_info += {'libgcrypt': gcrypt} 4433summary_info += {'nettle': nettle} 4434if nettle.found() 4435 summary_info += {' XTS': xts != 'private'} 4436endif 4437summary_info += {'SM4 ALG support': crypto_sm4} 4438summary_info += {'AF_ALG support': have_afalg} 4439summary_info += {'rng-none': get_option('rng_none')} 4440summary_info += {'Linux keyring': have_keyring} 4441summary_info += {'Linux keyutils': keyutils} 4442summary(summary_info, bool_yn: true, section: 'Crypto') 4443 4444# UI 4445summary_info = {} 4446if host_os == 'darwin' 4447 summary_info += {'Cocoa support': cocoa} 4448endif 4449summary_info += {'SDL support': sdl} 4450summary_info += {'SDL image support': sdl_image} 4451summary_info += {'GTK support': gtk} 4452summary_info += {'pixman': pixman} 4453summary_info += {'VTE support': vte} 4454summary_info += {'PNG support': png} 4455summary_info += {'VNC support': vnc} 4456if vnc.found() 4457 summary_info += {'VNC SASL support': sasl} 4458 summary_info += {'VNC JPEG support': jpeg} 4459endif 4460summary_info += {'spice protocol support': spice_protocol} 4461if spice_protocol.found() 4462 summary_info += {' spice server support': spice} 4463endif 4464summary_info += {'curses support': curses} 4465summary_info += {'brlapi support': brlapi} 4466summary(summary_info, bool_yn: true, section: 'User interface') 4467 4468# Graphics backends 4469summary_info = {} 4470summary_info += {'VirGL support': virgl} 4471summary_info += {'Rutabaga support': rutabaga} 4472summary(summary_info, bool_yn: true, section: 'Graphics backends') 4473 4474# Audio backends 4475summary_info = {} 4476if host_os not in ['darwin', 'haiku', 'windows'] 4477 summary_info += {'OSS support': oss} 4478 summary_info += {'sndio support': sndio} 4479elif host_os == 'darwin' 4480 summary_info += {'CoreAudio support': coreaudio} 4481elif host_os == 'windows' 4482 summary_info += {'DirectSound support': dsound} 4483endif 4484if host_os == 'linux' 4485 summary_info += {'ALSA support': alsa} 4486 summary_info += {'PulseAudio support': pulse} 4487endif 4488summary_info += {'PipeWire support': pipewire} 4489summary_info += {'JACK support': jack} 4490summary(summary_info, bool_yn: true, section: 'Audio backends') 4491 4492# Network backends 4493summary_info = {} 4494if host_os == 'darwin' 4495 summary_info += {'vmnet.framework support': vmnet} 4496endif 4497summary_info += {'AF_XDP support': libxdp} 4498summary_info += {'slirp support': slirp} 4499summary_info += {'vde support': vde} 4500summary_info += {'netmap support': have_netmap} 4501summary_info += {'l2tpv3 support': have_l2tpv3} 4502summary(summary_info, bool_yn: true, section: 'Network backends') 4503 4504# Libraries 4505summary_info = {} 4506summary_info += {'libtasn1': tasn1} 4507summary_info += {'PAM': pam} 4508summary_info += {'iconv support': iconv} 4509summary_info += {'blkio support': blkio} 4510summary_info += {'curl support': curl} 4511summary_info += {'Multipath support': mpathpersist} 4512summary_info += {'Linux AIO support': libaio} 4513summary_info += {'Linux io_uring support': linux_io_uring} 4514summary_info += {'ATTR/XATTR support': libattr} 4515summary_info += {'RDMA support': rdma} 4516summary_info += {'fdt support': fdt_opt == 'internal' ? 'internal' : fdt} 4517summary_info += {'libcap-ng support': libcap_ng} 4518summary_info += {'bpf support': libbpf} 4519summary_info += {'rbd support': rbd} 4520summary_info += {'smartcard support': cacard} 4521summary_info += {'U2F support': u2f} 4522summary_info += {'libusb': libusb} 4523summary_info += {'usb net redir': usbredir} 4524summary_info += {'OpenGL support (epoxy)': opengl} 4525summary_info += {'GBM': gbm} 4526summary_info += {'libiscsi support': libiscsi} 4527summary_info += {'libnfs support': libnfs} 4528if host_os == 'windows' 4529 if have_ga 4530 summary_info += {'QGA VSS support': have_qga_vss} 4531 endif 4532endif 4533summary_info += {'seccomp support': seccomp} 4534summary_info += {'GlusterFS support': glusterfs} 4535summary_info += {'hv-balloon support': hv_balloon} 4536summary_info += {'TPM support': have_tpm} 4537summary_info += {'libssh support': libssh} 4538summary_info += {'lzo support': lzo} 4539summary_info += {'snappy support': snappy} 4540summary_info += {'bzip2 support': libbzip2} 4541summary_info += {'lzfse support': liblzfse} 4542summary_info += {'zstd support': zstd} 4543summary_info += {'Query Processing Library support': qpl} 4544summary_info += {'UADK Library support': uadk} 4545summary_info += {'NUMA host support': numa} 4546summary_info += {'capstone': capstone} 4547summary_info += {'libpmem support': libpmem} 4548summary_info += {'libdaxctl support': libdaxctl} 4549summary_info += {'libudev': libudev} 4550# Dummy dependency, keep .found() 4551summary_info += {'FUSE lseek': fuse_lseek.found()} 4552summary_info += {'selinux': selinux} 4553summary_info += {'libdw': libdw} 4554if host_os == 'freebsd' 4555 summary_info += {'libinotify-kqueue': inotify} 4556endif 4557summary(summary_info, bool_yn: true, section: 'Dependencies') 4558 4559if host_arch == 'unknown' 4560 message() 4561 warning('UNSUPPORTED HOST CPU') 4562 message() 4563 message('Support for CPU host architecture ' + cpu + ' is not currently') 4564 message('maintained. The QEMU project does not guarantee that QEMU will') 4565 message('compile or work on this host CPU. You can help by volunteering') 4566 message('to maintain it and providing a build host for our continuous') 4567 message('integration setup.') 4568 if get_option('tcg').allowed() and target_dirs.length() > 0 4569 message() 4570 message('configure has succeeded and you can continue to build, but') 4571 message('QEMU will use a slow interpreter to emulate the target CPU.') 4572 endif 4573endif 4574 4575if not supported_oses.contains(host_os) 4576 message() 4577 warning('UNSUPPORTED HOST OS') 4578 message() 4579 message('Support for host OS ' + host_os + 'is not currently maintained.') 4580 message('configure has succeeded and you can continue to build, but') 4581 message('the QEMU project does not guarantee that QEMU will compile or') 4582 message('work on this operating system. You can help by volunteering') 4583 message('to maintain it and providing a build host for our continuous') 4584 message('integration setup. This will ensure that future versions of QEMU') 4585 message('will keep working on ' + host_os + '.') 4586endif 4587 4588if host_arch == 'unknown' or not supported_oses.contains(host_os) 4589 message() 4590 message('If you want to help supporting QEMU on this platform, please') 4591 message('contact the developers at qemu-devel@nongnu.org.') 4592endif 4593 4594actually_reloc = get_option('relocatable') 4595# check if get_relocated_path() is actually able to relocate paths 4596if get_option('relocatable') and \ 4597 not (get_option('prefix') / get_option('bindir')).startswith(get_option('prefix') / '') 4598 message() 4599 warning('bindir not included within prefix, the installation will not be relocatable.') 4600 actually_reloc = false 4601endif 4602if not actually_reloc and (host_os == 'windows' or get_option('relocatable')) 4603 if host_os == 'windows' 4604 message() 4605 warning('Windows installs should usually be relocatable.') 4606 endif 4607 message() 4608 message('QEMU will have to be installed under ' + get_option('prefix') + '.') 4609 message('Use --disable-relocatable to remove this warning.') 4610endif 4611