ss = import('sourceset')
fs = import('fs')
+targetos = host_machine.system()
sh = find_program('sh')
-cc = meson.get_compiler('c')
config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
enable_modules = 'CONFIG_MODULES' in config_host
enable_static = 'CONFIG_STATIC' in config_host
# Allow both shared and static libraries unless --enable-static
static_kwargs = enable_static ? {'static': true} : {}
+cc = meson.get_compiler('c')
+all_languages = ['c']
+if add_languages('cpp', required: false, native: false)
+ all_languages += ['cpp']
+ cxx = meson.get_compiler('cpp')
+endif
+if targetos == 'darwin' and \
+ add_languages('objc', required: get_option('cocoa'), native: false)
+ all_languages += ['objc']
+ objc = meson.get_compiler('objc')
+endif
+
# 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
cpu = 'riscv'
endif
-targetos = host_machine.system()
-
target_dirs = config_host['TARGET_DIRS'].split()
have_linux_user = false
have_bsd_user = false
# semaphores are linked into the main binary and not the module's shared
# object.
add_global_arguments('-DSTAP_SDT_V2',
- native: false, language: ['c', 'cpp', 'objc'])
+ native: false, language: all_languages)
endif
endif
if targetos == 'windows'
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--no-seh', '-Wl,--nxcompat')
- # Disable ASLR for debug builds to allow debugging with gdb
- if get_option('optimization') == '0'
- qemu_ldflags += cc.get_supported_link_arguments('-Wl,--dynamicbase')
- endif
+ qemu_ldflags += cc.get_supported_link_arguments('-Wl,--dynamicbase', '-Wl,--high-entropy-va')
endif
if get_option('gprof')
if get_option('fuzzing')
add_project_link_arguments(['-Wl,-T,',
(meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')],
- native: false, language: ['c', 'cpp', 'objc'])
+ native: false, language: all_languages)
# Specify a filter to only instrument code that is directly related to
# virtual-devices.
args: ['-fsanitize-coverage-allowlist=/dev/null',
'-fsanitize-coverage=trace-pc'] )
add_global_arguments('-fsanitize-coverage-allowlist=instrumentation-filter',
- native: false, language: ['c', 'cpp', 'objc'])
+ native: false, language: all_languages)
endif
if get_option('fuzzing_engine') == ''
# everything with fsanitize=fuzzer-no-link. Otherwise, the linker will be
# unable to bind the fuzzer-related callbacks added by instrumentation.
add_global_arguments('-fsanitize=fuzzer-no-link',
- native: false, language: ['c', 'cpp', 'objc'])
+ native: false, language: all_languages)
add_global_link_arguments('-fsanitize=fuzzer-no-link',
- native: false, language: ['c', 'cpp', 'objc'])
+ native: false, language: all_languages)
# 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']
endif
endif
-add_global_arguments(qemu_cflags, native: false, language: ['c'])
-add_global_arguments(qemu_objcflags, native: false, language: ['objc'])
-
# Check that the C++ compiler exists and works with the C compiler.
link_language = 'c'
linker = cc
qemu_cxxflags = []
-if add_languages('cpp', required: false, native: false)
- cxx = meson.get_compiler('cpp')
+if 'cpp' in all_languages
add_global_arguments(['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'],
native: false, language: 'cpp')
foreach k: qemu_cflags
qemu_cxxflags += [k]
endif
endforeach
- add_global_arguments(qemu_cxxflags, native: false, language: 'cpp')
if cxx.links(files('scripts/main.c'), args: qemu_cflags)
link_language = 'cpp'
qemu_ldflags += linker.get_supported_link_arguments('-Wl,--warn-common')
endif
-add_global_link_arguments(qemu_ldflags, native: false, language: ['c', 'cpp', 'objc'])
+add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
+add_global_arguments(qemu_cflags, native: false, language: 'c')
+add_global_arguments(qemu_cxxflags, native: false, language: 'cpp')
+add_global_arguments(qemu_objcflags, native: false, language: 'objc')
if targetos == 'linux'
add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
'-isystem', 'linux-headers',
- language: ['c', 'cpp'])
+ language: all_languages)
endif
add_project_arguments('-iquote', '.',
'-iquote', meson.current_source_dir(),
'-iquote', meson.current_source_dir() / 'include',
- language: ['c', 'cpp', 'objc'])
-
-if host_machine.system() == 'darwin'
- add_languages('objc', required: false, native: false)
-endif
+ language: all_languages)
sparse = find_program('cgcc', required: get_option('sparse'))
if sparse.found()
endif
if get_option('tcg_interpreter')
tcg_arch = 'tci'
+ config_host += { 'CONFIG_TCG_INTERPRETER': 'y' }
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: ['c', 'cpp', 'objc'])
+ language: all_languages)
accelerators += 'CONFIG_TCG'
config_host += { 'CONFIG_TCG': 'y' }
# The path to glib.h is added to all compilation commands. This was
# grandfathered in from the QEMU Makefiles.
add_project_arguments(config_host['GLIB_CFLAGS'].split(),
- native: false, language: ['c', 'cpp', 'objc'])
+ native: false, language: all_languages)
glib = declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split(),
link_args: config_host['GLIB_LIBS'].split(),
version: config_host['GLIB_VERSION'],
endif
endif
+# libdw
+libdw = dependency('libdw',
+ method: 'pkg-config',
+ kwargs: static_kwargs,
+ required: false)
+
#################
# config-host.h #
#################
error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
endif
endif
- add_global_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
- add_global_link_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
+ add_global_arguments(cfi_flags, native: false, language: all_languages)
+ add_global_link_arguments(cfi_flags, native: false, language: all_languages)
endif
have_host_block_device = (targetos != 'darwin' or
config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
config_host_data.set('CONFIG_NUMA', numa.found())
+if numa.found()
+ config_host_data.set('HAVE_NUMA_HAS_PREFERRED_MANY',
+ cc.has_function('numa_has_preferred_many',
+ dependencies: numa))
+endif
config_host_data.set('CONFIG_OPENGL', opengl.found())
config_host_data.set('CONFIG_PROFILER', get_option('profiler'))
config_host_data.set('CONFIG_RBD', rbd.found())
config_host_data.set('CONFIG_CFI', get_option('cfi'))
config_host_data.set('CONFIG_SELINUX', selinux.found())
config_host_data.set('CONFIG_XEN_BACKEND', xen.found())
+config_host_data.set('CONFIG_LIBDW', libdw.found())
if xen.found()
# protect from xen.version() having less than three components
xen_version = xen.version().split('.') + ['0', '0']
config_host_data.set('CONFIG_AVX2_OPT', get_option('avx2') \
.require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX2') \
.require(cc.links('''
- #pragma GCC push_options
- #pragma GCC target("avx2")
#include <cpuid.h>
#include <immintrin.h>
- static int bar(void *a) {
+ static int __attribute__((target("avx2"))) bar(void *a) {
__m256i x = *(__m256i *)a;
return _mm256_testz_si256(x, x);
}
config_host_data.set('CONFIG_AVX512F_OPT', get_option('avx512f') \
.require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512F') \
.require(cc.links('''
- #pragma GCC push_options
- #pragma GCC target("avx512f")
#include <cpuid.h>
#include <immintrin.h>
- static int bar(void *a) {
+ static int __attribute__((target("avx512f"))) bar(void *a) {
__m512i x = *(__m512i *)a;
return _mm512_test_epi64_mask(x, x);
}
'xtensa' : ['CONFIG_XTENSA_DIS'],
'loongarch' : ['CONFIG_LOONGARCH_DIS'],
}
-if link_language == 'cpp'
- disassemblers += {
- 'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
- }
-endif
have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
host_kconfig = \
if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
config_target += { sym: 'y' }
config_all += { sym: 'y' }
- if sym == 'CONFIG_TCG' and tcg_arch == 'tci'
- config_target += { 'CONFIG_TCG_INTERPRETER': 'y' }
- endif
if target in modular_tcg
config_target += { 'CONFIG_TCG_MODULAR': 'y' }
else
if targetos == 'darwin'
summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
endif
-summary_info += {'CFLAGS': ' '.join(get_option('c_args')
- + ['-O' + get_option('optimization')]
- + (get_option('debug') ? ['-g'] : []))}
+option_cflags = (get_option('debug') ? ['-g'] : [])
+if get_option('optimization') != 'plain'
+ option_cflags += ['-O' + get_option('optimization')]
+endif
+summary_info += {'CFLAGS': ' '.join(get_option('c_args') + option_cflags)}
if link_language == 'cpp'
- summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args')
- + ['-O' + get_option('optimization')]
- + (get_option('debug') ? ['-g'] : []))}
+ summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args') + option_cflags)}
endif
if targetos == 'darwin'
- summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args')
- + ['-O' + get_option('optimization')]
- + (get_option('debug') ? ['-g'] : []))}
+ summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args') + option_cflags)}
endif
link_args = get_option(link_language + '_link_args')
if link_args.length() > 0
summary_info += {'LDFLAGS': ' '.join(link_args)}
endif
summary_info += {'QEMU_CFLAGS': ' '.join(qemu_cflags)}
-summary_info += {'QEMU_CXXFLAGS': ' '.join(qemu_cxxflags)}
-summary_info += {'QEMU_OBJCFLAGS': ' '.join(qemu_objcflags)}
+if 'cpp' in all_languages
+ summary_info += {'QEMU_CXXFLAGS': ' '.join(qemu_cxxflags)}
+endif
+if 'objc' in all_languages
+ summary_info += {'QEMU_OBJCFLAGS': ' '.join(qemu_objcflags)}
+endif
summary_info += {'QEMU_LDFLAGS': ' '.join(qemu_ldflags)}
summary_info += {'profiler': get_option('profiler')}
summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
# Dummy dependency, keep .found()
summary_info += {'FUSE lseek': fuse_lseek.found()}
summary_info += {'selinux': selinux}
+summary_info += {'libdw': libdw}
summary(summary_info, bool_yn: true, section: 'Dependencies')
if not supported_cpus.contains(cpu)