qemu/meson.build
Richard Henderson db770a206c meson: Move -fsanitize=undefined into normal configuraton
With 8e466dd092 and 23ef50ae2d, we disable function pointer
sanitization in CI because the qemu code base does not support it.
We must disable this for normal usage of --enable-ubsan as well,
so move it there.

Append options rather than prepend, since all of this requires
proper ordering of options.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20240813095216.306555-3-richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2024-09-11 09:49:11 +02:00

4628 lines
165 KiB
Meson

project('qemu', ['c'], meson_version: '>=1.1.0',
default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto',
'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true'],
version: files('VERSION'))
add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true)
add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow'])
add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
meson.add_postconf_script(find_program('scripts/symlink-install-tree.py'))
####################
# Global variables #
####################
not_found = dependency('', required: false)
keyval = import('keyval')
ss = import('sourceset')
fs = import('fs')
host_os = host_machine.system()
config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
# Temporary directory used for files created while
# configure runs. Since it is in the build directory
# we can safely blow away any previous version of it
# (and we need not jump through hoops to try to delete
# it when configure exits.)
tmpdir = meson.current_build_dir() / 'meson-private/temp'
if get_option('qemu_suffix').startswith('/')
error('qemu_suffix cannot start with a /')
endif
qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
qemu_moddir = get_option('libdir') / get_option('qemu_suffix')
qemu_desktopdir = get_option('datadir') / 'applications'
qemu_icondir = get_option('datadir') / 'icons'
genh = []
qapi_trace_events = []
bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64']
cpu = host_machine.cpu_family()
target_dirs = config_host['TARGET_DIRS'].split()
############
# Programs #
############
sh = find_program('sh')
python = import('python').find_installation()
cc = meson.get_compiler('c')
all_languages = ['c']
if host_os == 'windows' and add_languages('cpp', required: false, native: false)
all_languages += ['cpp']
cxx = meson.get_compiler('cpp')
endif
if host_os == 'darwin' and \
add_languages('objc', required: true, native: false)
all_languages += ['objc']
objc = meson.get_compiler('objc')
endif
dtrace = not_found
stap = not_found
if 'dtrace' in get_option('trace_backends')
dtrace = find_program('dtrace', required: true)
stap = find_program('stap', required: false)
if stap.found()
# Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
# visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
# instead. QEMU --enable-modules depends on this because the SystemTap
# semaphores are linked into the main binary and not the module's shared
# object.
add_global_arguments('-DSTAP_SDT_V2',
native: false, language: all_languages)
endif
endif
if get_option('iasl') == ''
iasl = find_program('iasl', required: false)
else
iasl = find_program(get_option('iasl'), required: true)
endif
edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu', 'riscv64-softmmu' ]
unpack_edk2_blobs = false
foreach target : edk2_targets
if target in target_dirs
bzip2 = find_program('bzip2', required: get_option('install_blobs'))
unpack_edk2_blobs = bzip2.found()
break
endif
endforeach
#####################
# Option validation #
#####################
# Fuzzing
if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
not cc.links('''
#include <stdint.h>
#include <sys/types.h>
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
''',
args: ['-Werror', '-fsanitize=fuzzer'])
error('Your compiler does not support -fsanitize=fuzzer')
endif
# Tracing backends
if 'ftrace' in get_option('trace_backends') and host_os != 'linux'
error('ftrace is supported only on Linux')
endif
if 'syslog' in get_option('trace_backends') and not cc.compiles('''
#include <syslog.h>
int main(void) {
openlog("qemu", LOG_PID, LOG_DAEMON);
syslog(LOG_INFO, "configure");
return 0;
}''')
error('syslog is not supported on this system')
endif
# Miscellaneous Linux-only features
get_option('mpath') \
.require(host_os == 'linux', error_message: 'Multipath is supported only on Linux')
multiprocess_allowed = get_option('multiprocess') \
.require(host_os == 'linux', error_message: 'Multiprocess QEMU is supported only on Linux') \
.allowed()
vfio_user_server_allowed = get_option('vfio_user_server') \
.require(host_os == 'linux', error_message: 'vfio-user server is supported only on Linux') \
.allowed()
have_tpm = get_option('tpm') \
.require(host_os != 'windows', error_message: 'TPM emulation only available on POSIX systems') \
.allowed()
# vhost
have_vhost_user = get_option('vhost_user') \
.disable_auto_if(host_os != 'linux') \
.require(host_os != 'windows',
error_message: 'vhost-user is not available on Windows').allowed()
have_vhost_vdpa = get_option('vhost_vdpa') \
.require(host_os == 'linux',
error_message: 'vhost-vdpa is only available on Linux').allowed()
have_vhost_kernel = get_option('vhost_kernel') \
.require(host_os == 'linux',
error_message: 'vhost-kernel is only available on Linux').allowed()
have_vhost_user_crypto = get_option('vhost_crypto') \
.require(have_vhost_user,
error_message: 'vhost-crypto requires vhost-user to be enabled').allowed()
have_vhost = have_vhost_user or have_vhost_vdpa or have_vhost_kernel
have_vhost_net_user = have_vhost_user and get_option('vhost_net').allowed()
have_vhost_net_vdpa = have_vhost_vdpa and get_option('vhost_net').allowed()
have_vhost_net_kernel = have_vhost_kernel and get_option('vhost_net').allowed()
have_vhost_net = have_vhost_net_kernel or have_vhost_net_user or have_vhost_net_vdpa
# type of binaries to build
have_linux_user = false
have_bsd_user = false
have_system = false
foreach target : target_dirs
have_linux_user = have_linux_user or target.endswith('linux-user')
have_bsd_user = have_bsd_user or target.endswith('bsd-user')
have_system = have_system or target.endswith('-softmmu')
endforeach
have_user = have_linux_user or have_bsd_user
have_tools = get_option('tools') \
.disable_auto_if(not have_system) \
.allowed()
have_ga = get_option('guest_agent') \
.disable_auto_if(not have_system and not have_tools) \
.require(host_os in ['sunos', 'linux', 'windows', 'freebsd', 'netbsd', 'openbsd'],
error_message: 'unsupported OS for QEMU guest agent') \
.allowed()
have_block = have_system or have_tools
enable_modules = get_option('modules') \
.require(host_os != 'windows',
error_message: 'Modules are not available for Windows') \
.require(not get_option('prefer_static'),
error_message: 'Modules are incompatible with static linking') \
.allowed()
#######################################
# Variables for host and accelerators #
#######################################
if cpu not in supported_cpus
host_arch = 'unknown'
elif cpu == 'x86'
host_arch = 'i386'
elif cpu == 'mips64'
host_arch = 'mips'
elif cpu in ['riscv32', 'riscv64']
host_arch = 'riscv'
else
host_arch = cpu
endif
if cpu in ['x86', 'x86_64']
kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
elif cpu == 'aarch64'
kvm_targets = ['aarch64-softmmu']
elif cpu == 's390x'
kvm_targets = ['s390x-softmmu']
elif cpu in ['ppc', 'ppc64']
kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
elif cpu in ['mips', 'mips64']
kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
elif cpu in ['riscv32']
kvm_targets = ['riscv32-softmmu']
elif cpu in ['riscv64']
kvm_targets = ['riscv64-softmmu']
elif cpu in ['loongarch64']
kvm_targets = ['loongarch64-softmmu']
else
kvm_targets = []
endif
accelerator_targets = { 'CONFIG_KVM': kvm_targets }
if cpu in ['x86', 'x86_64']
xen_targets = ['i386-softmmu', 'x86_64-softmmu']
elif cpu in ['arm', 'aarch64']
# i386 emulator provides xenpv machine type for multiple architectures
xen_targets = ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu']
else
xen_targets = []
endif
accelerator_targets += { 'CONFIG_XEN': xen_targets }
if cpu in ['aarch64']
accelerator_targets += {
'CONFIG_HVF': ['aarch64-softmmu']
}
endif
if cpu in ['x86', 'x86_64']
accelerator_targets += {
'CONFIG_HVF': ['x86_64-softmmu'],
'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'],
'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
}
endif
modular_tcg = []
# Darwin does not support references to thread-local variables in modules
if host_os != 'darwin'
modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
endif
##################
# Compiler flags #
##################
foreach lang : all_languages
compiler = meson.get_compiler(lang)
if compiler.get_id() == 'gcc' and compiler.version().version_compare('>=7.4')
# ok
elif compiler.get_id() == 'clang' and compiler.compiles('''
#ifdef __apple_build_version__
# if __clang_major__ < 12 || (__clang_major__ == 12 && __clang_minor__ < 0)
# error You need at least XCode Clang v12.0 to compile QEMU
# endif
#else
# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
# error You need at least Clang v10.0 to compile QEMU
# endif
#endif''')
# ok
else
error('You either need GCC v7.4 or Clang v10.0 (or XCode Clang v12.0) to compile QEMU')
endif
endforeach
# default flags for all hosts
# We use -fwrapv to tell the compiler that we require a C dialect where
# left shift of signed integers is well defined and has the expected
# 2s-complement style results. (Both clang and gcc agree that it
# provides these semantics.)
qemu_common_flags = [
'-D_GNU_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE',
'-fno-strict-aliasing', '-fno-common', '-fwrapv' ]
qemu_cflags = []
qemu_ldflags = []
if host_os == 'darwin'
# Disable attempts to use ObjectiveC features in os/object.h since they
# won't work when we're compiling with gcc as a C compiler.
if compiler.get_id() == 'gcc'
qemu_common_flags += '-DOS_OBJECT_USE_OBJC=0'
endif
elif host_os == 'sunos'
# needed for CMSG_ macros in sys/socket.h
qemu_common_flags += '-D_XOPEN_SOURCE=600'
# needed for TIOCWIN* defines in termios.h
qemu_common_flags += '-D__EXTENSIONS__'
elif host_os == 'haiku'
qemu_common_flags += ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE', '-fPIC']
elif host_os == 'windows'
if not compiler.compiles('struct x { int y; } __attribute__((gcc_struct));',
args: '-Werror')
error('Your compiler does not support __attribute__((gcc_struct)) - please use GCC instead of Clang')
endif
endif
# __sync_fetch_and_and requires at least -march=i486. Many toolchains
# use i686 as default anyway, but for those that don't, an explicit
# specification is necessary
if host_arch == 'i386' and not cc.links('''
static int sfaa(int *ptr)
{
return __sync_fetch_and_and(ptr, 0);
}
int main(void)
{
int val = 42;
val = __sync_val_compare_and_swap(&val, 0, 1);
sfaa(&val);
return val;
}''')
qemu_common_flags = ['-march=i486'] + qemu_common_flags
endif
# Pick x86-64 baseline version
if host_arch in ['i386', 'x86_64']
if get_option('x86_version') == '0' and host_arch == 'x86_64'
error('x86_64-v1 required for x86-64 hosts')
endif
# add flags for individual instruction set extensions
if get_option('x86_version') >= '1'
if host_arch == 'i386'
qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags
else
# present on basically all processors but technically not part of
# x86-64-v1, so only include -mneeded for x86-64 version 2 and above
qemu_common_flags = ['-mcx16'] + qemu_common_flags
endif
endif
if get_option('x86_version') >= '2'
qemu_common_flags = ['-mpopcnt'] + qemu_common_flags
qemu_common_flags = cc.get_supported_arguments('-mneeded') + qemu_common_flags
endif
if get_option('x86_version') >= '3'
qemu_common_flags = ['-mmovbe', '-mabm', '-mbmi1', '-mbmi2', '-mfma', '-mf16c'] + qemu_common_flags
endif
# add required vector instruction set (each level implies those below)
if get_option('x86_version') == '1'
qemu_common_flags = ['-msse2'] + qemu_common_flags
elif get_option('x86_version') == '2'
qemu_common_flags = ['-msse4.2'] + qemu_common_flags
elif get_option('x86_version') == '3'
qemu_common_flags = ['-mavx2'] + qemu_common_flags
elif get_option('x86_version') == '4'
qemu_common_flags = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl'] + qemu_common_flags
endif
endif
if get_option('prefer_static')
qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
endif
# Meson currently only handles pie as a boolean for now, so if the user
# has explicitly disabled PIE we need to extend our cflags.
#
# -no-pie is supposedly a linker flag that has no effect on the compiler
# command line, but some distros, that didn't quite know what they were
# doing, made local changes to gcc's specs file that turned it into
# a compiler command-line flag.
#
# What about linker flags? For a static build, no PIE is implied by -static
# which we added above (and if it's not because of the same specs patching,
# there's nothing we can do: compilation will fail, report a bug to your
# distro and do not use --disable-pie in the meanwhile). For dynamic linking,
# instead, we can't add -no-pie because it overrides -shared: the linker then
# tries to build an executable instead of a shared library and fails. So
# don't add -no-pie anywhere and cross fingers. :(
if not get_option('b_pie')
qemu_common_flags += cc.get_supported_arguments('-fno-pie', '-no-pie')
endif
if not get_option('stack_protector').disabled()
stack_protector_probe = '''
int main(int argc, char *argv[])
{
char arr[64], *p = arr, *c = argv[argc - 1];
while (*c) {
*p++ = *c++;
}
return 0;
}'''
have_stack_protector = false
foreach arg : ['-fstack-protector-strong', '-fstack-protector-all']
# We need to check both a compile and a link, since some compiler
# setups fail only on a .c->.o compile and some only at link time
if cc.compiles(stack_protector_probe, args: ['-Werror', arg]) and \
cc.links(stack_protector_probe, args: ['-Werror', arg])
have_stack_protector = true
qemu_cflags += arg
qemu_ldflags += arg
break
endif
endforeach
get_option('stack_protector') \
.require(have_stack_protector, error_message: 'Stack protector not supported')
endif
coroutine_backend = get_option('coroutine_backend')
ucontext_probe = '''
#include <ucontext.h>
#ifdef __stub_makecontext
#error Ignoring glibc stub makecontext which will always fail
#endif
int main(void) { makecontext(0, 0, 0); return 0; }'''
# On Windows the only valid backend is the Windows specific one.
# For POSIX prefer ucontext, but it's not always possible. The fallback
# is sigcontext.
supported_backends = []
if host_os == 'windows'
supported_backends += ['windows']
else
if host_os != 'darwin' and cc.links(ucontext_probe)
supported_backends += ['ucontext']
endif
supported_backends += ['sigaltstack']
endif
if coroutine_backend == 'auto'
coroutine_backend = supported_backends[0]
elif coroutine_backend not in supported_backends
error('"@0@" backend requested but not available. Available backends: @1@' \
.format(coroutine_backend, ', '.join(supported_backends)))
endif
# Compiles if SafeStack *not* enabled
safe_stack_probe = '''
int main(void)
{
#if defined(__has_feature)
#if __has_feature(safe_stack)
#error SafeStack Enabled
#endif
#endif
return 0;
}'''
if get_option('safe_stack') != not cc.compiles(safe_stack_probe)
safe_stack_arg = get_option('safe_stack') ? '-fsanitize=safe-stack' : '-fno-sanitize=safe-stack'
if get_option('safe_stack') != not cc.compiles(safe_stack_probe, args: safe_stack_arg)
error(get_option('safe_stack') \
? 'SafeStack not supported by your compiler' \
: 'Cannot disable SafeStack')
endif
qemu_cflags += safe_stack_arg
qemu_ldflags += safe_stack_arg
endif
if get_option('safe_stack') and coroutine_backend != 'ucontext'
error('SafeStack is only supported with the ucontext coroutine backend')
endif
if get_option('asan')
if cc.has_argument('-fsanitize=address')
qemu_cflags = ['-fsanitize=address'] + qemu_cflags
qemu_ldflags = ['-fsanitize=address'] + qemu_ldflags
else
error('Your compiler does not support -fsanitize=address')
endif
endif
if get_option('ubsan')
# Detect static linking issue with ubsan:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
if cc.links('int main(int argc, char **argv) { return argc + 1; }',
args: [qemu_ldflags, '-fsanitize=undefined'])
qemu_cflags += ['-fsanitize=undefined']
qemu_ldflags += ['-fsanitize=undefined']
# Suppress undefined behaviour from function call to mismatched type.
# In addition, tcg prologue does not emit function type prefix
# required by function call sanitizer.
if cc.has_argument('-fno-sanitize=function')
qemu_cflags += ['-fno-sanitize=function']
endif
else
error('Your compiler does not support -fsanitize=undefined')
endif
endif
# Thread sanitizer is, for now, much noisier than the other sanitizers;
# keep it separate until that is not the case.
if get_option('tsan')
if get_option('asan') or get_option('ubsan')
error('TSAN is not supported with other sanitizers')
endif
if not cc.has_function('__tsan_create_fiber',
args: '-fsanitize=thread',
prefix: '#include <sanitizer/tsan_interface.h>')
error('Cannot enable TSAN due to missing fiber annotation interface')
endif
qemu_cflags = ['-fsanitize=thread'] + qemu_cflags
qemu_ldflags = ['-fsanitize=thread'] + qemu_ldflags
endif
# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
# The combination is known as "full relro", because .got.plt is read-only too.
qemu_ldflags += cc.get_supported_link_arguments('-Wl,-z,relro', '-Wl,-z,now')
if host_os == 'windows'
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--no-seh', '-Wl,--nxcompat')
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--dynamicbase', '-Wl,--high-entropy-va')
endif
if get_option('fuzzing')
# Specify a filter to only instrument code that is directly related to
# virtual-devices.
configure_file(output: 'instrumentation-filter',
input: 'scripts/oss-fuzz/instrumentation-filter-template',
copy: true)
if cc.compiles('int main () { return 0; }',
name: '-fsanitize-coverage-allowlist=/dev/null',
args: ['-fsanitize-coverage-allowlist=/dev/null',
'-fsanitize-coverage=trace-pc'] )
qemu_common_flags += ['-fsanitize-coverage-allowlist=instrumentation-filter']
endif
if get_option('fuzzing_engine') == ''
# Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
# compiled code. To build non-fuzzer binaries with --enable-fuzzing, link
# everything with fsanitize=fuzzer-no-link. Otherwise, the linker will be
# unable to bind the fuzzer-related callbacks added by instrumentation.
qemu_common_flags += ['-fsanitize=fuzzer-no-link']
qemu_ldflags += ['-fsanitize=fuzzer-no-link']
# For the actual fuzzer binaries, we need to link against the libfuzzer
# library. They need to be configurable, to support OSS-Fuzz
fuzz_exe_ldflags = ['-fsanitize=fuzzer']
else
# LIB_FUZZING_ENGINE was set; assume we are running on OSS-Fuzz, and
# the needed CFLAGS have already been provided
fuzz_exe_ldflags = get_option('fuzzing_engine').split()
endif
endif
if get_option('cfi')
cfi_flags=[]
# Check for dependency on LTO
if not get_option('b_lto')
error('Selected Control-Flow Integrity but LTO is disabled')
endif
if enable_modules
error('Selected Control-Flow Integrity is not compatible with modules')
endif
# Check for cfi flags. CFI requires LTO so we can't use
# get_supported_arguments, but need a more complex "compiles" which allows
# custom arguments
if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
args: ['-flto', '-fsanitize=cfi-icall'] )
cfi_flags += '-fsanitize=cfi-icall'
else
error('-fsanitize=cfi-icall is not supported by the compiler')
endif
if cc.compiles('int main () { return 0; }',
name: '-fsanitize-cfi-icall-generalize-pointers',
args: ['-flto', '-fsanitize=cfi-icall',
'-fsanitize-cfi-icall-generalize-pointers'] )
cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
else
error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
endif
if get_option('cfi_debug')
if cc.compiles('int main () { return 0; }',
name: '-fno-sanitize-trap=cfi-icall',
args: ['-flto', '-fsanitize=cfi-icall',
'-fno-sanitize-trap=cfi-icall'] )
cfi_flags += '-fno-sanitize-trap=cfi-icall'
else
error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
endif
endif
add_global_arguments(cfi_flags, native: false, language: all_languages)
add_global_link_arguments(cfi_flags, native: false, language: all_languages)
endif
# Check further flags that make QEMU more robust against malicious parties
hardening_flags = [
# Initialize all stack variables to zero. This makes
# it harder to take advantage of uninitialized stack
# data to drive exploits
'-ftrivial-auto-var-init=zero',
]
# Zero out registers used during a function call
# upon its return. This makes it harder to assemble
# ROP gadgets into something usable
#
# NB: Clang 17 is broken and SEGVs
# https://github.com/llvm/llvm-project/issues/75168
#
# NB2: This clashes with the "retguard" extension of OpenBSD's Clang
# https://gitlab.com/qemu-project/qemu/-/issues/2278
if host_os != 'openbsd' and \
cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }',
name: '-fzero-call-used-regs=used-gpr',
args: ['-O2', '-fzero-call-used-regs=used-gpr'])
hardening_flags += '-fzero-call-used-regs=used-gpr'
endif
qemu_common_flags += cc.get_supported_arguments(hardening_flags)
add_global_arguments(qemu_common_flags, native: false, language: all_languages)
add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
# Collect warning flags we want to set, sorted alphabetically
warn_flags = [
# First enable interesting warnings
'-Wempty-body',
'-Wendif-labels',
'-Wexpansion-to-defined',
'-Wformat-security',
'-Wformat-y2k',
'-Wignored-qualifiers',
'-Wimplicit-fallthrough=2',
'-Winit-self',
'-Wmissing-format-attribute',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wold-style-declaration',
'-Wold-style-definition',
'-Wredundant-decls',
'-Wshadow=local',
'-Wstrict-prototypes',
'-Wtype-limits',
'-Wundef',
'-Wvla',
'-Wwrite-strings',
# Then disable some undesirable warnings
'-Wno-gnu-variable-sized-type-not-at-end',
'-Wno-initializer-overrides',
'-Wno-missing-include-dirs',
'-Wno-psabi',
'-Wno-shift-negative-value',
'-Wno-string-plus-int',
'-Wno-tautological-type-limit-compare',
'-Wno-typedef-redefinition',
]
if host_os != 'darwin'
tsa_has_cleanup = cc.compiles('''
struct __attribute__((capability("mutex"))) mutex {};
void lock(struct mutex *m) __attribute__((acquire_capability(m)));
void unlock(struct mutex *m) __attribute__((release_capability(m)));
void test(void) {
struct mutex __attribute__((cleanup(unlock))) m;
lock(&m);
}
''', args: ['-Wthread-safety', '-Werror'])
if tsa_has_cleanup
warn_flags += ['-Wthread-safety']
endif
endif
# Set up C++ compiler flags
qemu_cxxflags = []
if 'cpp' in all_languages
qemu_cxxflags = ['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'] + qemu_cflags
endif
add_project_arguments(qemu_cflags, native: false, language: 'c')
add_project_arguments(cc.get_supported_arguments(warn_flags), native: false, language: 'c')
if 'cpp' in all_languages
add_project_arguments(qemu_cxxflags, native: false, language: 'cpp')
add_project_arguments(cxx.get_supported_arguments(warn_flags), native: false, language: 'cpp')
endif
if 'objc' in all_languages
# Note sanitizer flags are not applied to Objective-C sources!
add_project_arguments(objc.get_supported_arguments(warn_flags), native: false, language: 'objc')
endif
if host_os == 'linux'
add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
'-isystem', 'linux-headers',
language: all_languages)
endif
add_project_arguments('-iquote', '.',
'-iquote', meson.current_source_dir(),
'-iquote', meson.current_source_dir() / 'include',
language: all_languages)
# If a host-specific include directory exists, list that first...
host_include = meson.current_source_dir() / 'host/include/'
if fs.is_dir(host_include / host_arch)
add_project_arguments('-iquote', host_include / host_arch,
language: all_languages)
endif
# ... followed by the generic fallback.
add_project_arguments('-iquote', host_include / 'generic',
language: all_languages)
sparse = find_program('cgcc', required: get_option('sparse'))
if sparse.found()
run_target('sparse',
command: [find_program('scripts/check_sparse.py'),
'compile_commands.json', sparse.full_path(), '-Wbitwise',
'-Wno-transparent-union', '-Wno-old-initializer',
'-Wno-non-pointer-null'])
endif
#####################################
# Host-specific libraries and flags #
#####################################
libm = cc.find_library('m', required: false)
threads = dependency('threads')
util = cc.find_library('util', required: false)
winmm = []
socket = []
version_res = []
coref = []
iokit = []
emulator_link_args = []
midl = not_found
widl = not_found
pathcch = not_found
host_dsosuf = '.so'
if host_os == 'windows'
midl = find_program('midl', required: false)
widl = find_program('widl', required: false)
pathcch = cc.find_library('pathcch')
socket = cc.find_library('ws2_32')
winmm = cc.find_library('winmm')
win = import('windows')
version_res = win.compile_resources('version.rc',
depend_files: files('pc-bios/qemu-nsis.ico'),
include_directories: include_directories('.'))
host_dsosuf = '.dll'
elif host_os == 'darwin'
coref = dependency('appleframeworks', modules: 'CoreFoundation')
iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
host_dsosuf = '.dylib'
elif host_os == 'sunos'
socket = [cc.find_library('socket'),
cc.find_library('nsl'),
cc.find_library('resolv')]
elif host_os == 'haiku'
socket = [cc.find_library('posix_error_mapper'),
cc.find_library('network'),
cc.find_library('bsd')]
elif host_os == 'openbsd'
if get_option('tcg').allowed() and target_dirs.length() > 0
# Disable OpenBSD W^X if available
emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
endif
endif
###############################################
# Host-specific configuration of accelerators #
###############################################
accelerators = []
if get_option('kvm').allowed() and host_os == 'linux'
accelerators += 'CONFIG_KVM'
endif
if get_option('whpx').allowed() and host_os == 'windows'
if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
error('WHPX requires 64-bit host')
elif cc.has_header('winhvplatform.h', required: get_option('whpx')) and \
cc.has_header('winhvemulation.h', required: get_option('whpx'))
accelerators += 'CONFIG_WHPX'
endif
endif
hvf = not_found
if get_option('hvf').allowed()
hvf = dependency('appleframeworks', modules: 'Hypervisor',
required: get_option('hvf'))
if hvf.found()
accelerators += 'CONFIG_HVF'
endif
endif
nvmm = not_found
if host_os == 'netbsd'
nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
if nvmm.found()
accelerators += 'CONFIG_NVMM'
endif
endif
tcg_arch = host_arch
if get_option('tcg').allowed()
if host_arch == 'unknown'
if not get_option('tcg_interpreter')
error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
endif
elif get_option('tcg_interpreter')
warning('Use of the TCG interpreter is not recommended on this host')
warning('architecture. There is a native TCG execution backend available')
warning('which provides substantially better performance and reliability.')
warning('It is strongly recommended to remove the --enable-tcg-interpreter')
warning('configuration option on this architecture to use the native')
warning('backend.')
endif
if get_option('tcg_interpreter')
tcg_arch = 'tci'
elif host_arch == 'x86_64'
tcg_arch = 'i386'
elif host_arch == 'ppc64'
tcg_arch = 'ppc'
endif
add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
language: all_languages)
accelerators += 'CONFIG_TCG'
endif
if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
error('KVM not available on this platform')
endif
if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
error('HVF not available on this platform')
endif
if 'CONFIG_NVMM' not in accelerators and get_option('nvmm').enabled()
error('NVMM not available on this platform')
endif
if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
error('WHPX not available on this platform')
endif
xen = not_found
if get_option('xen').enabled() or (get_option('xen').auto() and have_system)
xencontrol = dependency('xencontrol', required: false,
method: 'pkg-config')
if xencontrol.found()
xen_pc = declare_dependency(version: xencontrol.version(),
dependencies: [
xencontrol,
# disabler: true makes xen_pc.found() return false if any is not found
dependency('xenstore', required: false,
method: 'pkg-config',
disabler: true),
dependency('xenforeignmemory', required: false,
method: 'pkg-config',
disabler: true),
dependency('xengnttab', required: false,
method: 'pkg-config',
disabler: true),
dependency('xenevtchn', required: false,
method: 'pkg-config',
disabler: true),
dependency('xendevicemodel', required: false,
method: 'pkg-config',
disabler: true),
# optional, no "disabler: true"
dependency('xentoolcore', required: false,
method: 'pkg-config')])
if xen_pc.found()
xen = xen_pc
endif
endif
if not xen.found()
xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1' ]
xen_libs = {
'4.11.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
'4.10.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
'4.9.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
'4.8.0': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
'4.7.1': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
}
xen_deps = {}
foreach ver: xen_tests
# cache the various library tests to avoid polluting the logs
xen_test_deps = []
foreach l: xen_libs[ver]
if l not in xen_deps
xen_deps += { l: cc.find_library(l, required: false) }
endif
xen_test_deps += xen_deps[l]
endforeach
# Use -D to pick just one of the test programs in scripts/xen-detect.c
xen_version = ver.split('.')
xen_ctrl_version = xen_version[0] + \
('0' + xen_version[1]).substring(-2) + \
('0' + xen_version[2]).substring(-2)
if cc.links(files('scripts/xen-detect.c'),
args: '-DCONFIG_XEN_CTRL_INTERFACE_VERSION=' + xen_ctrl_version,
dependencies: xen_test_deps)
xen = declare_dependency(version: ver, dependencies: xen_test_deps)
break
endif
endforeach
endif
if xen.found()
accelerators += 'CONFIG_XEN'
elif get_option('xen').enabled()
error('could not compile and link Xen test program')
endif
endif
have_xen_pci_passthrough = get_option('xen_pci_passthrough') \
.require(xen.found(),
error_message: 'Xen PCI passthrough requested but Xen not enabled') \
.require(host_os == 'linux',
error_message: 'Xen PCI passthrough not available on this platform') \
.require(cpu == 'x86' or cpu == 'x86_64',
error_message: 'Xen PCI passthrough not available on this platform') \
.allowed()
################
# Dependencies #
################
# When bumping glib minimum version, please check also whether to increase
# the _WIN32_WINNT setting in osdep.h according to the value from glib
glib_req_ver = '>=2.66.0'
glib_pc = dependency('glib-2.0', version: glib_req_ver, required: true,
method: 'pkg-config')
glib_cflags = []
if enable_modules
gmodule = dependency('gmodule-export-2.0', version: glib_req_ver, required: true,
method: 'pkg-config')
elif get_option('plugins')
gmodule = dependency('gmodule-no-export-2.0', version: glib_req_ver, required: true,
method: 'pkg-config')
else
gmodule = not_found
endif
# This workaround is required due to a bug in pkg-config file for glib as it
# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
if host_os == 'windows' and get_option('prefer_static')
glib_cflags += ['-DGLIB_STATIC_COMPILATION']
endif
# Sanity check that the current size_t matches the
# size that glib thinks it should be. This catches
# problems on multi-arch where people try to build
# 32-bit QEMU while pointing at 64-bit glib headers
if not cc.compiles('''
#include <glib.h>
#include <unistd.h>
#define QEMU_BUILD_BUG_ON(x) \
typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
int main(void) {
QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
return 0;
}''', dependencies: glib_pc, args: glib_cflags)
error('''sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T.
You probably need to set PKG_CONFIG_LIBDIR" to point
to the right pkg-config files for your build target.''')
endif
glib = declare_dependency(dependencies: [glib_pc, gmodule],
compile_args: glib_cflags,
version: glib_pc.version())
# Check whether glib has gslice, which we have to avoid for correctness.
# TODO: remove this check and the corresponding workaround (qtree) when
# the minimum supported glib is >= 2.75.3
glib_has_gslice = glib.version().version_compare('<2.75.3')
# override glib dep to include the above refinements
meson.override_dependency('glib-2.0', glib)
# The path to glib.h is added to all compilation commands.
add_project_dependencies(glib.partial_dependency(compile_args: true, includes: true),
native: false, language: all_languages)
gio = not_found
gdbus_codegen = not_found
gdbus_codegen_error = '@0@ requires gdbus-codegen, please install libgio'
if not get_option('gio').auto() or have_system
gio = dependency('gio-2.0', required: get_option('gio'),
method: 'pkg-config')
if gio.found() and not cc.links('''
#include <gio/gio.h>
int main(void)
{
g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
return 0;
}''', dependencies: [glib, gio])
if get_option('gio').enabled()
error('The installed libgio is broken for static linking')
endif
gio = not_found
endif
if gio.found()
gdbus_codegen = find_program(gio.get_variable('gdbus_codegen'),
required: get_option('gio'))
gio_unix = dependency('gio-unix-2.0', required: get_option('gio'),
method: 'pkg-config')
gio = declare_dependency(dependencies: [gio, gio_unix],
version: gio.version())
endif
endif
if gdbus_codegen.found() and get_option('cfi')
gdbus_codegen = not_found
gdbus_codegen_error = '@0@ uses gdbus-codegen, which does not support control flow integrity'
endif
xml_pp = find_program('scripts/xml-preprocess.py')
lttng = not_found
if 'ust' in get_option('trace_backends')
lttng = dependency('lttng-ust', required: true, version: '>= 2.1',
method: 'pkg-config')
endif
pixman = not_found
if not get_option('pixman').auto() or have_system or have_tools
pixman = dependency('pixman-1', required: get_option('pixman'), version:'>=0.21.8',
method: 'pkg-config')
endif
zlib = dependency('zlib', required: true)
libaio = not_found
if not get_option('linux_aio').auto() or have_block
libaio = cc.find_library('aio', has_headers: ['libaio.h'],
required: get_option('linux_aio'))
endif
linux_io_uring_test = '''
#include <liburing.h>
#include <linux/errqueue.h>
int main(void) { return 0; }'''
linux_io_uring = not_found
if not get_option('linux_io_uring').auto() or have_block
linux_io_uring = dependency('liburing', version: '>=0.3',
required: get_option('linux_io_uring'),
method: 'pkg-config')
if not cc.links(linux_io_uring_test)
linux_io_uring = not_found
endif
endif
libnfs = not_found
if not get_option('libnfs').auto() or have_block
libnfs = dependency('libnfs', version: '>=1.9.3',
required: get_option('libnfs'),
method: 'pkg-config')
endif
libattr_test = '''
#include <stddef.h>
#include <sys/types.h>
#ifdef CONFIG_LIBATTR
#include <attr/xattr.h>
#else
#include <sys/xattr.h>
#endif
int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }'''
libattr = not_found
have_old_libattr = false
if get_option('attr').allowed()
if cc.links(libattr_test)
libattr = declare_dependency()
else
libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'],
required: get_option('attr'))
if libattr.found() and not \
cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR')
libattr = not_found
if get_option('attr').enabled()
error('could not link libattr')
else
warning('could not link libattr, disabling')
endif
else
have_old_libattr = libattr.found()
endif
endif
endif
cocoa = dependency('appleframeworks',
modules: ['Cocoa', 'CoreVideo', 'QuartzCore'],
required: get_option('cocoa'))
vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet'))
if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h',
'VMNET_BRIDGED_MODE',
dependencies: vmnet)
vmnet = not_found
if get_option('vmnet').enabled()
error('vmnet.framework API is outdated')
else
warning('vmnet.framework API is outdated, disabling')
endif
endif
seccomp = not_found
seccomp_has_sysrawrc = false
if not get_option('seccomp').auto() or have_system or have_tools
seccomp = dependency('libseccomp', version: '>=2.3.0',
required: get_option('seccomp'),
method: 'pkg-config')
if seccomp.found()
seccomp_has_sysrawrc = cc.has_header_symbol('seccomp.h',
'SCMP_FLTATR_API_SYSRAWRC',
dependencies: seccomp)
endif
endif
libcap_ng = not_found
if not get_option('cap_ng').auto() or have_system or have_tools
libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'],
required: get_option('cap_ng'))
endif
if libcap_ng.found() and not cc.links('''
#include <cap-ng.h>
int main(void)
{
capng_capability_to_name(CAPNG_EFFECTIVE);
return 0;
}''', dependencies: libcap_ng)
libcap_ng = not_found
if get_option('cap_ng').enabled()
error('could not link libcap-ng')
else
warning('could not link libcap-ng, disabling')
endif
endif
if get_option('xkbcommon').auto() and not have_system and not have_tools
xkbcommon = not_found
else
xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
method: 'pkg-config')
endif
slirp = not_found
if not get_option('slirp').auto() or have_system
slirp = dependency('slirp', required: get_option('slirp'),
method: 'pkg-config')
# slirp < 4.7 is incompatible with CFI support in QEMU. This is because
# it passes function pointers within libslirp as callbacks for timers.
# When using a system-wide shared libslirp, the type information for the
# callback is missing and the timer call produces a false positive with CFI.
# Do not use the "version" keyword argument to produce a better error.
# with control-flow integrity.
if get_option('cfi') and slirp.found() and slirp.version().version_compare('<4.7')
if get_option('slirp').enabled()
error('Control-Flow Integrity requires libslirp 4.7.')
else
warning('Cannot use libslirp since Control-Flow Integrity requires libslirp >= 4.7.')
slirp = not_found
endif
endif
endif
vde = not_found
if not get_option('vde').auto() or have_system or have_tools
vde = cc.find_library('vdeplug', has_headers: ['libvdeplug.h'],
required: get_option('vde'))
endif
if vde.found() and not cc.links('''
#include <libvdeplug.h>
int main(void)
{
struct vde_open_args a = {0, 0, 0};
char s[] = "";
vde_open(s, s, &a);
return 0;
}''', dependencies: vde)
vde = not_found
if get_option('cap_ng').enabled()
error('could not link libvdeplug')
else
warning('could not link libvdeplug, disabling')
endif
endif
pulse = not_found
if not get_option('pa').auto() or (host_os == 'linux' and have_system)
pulse = dependency('libpulse', required: get_option('pa'),
method: 'pkg-config')
endif
alsa = not_found
if not get_option('alsa').auto() or (host_os == 'linux' and have_system)
alsa = dependency('alsa', required: get_option('alsa'),
method: 'pkg-config')
endif
jack = not_found
if not get_option('jack').auto() or have_system
jack = dependency('jack', required: get_option('jack'),
method: 'pkg-config')
endif
pipewire = not_found
if not get_option('pipewire').auto() or (host_os == 'linux' and have_system)
pipewire = dependency('libpipewire-0.3', version: '>=0.3.60',
required: get_option('pipewire'),
method: 'pkg-config')
endif
sndio = not_found
if not get_option('sndio').auto() or have_system
sndio = dependency('sndio', required: get_option('sndio'),
method: 'pkg-config')
endif
spice_protocol = not_found
if not get_option('spice_protocol').auto() or have_system
spice_protocol = dependency('spice-protocol', version: '>=0.14.0',
required: get_option('spice_protocol'),
method: 'pkg-config')
endif
spice = not_found
if get_option('spice') \
.disable_auto_if(not have_system) \
.require(pixman.found(),
error_message: 'cannot enable SPICE if pixman is not available') \
.allowed()
spice = dependency('spice-server', version: '>=0.14.0',
required: get_option('spice'),
method: 'pkg-config')
endif
spice_headers = spice.partial_dependency(compile_args: true, includes: true)
rt = cc.find_library('rt', required: false)
libiscsi = not_found
if not get_option('libiscsi').auto() or have_block
libiscsi = dependency('libiscsi', version: '>=1.9.0',
required: get_option('libiscsi'),
method: 'pkg-config')
endif
zstd = not_found
if not get_option('zstd').auto() or have_block
zstd = dependency('libzstd', version: '>=1.4.0',
required: get_option('zstd'),
method: 'pkg-config')
endif
qpl = not_found
if not get_option('qpl').auto() or have_system
qpl = dependency('qpl', version: '>=1.5.0',
required: get_option('qpl'),
method: 'pkg-config')
endif
uadk = not_found
if not get_option('uadk').auto() or have_system
libwd = dependency('libwd', version: '>=2.6',
required: get_option('uadk'),
method: 'pkg-config')
libwd_comp = dependency('libwd_comp', version: '>=2.6',
required: get_option('uadk'),
method: 'pkg-config')
if libwd.found() and libwd_comp.found()
uadk = declare_dependency(dependencies: [libwd, libwd_comp])
endif
endif
qatzip = not_found
if not get_option('qatzip').auto() or have_system
qatzip = dependency('qatzip', version: '>=1.1.2',
required: get_option('qatzip'),
method: 'pkg-config')
endif
virgl = not_found
have_vhost_user_gpu = have_tools and host_os == 'linux' and pixman.found()
if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu
virgl = dependency('virglrenderer',
method: 'pkg-config',
required: get_option('virglrenderer'))
endif
rutabaga = not_found
if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu
rutabaga = dependency('rutabaga_gfx_ffi',
method: 'pkg-config',
required: get_option('rutabaga_gfx'))
endif
blkio = not_found
if not get_option('blkio').auto() or have_block
blkio = dependency('blkio',
method: 'pkg-config',
required: get_option('blkio'))
endif
curl = not_found
if not get_option('curl').auto() or have_block
curl = dependency('libcurl', version: '>=7.29.0',
method: 'pkg-config',
required: get_option('curl'))
endif
libudev = not_found
if host_os == 'linux' and (have_system or have_tools)
libudev = dependency('libudev',
method: 'pkg-config',
required: get_option('libudev'))
endif
mpathlibs = [libudev]
mpathpersist = not_found
if host_os == 'linux' and have_tools and get_option('mpath').allowed()
mpath_test_source = '''
#include <libudev.h>
#include <mpath_persist.h>
unsigned mpath_mx_alloc_len = 1024;
int logsink;
static struct config *multipath_conf;
extern struct udev *udev;
extern struct config *get_multipath_config(void);
extern void put_multipath_config(struct config *conf);
struct udev *udev;
struct config *get_multipath_config(void) { return multipath_conf; }
void put_multipath_config(struct config *conf) { }
int main(void) {
udev = udev_new();
multipath_conf = mpath_lib_init();
return 0;
}'''
libmpathpersist = cc.find_library('mpathpersist',
required: get_option('mpath'))
if libmpathpersist.found()
mpathlibs += libmpathpersist
if get_option('prefer_static')
mpathlibs += cc.find_library('devmapper',
required: get_option('mpath'))
endif
mpathlibs += cc.find_library('multipath',
required: get_option('mpath'))
foreach lib: mpathlibs
if not lib.found()
mpathlibs = []
break
endif
endforeach
if mpathlibs.length() == 0
msg = 'Dependencies missing for libmpathpersist'
elif cc.links(mpath_test_source, dependencies: mpathlibs)
mpathpersist = declare_dependency(dependencies: mpathlibs)
else
msg = 'Cannot detect libmpathpersist API'
endif
if not mpathpersist.found()
if get_option('mpath').enabled()
error(msg)
else
warning(msg + ', disabling')
endif
endif
endif
endif
iconv = not_found
curses = not_found
if have_system and get_option('curses').allowed()
curses_test = '''
#if defined(__APPLE__) || defined(__OpenBSD__)
#define _XOPEN_SOURCE_EXTENDED 1
#endif
#include <locale.h>
#include <curses.h>
#include <wchar.h>
int main(void) {
wchar_t wch = L'w';
setlocale(LC_ALL, "");
resize_term(0, 0);
addwstr(L"wide chars\n");
addnwstr(&wch, 1);
add_wch(WACS_DEGREE);
return 0;
}'''
curses_dep_list = host_os == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
curses = dependency(curses_dep_list,
required: false,
method: 'pkg-config')
msg = get_option('curses').enabled() ? 'curses library not found' : ''
curses_compile_args = ['-DNCURSES_WIDECHAR=1']
if curses.found()
if cc.links(curses_test, args: curses_compile_args, dependencies: [curses])
curses = declare_dependency(compile_args: curses_compile_args, dependencies: [curses],
version: curses.version())
else
msg = 'curses package not usable'
curses = not_found
endif
endif
if not curses.found()
has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
if host_os != 'windows' and not has_curses_h
message('Trying with /usr/include/ncursesw')
curses_compile_args += ['-I/usr/include/ncursesw']
has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
endif
if has_curses_h
curses_libname_list = (host_os == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
foreach curses_libname : curses_libname_list
libcurses = cc.find_library(curses_libname,
required: false)
if libcurses.found()
if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
curses = declare_dependency(compile_args: curses_compile_args,
dependencies: [libcurses])
break
else
msg = 'curses library not usable'
endif
endif
endforeach
endif
endif
if get_option('iconv').allowed()
foreach link_args : [ ['-liconv'], [] ]
# Programs will be linked with glib and this will bring in libiconv on FreeBSD.
# We need to use libiconv if available because mixing libiconv's headers with
# the system libc does not work.
# However, without adding glib to the dependencies -L/usr/local/lib will not be
# included in the command line and libiconv will not be found.
if cc.links('''
#include <iconv.h>
int main(void) {
iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
return conv != (iconv_t) -1;
}''', args: link_args, dependencies: glib)
iconv = declare_dependency(link_args: link_args, dependencies: glib)
break
endif
endforeach
endif
if curses.found() and not iconv.found()
if get_option('iconv').enabled()
error('iconv not available')
endif
msg = 'iconv required for curses UI but not available'
curses = not_found
endif
if not curses.found() and msg != ''
if get_option('curses').enabled()
error(msg)
else
warning(msg + ', disabling')
endif
endif
endif
brlapi = not_found
if not get_option('brlapi').auto() or have_system
brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'],
required: get_option('brlapi'))
if brlapi.found() and not cc.links('''
#include <brlapi.h>
#include <stddef.h>
int main(void) { return brlapi__openConnection (NULL, NULL, NULL); }''', dependencies: brlapi)
brlapi = not_found
if get_option('brlapi').enabled()
error('could not link brlapi')
else
warning('could not link brlapi, disabling')
endif
endif
endif
sdl = not_found
if not get_option('sdl').auto() or have_system
sdl = dependency('sdl2', required: get_option('sdl'))
sdl_image = not_found
endif
if sdl.found()
# Some versions of SDL have problems with -Wundef
if not cc.compiles('''
#include <SDL.h>
#include <SDL_syswm.h>
int main(int argc, char *argv[]) { return 0; }
''', dependencies: sdl, args: '-Werror=undef')
sdl = declare_dependency(compile_args: '-Wno-undef',
dependencies: sdl,
version: sdl.version())
endif
sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
method: 'pkg-config')
else
if get_option('sdl_image').enabled()
error('sdl-image required, but SDL was @0@'.format(
get_option('sdl').disabled() ? 'disabled' : 'not found'))
endif
sdl_image = not_found
endif
rbd = not_found
if not get_option('rbd').auto() or have_block
librados = cc.find_library('rados', required: get_option('rbd'))
librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
required: get_option('rbd'))
if librados.found() and librbd.found()
if cc.links('''
#include <stdio.h>
#include <rbd/librbd.h>
int main(void) {
rados_t cluster;
rados_create(&cluster, NULL);
#if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 12, 0)
#error
#endif
return 0;
}''', dependencies: [librbd, librados])
rbd = declare_dependency(dependencies: [librbd, librados])
elif get_option('rbd').enabled()
error('librbd >= 1.12.0 required')
else
warning('librbd >= 1.12.0 not found, disabling')
endif
endif
endif
glusterfs = not_found
glusterfs_ftruncate_has_stat = false
glusterfs_iocb_has_stat = false
if not get_option('glusterfs').auto() or have_block
glusterfs = dependency('glusterfs-api', version: '>=3',
required: get_option('glusterfs'),
method: 'pkg-config')
if glusterfs.found()
glusterfs_ftruncate_has_stat = cc.links('''
#include <glusterfs/api/glfs.h>
int
main(void)
{
/* new glfs_ftruncate() passes two additional args */
return glfs_ftruncate(NULL, 0, NULL, NULL);
}
''', dependencies: glusterfs)
glusterfs_iocb_has_stat = cc.links('''
#include <glusterfs/api/glfs.h>
/* new glfs_io_cbk() passes two additional glfs_stat structs */
static void
glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
{}
int
main(void)
{
glfs_io_cbk iocb = &glusterfs_iocb;
iocb(NULL, 0 , NULL, NULL, NULL);
return 0;
}
''', dependencies: glusterfs)
endif
endif
hv_balloon = false
if get_option('hv_balloon').allowed() and have_system
if cc.links('''
#include <string.h>
#include <gmodule.h>
int main(void) {
GTree *tree;
tree = g_tree_new((GCompareFunc)strcmp);
(void)g_tree_node_first(tree);
g_tree_destroy(tree);
return 0;
}
''', dependencies: glib)
hv_balloon = true
else
if get_option('hv_balloon').enabled()
error('could not enable hv-balloon, update your glib')
else
warning('could not find glib support for hv-balloon, disabling')
endif
endif
endif
libssh = not_found
if not get_option('libssh').auto() or have_block
libssh = dependency('libssh', version: '>=0.8.7',
method: 'pkg-config',
required: get_option('libssh'))
endif
libbzip2 = not_found
if not get_option('bzip2').auto() or have_block
libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
required: get_option('bzip2'))
if libbzip2.found() and not cc.links('''
#include <bzlib.h>
int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2)
libbzip2 = not_found
if get_option('bzip2').enabled()
error('could not link libbzip2')
else
warning('could not link libbzip2, disabling')
endif
endif
endif
liblzfse = not_found
if not get_option('lzfse').auto() or have_block
liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'],
required: get_option('lzfse'))
endif
if liblzfse.found() and not cc.links('''
#include <lzfse.h>
int main(void) { lzfse_decode_scratch_size(); return 0; }''', dependencies: liblzfse)
liblzfse = not_found
if get_option('lzfse').enabled()
error('could not link liblzfse')
else
warning('could not link liblzfse, disabling')
endif
endif
oss = not_found
if get_option('oss').allowed() and have_system
if not cc.has_header('sys/soundcard.h')
# not found
elif host_os == 'netbsd'
oss = cc.find_library('ossaudio', required: get_option('oss'))
else
oss = declare_dependency()
endif
if not oss.found()
if get_option('oss').enabled()
error('OSS not found')
endif
endif
endif
dsound = not_found
if not get_option('dsound').auto() or (host_os == 'windows' and have_system)
if cc.has_header('dsound.h')
dsound = declare_dependency(link_args: ['-lole32', '-ldxguid'])
endif
if not dsound.found()
if get_option('dsound').enabled()
error('DirectSound not found')
endif
endif
endif
coreaudio = not_found
if not get_option('coreaudio').auto() or (host_os == 'darwin' and have_system)
coreaudio = dependency('appleframeworks', modules: 'CoreAudio',
required: get_option('coreaudio'))
endif
opengl = not_found
if not get_option('opengl').auto() or have_system or have_vhost_user_gpu
epoxy = dependency('epoxy', method: 'pkg-config',
required: get_option('opengl'))
if cc.has_header('epoxy/egl.h', dependencies: epoxy)
opengl = epoxy
elif get_option('opengl').enabled()
error('epoxy/egl.h not found')
endif
endif
gbm = not_found
if (have_system or have_tools) and (virgl.found() or opengl.found())
gbm = dependency('gbm', method: 'pkg-config', required: false)
endif
have_vhost_user_gpu = have_vhost_user_gpu and virgl.found() and opengl.found() and gbm.found()
gnutls = not_found
gnutls_crypto = not_found
if get_option('gnutls').enabled() or (get_option('gnutls').auto() and have_system)
# For general TLS support our min gnutls matches
# that implied by our platform support matrix
#
# For the crypto backends, we look for a newer
# gnutls:
#
# Version 3.6.8 is needed to get XTS
# Version 3.6.13 is needed to get PBKDF
# Version 3.6.14 is needed to get HW accelerated XTS
#
# If newer enough gnutls isn't available, we can
# still use a different crypto backend to satisfy
# the platform support requirements
gnutls_crypto = dependency('gnutls', version: '>=3.6.14',
method: 'pkg-config',
required: false)
if gnutls_crypto.found()
gnutls = gnutls_crypto
else
# Our min version if all we need is TLS
gnutls = dependency('gnutls', version: '>=3.5.18',
method: 'pkg-config',
required: get_option('gnutls'))
endif
endif
# We prefer use of gnutls for crypto, unless the options
# explicitly asked for nettle or gcrypt.
#
# If gnutls isn't available for crypto, then we'll prefer
# gcrypt over nettle for performance reasons.
gcrypt = not_found
nettle = not_found
hogweed = not_found
crypto_sm4 = not_found
xts = 'none'
if get_option('nettle').enabled() and get_option('gcrypt').enabled()
error('Only one of gcrypt & nettle can be enabled')
endif
# Explicit nettle/gcrypt request, so ignore gnutls for crypto
if get_option('nettle').enabled() or get_option('gcrypt').enabled()
gnutls_crypto = not_found
endif
if not gnutls_crypto.found()
if (not get_option('gcrypt').auto() or have_system) and not get_option('nettle').enabled()
gcrypt = dependency('libgcrypt', version: '>=1.8',
required: get_option('gcrypt'))
# Debian has removed -lgpg-error from libgcrypt-config
# as it "spreads unnecessary dependencies" which in
# turn breaks static builds...
if gcrypt.found() and get_option('prefer_static')
gcrypt = declare_dependency(dependencies:
[gcrypt,
cc.find_library('gpg-error', required: true)],
version: gcrypt.version())
endif
crypto_sm4 = gcrypt
# SM4 ALG is available in libgcrypt >= 1.9
if gcrypt.found() and not cc.links('''
#include <gcrypt.h>
int main(void) {
gcry_cipher_hd_t handler;
gcry_cipher_open(&handler, GCRY_CIPHER_SM4, GCRY_CIPHER_MODE_ECB, 0);
return 0;
}''', dependencies: gcrypt)
crypto_sm4 = not_found
endif
endif
if (not get_option('nettle').auto() or have_system) and not gcrypt.found()
nettle = dependency('nettle', version: '>=3.4',
method: 'pkg-config',
required: get_option('nettle'))
if nettle.found() and not cc.has_header('nettle/xts.h', dependencies: nettle)
xts = 'private'
endif
crypto_sm4 = nettle
# SM4 ALG is available in nettle >= 3.9
if nettle.found() and not cc.links('''
#include <nettle/sm4.h>
int main(void) {
struct sm4_ctx ctx;
unsigned char key[16] = {0};
sm4_set_encrypt_key(&ctx, key);
return 0;
}''', dependencies: nettle)
crypto_sm4 = not_found
endif
endif
endif
capstone = not_found
if not get_option('capstone').auto() or have_system or have_user
capstone = dependency('capstone', version: '>=3.0.5',
method: 'pkg-config',
required: get_option('capstone'))
# Some versions of capstone have broken pkg-config file
# that reports a wrong -I path, causing the #include to
# fail later. If the system has such a broken version
# do not use it.
if capstone.found() and not cc.compiles('#include <capstone.h>',
dependencies: [capstone])
capstone = not_found
if get_option('capstone').enabled()
error('capstone requested, but it does not appear to work')
endif
endif
endif
gmp = dependency('gmp', required: false, method: 'pkg-config')
if nettle.found() and gmp.found()
hogweed = dependency('hogweed', version: '>=3.4',
method: 'pkg-config',
required: get_option('nettle'))
endif
gtk = not_found
gtkx11 = not_found
vte = not_found
have_gtk_clipboard = get_option('gtk_clipboard').enabled()
if get_option('gtk') \
.disable_auto_if(not have_system) \
.require(pixman.found(),
error_message: 'cannot enable GTK if pixman is not available') \
.allowed()
gtk = dependency('gtk+-3.0', version: '>=3.22.0',
method: 'pkg-config',
required: get_option('gtk'))
if gtk.found()
gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0',
method: 'pkg-config',
required: false)
gtk = declare_dependency(dependencies: [gtk, gtkx11],
version: gtk.version())
if not get_option('vte').auto() or have_system
vte = dependency('vte-2.91',
method: 'pkg-config',
required: get_option('vte'))
endif
elif have_gtk_clipboard
error('GTK clipboard requested, but GTK not found')
endif
endif
x11 = not_found
if gtkx11.found()
x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found())
endif
png = not_found
if get_option('png').allowed() and have_system
png = dependency('libpng', version: '>=1.6.34', required: get_option('png'),
method: 'pkg-config')
endif
vnc = not_found
jpeg = not_found
sasl = not_found
if get_option('vnc') \
.disable_auto_if(not have_system) \
.require(pixman.found(),
error_message: 'cannot enable VNC if pixman is not available') \
.allowed()
vnc = declare_dependency() # dummy dependency
jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'),
method: 'pkg-config')
sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
required: get_option('vnc_sasl'))
if sasl.found()
sasl = declare_dependency(dependencies: sasl,
compile_args: '-DSTRUCT_IOVEC_DEFINED')
endif
endif
pam = not_found
if not get_option('auth_pam').auto() or have_system
pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
required: get_option('auth_pam'))
endif
if pam.found() and not cc.links('''
#include <stddef.h>
#include <security/pam_appl.h>
int main(void) {
const char *service_name = "qemu";
const char *user = "frank";
const struct pam_conv pam_conv = { 0 };
pam_handle_t *pamh = NULL;
pam_start(service_name, user, &pam_conv, &pamh);
return 0;
}''', dependencies: pam)
pam = not_found
if get_option('auth_pam').enabled()
error('could not link libpam')
else
warning('could not link libpam, disabling')
endif
endif
snappy = not_found
if not get_option('snappy').auto() or have_system
snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
required: get_option('snappy'))
endif
if snappy.found() and not cc.links('''
#include <snappy-c.h>
int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy)
snappy = not_found
if get_option('snappy').enabled()
error('could not link libsnappy')
else
warning('could not link libsnappy, disabling')
endif
endif
lzo = not_found
if not get_option('lzo').auto() or have_system
lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'],
required: get_option('lzo'))
endif
if lzo.found() and not cc.links('''
#include <lzo/lzo1x.h>
int main(void) { lzo_version(); return 0; }''', dependencies: lzo)
lzo = not_found
if get_option('lzo').enabled()
error('could not link liblzo2')
else
warning('could not link liblzo2, disabling')
endif
endif
numa = not_found
if not get_option('numa').auto() or have_system or have_tools
numa = cc.find_library('numa', has_headers: ['numa.h'],
required: get_option('numa'))
endif
if numa.found() and not cc.links('''
#include <numa.h>
int main(void) { return numa_available(); }
''', dependencies: numa)
numa = not_found
if get_option('numa').enabled()
error('could not link numa')
else
warning('could not link numa, disabling')
endif
endif
fdt = not_found
fdt_opt = get_option('fdt')
if fdt_opt == 'enabled' and get_option('wrap_mode') == 'nodownload'
fdt_opt = 'system'
endif
if fdt_opt in ['enabled', 'system'] or (fdt_opt == 'auto' and have_system)
fdt = cc.find_library('fdt', required: fdt_opt == 'system')
if fdt.found() and cc.links('''
#include <libfdt.h>
#include <libfdt_env.h>
int main(void) { fdt_find_max_phandle(NULL, NULL); return 0; }''',
dependencies: fdt)
fdt_opt = 'system'
elif fdt_opt != 'system'
fdt_opt = get_option('wrap_mode') == 'nodownload' ? 'disabled' : 'internal'
fdt = not_found
else
error('system libfdt is too old (1.5.1 or newer required)')
endif
endif
if fdt_opt == 'internal'
assert(not fdt.found())
libfdt_proj = subproject('dtc', required: true,
default_options: ['tools=false', 'yaml=disabled',
'python=disabled', 'default_library=static'])
fdt = libfdt_proj.get_variable('libfdt_dep')
endif
rdma = not_found
if not get_option('rdma').auto() or have_system
rdma_libs = [cc.find_library('rdmacm', has_headers: ['rdma/rdma_cma.h'],
required: get_option('rdma')),
cc.find_library('ibverbs', required: get_option('rdma'))]
rdma = declare_dependency(dependencies: rdma_libs)
foreach lib: rdma_libs
if not lib.found()
rdma = not_found
endif
endforeach
endif
cacard = not_found
if not get_option('smartcard').auto() or have_system
cacard = dependency('libcacard', required: get_option('smartcard'),
version: '>=2.5.1', method: 'pkg-config')
endif
u2f = not_found
if not get_option('u2f').auto() or have_system
u2f = dependency('u2f-emu', required: get_option('u2f'),
method: 'pkg-config')
endif
canokey = not_found
if not get_option('canokey').auto() or have_system
canokey = dependency('canokey-qemu', required: get_option('canokey'),
method: 'pkg-config')
endif
usbredir = not_found
if not get_option('usb_redir').auto() or have_system
usbredir = dependency('libusbredirparser-0.5', required: get_option('usb_redir'),
version: '>=0.6', method: 'pkg-config')
endif
libusb = not_found
if not get_option('libusb').auto() or have_system
libusb = dependency('libusb-1.0', required: get_option('libusb'),
version: '>=1.0.13', method: 'pkg-config')
endif
libpmem = not_found
if not get_option('libpmem').auto() or have_system
libpmem = dependency('libpmem', required: get_option('libpmem'),
method: 'pkg-config')
endif
libdaxctl = not_found
if not get_option('libdaxctl').auto() or have_system
libdaxctl = dependency('libdaxctl', required: get_option('libdaxctl'),
version: '>=57', method: 'pkg-config')
endif
tasn1 = not_found
if gnutls.found()
tasn1 = dependency('libtasn1',
required: false,
method: 'pkg-config')
endif
keyutils = not_found
if not get_option('libkeyutils').auto() or have_block
keyutils = dependency('libkeyutils', required: get_option('libkeyutils'),
method: 'pkg-config')
endif
has_gettid = cc.has_function('gettid')
# libselinux
selinux = dependency('libselinux',
required: get_option('selinux'),
method: 'pkg-config')
# Malloc tests
malloc = []
if get_option('malloc') == 'system'
has_malloc_trim = \
get_option('malloc_trim').allowed() and \
cc.has_function('malloc_trim', prefix: '#include <malloc.h>')
else
has_malloc_trim = false
malloc = cc.find_library(get_option('malloc'), required: true)
endif
if not has_malloc_trim and get_option('malloc_trim').enabled()
if get_option('malloc') == 'system'
error('malloc_trim not available on this platform.')
else
error('malloc_trim not available with non-libc memory allocator')
endif
endif
gnu_source_prefix = '''
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
'''
# Check whether the glibc provides STATX_BASIC_STATS
has_statx = cc.has_header_symbol('sys/stat.h', 'STATX_BASIC_STATS', prefix: gnu_source_prefix)
# Check whether statx() provides mount ID information
has_statx_mnt_id = cc.has_header_symbol('sys/stat.h', 'STATX_MNT_ID', prefix: gnu_source_prefix)
have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
.require(host_os == 'linux',
error_message: 'vhost_user_blk_server requires linux') \
.require(have_vhost_user,
error_message: 'vhost_user_blk_server requires vhost-user support') \
.disable_auto_if(not have_tools and not have_system) \
.allowed()
if get_option('fuse').disabled() and get_option('fuse_lseek').enabled()
error('Cannot enable fuse-lseek while fuse is disabled')
endif
fuse = dependency('fuse3', required: get_option('fuse'),
version: '>=3.1', method: 'pkg-config')
fuse_lseek = not_found
if get_option('fuse_lseek').allowed()
if fuse.version().version_compare('>=3.8')
# Dummy dependency
fuse_lseek = declare_dependency()
elif get_option('fuse_lseek').enabled()
if fuse.found()
error('fuse-lseek requires libfuse >=3.8, found ' + fuse.version())
else
error('fuse-lseek requires libfuse, which was not found')
endif
endif
endif
have_libvduse = (host_os == 'linux')
if get_option('libvduse').enabled()
if host_os != 'linux'
error('libvduse requires linux')
endif
elif get_option('libvduse').disabled()
have_libvduse = false
endif
have_vduse_blk_export = (have_libvduse and host_os == 'linux')
if get_option('vduse_blk_export').enabled()
if host_os != 'linux'
error('vduse_blk_export requires linux')
elif not have_libvduse
error('vduse_blk_export requires libvduse support')
endif
elif get_option('vduse_blk_export').disabled()
have_vduse_blk_export = false
endif
# libbpf
bpf_version = '1.1.0'
libbpf = dependency('libbpf', version: '>=' + bpf_version, required: get_option('bpf'), method: 'pkg-config')
if libbpf.found() and not cc.links('''
#include <bpf/libbpf.h>
#include <linux/bpf.h>
int main(void)
{
// check flag availability
int flag = BPF_F_MMAPABLE;
bpf_object__destroy_skeleton(NULL);
return 0;
}''', dependencies: libbpf)
libbpf = not_found
if get_option('bpf').enabled()
error('libbpf skeleton/mmaping test failed')
else
warning('libbpf skeleton/mmaping test failed, disabling')
endif
endif
# libxdp
libxdp = not_found
if not get_option('af_xdp').auto() or have_system
libxdp = dependency('libxdp', required: get_option('af_xdp'),
version: '>=1.4.0', method: 'pkg-config')
endif
# libdw
libdw = not_found
if not get_option('libdw').auto() or \
(not get_option('prefer_static') and (have_system or have_user))
libdw = dependency('libdw',
method: 'pkg-config',
required: get_option('libdw'))
endif
#################
# config-host.h #
#################
config_host_data = configuration_data()
audio_drivers_selected = []
if have_system
audio_drivers_available = {
'alsa': alsa.found(),
'coreaudio': coreaudio.found(),
'dsound': dsound.found(),
'jack': jack.found(),
'oss': oss.found(),
'pa': pulse.found(),
'pipewire': pipewire.found(),
'sdl': sdl.found(),
'sndio': sndio.found(),
}
foreach k, v: audio_drivers_available
config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
endforeach
# Default to native drivers first, OSS second, SDL third
audio_drivers_priority = \
[ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
(host_os == 'linux' ? [] : [ 'sdl' ])
audio_drivers_default = []
foreach k: audio_drivers_priority
if audio_drivers_available[k]
audio_drivers_default += k
endif
endforeach
foreach k: get_option('audio_drv_list')
if k == 'default'
audio_drivers_selected += audio_drivers_default
elif not audio_drivers_available[k]
error('Audio driver "@0@" not available.'.format(k))
else
audio_drivers_selected += k
endif
endforeach
endif
config_host_data.set('CONFIG_AUDIO_DRIVERS',
'"' + '", "'.join(audio_drivers_selected) + '", ')
have_host_block_device = (host_os != 'darwin' or
cc.has_header('IOKit/storage/IOMedia.h'))
dbus_display = get_option('dbus_display') \
.require(gio.version().version_compare('>=2.64'),
error_message: '-display dbus requires glib>=2.64') \
.require(gdbus_codegen.found(),
error_message: gdbus_codegen_error.format('-display dbus')) \
.allowed()
have_virtfs = get_option('virtfs') \
.require(host_os == 'linux' or host_os == 'darwin',
error_message: 'virtio-9p (virtfs) requires Linux or macOS') \
.require(host_os == 'linux' or cc.has_function('pthread_fchdir_np'),
error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \
.require(host_os == 'darwin' or libattr.found(),
error_message: 'virtio-9p (virtfs) on Linux requires libattr-devel') \
.disable_auto_if(not have_tools and not have_system) \
.allowed()
have_virtfs_proxy_helper = get_option('virtfs_proxy_helper') \
.require(host_os != 'darwin', error_message: 'the virtfs proxy helper is incompatible with macOS') \
.require(have_virtfs, error_message: 'the virtfs proxy helper requires that virtfs is enabled') \
.disable_auto_if(not have_tools) \
.require(libcap_ng.found(), error_message: 'the virtfs proxy helper requires libcap-ng') \
.allowed()
qga_fsfreeze = false
qga_fstrim = false
if host_os == 'linux'
if cc.has_header_symbol('linux/fs.h', 'FIFREEZE')
qga_fsfreeze = true
endif
if cc.has_header_symbol('linux/fs.h', 'FITRIM')
qga_fstrim = true
endif
elif host_os == 'freebsd' and cc.has_header_symbol('ufs/ffs/fs.h', 'UFSSUSPEND')
qga_fsfreeze = true
endif
if get_option('block_drv_ro_whitelist') == ''
config_host_data.set('CONFIG_BDRV_RO_WHITELIST', '')
else
config_host_data.set('CONFIG_BDRV_RO_WHITELIST',
'"' + get_option('block_drv_ro_whitelist').replace(',', '", "') + '", ')
endif
if get_option('block_drv_rw_whitelist') == ''
config_host_data.set('CONFIG_BDRV_RW_WHITELIST', '')
else
config_host_data.set('CONFIG_BDRV_RW_WHITELIST',
'"' + get_option('block_drv_rw_whitelist').replace(',', '", "') + '", ')
endif
foreach k : get_option('trace_backends')
config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true)
endforeach
config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('trace_file'))
config_host_data.set_quoted('CONFIG_TLS_PRIORITY', get_option('tls_priority'))
if iasl.found()
config_host_data.set_quoted('CONFIG_IASL', iasl.full_path())
endif
config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
qemu_firmwarepath = ''
foreach k : get_option('qemu_firmwarepath')
qemu_firmwarepath += '"' + get_option('prefix') / k + '", '
endforeach
config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_firmwarepath)
config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
if enable_modules
config_host_data.set('CONFIG_STAMP', run_command(
meson.current_source_dir() / 'scripts/qemu-stamp.py',
meson.project_version(), get_option('pkgversion'), '--',
meson.current_source_dir() / 'configure',
capture: true, check: true).stdout().strip())
endif
have_slirp_smbd = get_option('slirp_smbd') \
.require(host_os != 'windows', error_message: 'Host smbd not supported on this platform.') \
.allowed()
if have_slirp_smbd
smbd_path = get_option('smbd')
if smbd_path == ''
smbd_path = (host_os == 'sunos' ? '/usr/sfw/sbin/smbd' : '/usr/sbin/smbd')
endif
config_host_data.set_quoted('CONFIG_SMBD_COMMAND', smbd_path)
endif
config_host_data.set('HOST_' + host_arch.to_upper(), 1)
kvm_targets_c = '""'
if get_option('kvm').allowed() and host_os == 'linux'
kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
endif
config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
if get_option('module_upgrades') and not enable_modules
error('Cannot enable module-upgrades as modules are not enabled')
endif
config_host_data.set('CONFIG_MODULE_UPGRADES', get_option('module_upgrades'))
config_host_data.set('CONFIG_ATTR', libattr.found())
config_host_data.set('CONFIG_BDRV_WHITELIST_TOOLS', get_option('block_drv_whitelist_in_tools'))
config_host_data.set('CONFIG_BRLAPI', brlapi.found())
config_host_data.set('CONFIG_BSD', host_os in bsd_oses)
config_host_data.set('CONFIG_FREEBSD', host_os == 'freebsd')
config_host_data.set('CONFIG_CAPSTONE',