aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-10-05 11:25:55 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-10-05 11:25:55 +0100
commit671ad7c4468f795b66b4cd8f376f1b1ce6701b63 (patch)
treea5b9838f62c5902965f82df211c2a018ae4b7a84 /meson.build
parent469e72ab7dbbd7ff4ee601e5ea7c29545d46593b (diff)
parentc6d3da962f058bca09b25f99da35436816fb6de8 (diff)
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-cap-20201003' into staging
Update capstone submodule from v3.0.5 to v5 ("next"). Convert submodule build to meson. Enable capstone disassembly for s390x. Code cleanups in disas.c # gpg: Signature made Sat 03 Oct 2020 10:33:44 BST # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full] # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F * remotes/rth-gitlab/tags/pull-cap-20201003: disas/capstone: Add skipdata hook for s390x disas: Enable capstone disassembly for s390x disas: Split out capstone code to disas/capstone.c disas: Configure capstone for aarch64 host without libvixl disas: Cleanup plugin_disas disas: Use qemu/bswap.h for bfd endian loads disas: Clean up CPUDebug initialization disas: Move host asm annotations to tb_gen_code capstone: Require version 4.0 from a system library capstone: Update to upstream "next" branch capstone: Convert Makefile bits to meson bits Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build123
1 files changed, 116 insertions, 7 deletions
diff --git a/meson.build b/meson.build
index 0f0cc21d16..20f6ad774a 100644
--- a/meson.build
+++ b/meson.build
@@ -10,6 +10,7 @@ else
keyval = import('unstable-keyval')
endif
ss = import('sourceset')
+fs = import('fs')
sh = find_program('sh')
cc = meson.get_compiler('c')
@@ -495,11 +496,6 @@ if 'CONFIG_USB_LIBUSB' in config_host
libusb = declare_dependency(compile_args: config_host['LIBUSB_CFLAGS'].split(),
link_args: config_host['LIBUSB_LIBS'].split())
endif
-capstone = not_found
-if 'CONFIG_CAPSTONE' in config_host
- capstone = declare_dependency(compile_args: config_host['CAPSTONE_CFLAGS'].split(),
- link_args: config_host['CAPSTONE_LIBS'].split())
-endif
libpmem = not_found
if 'CONFIG_LIBPMEM' in config_host
libpmem = declare_dependency(compile_args: config_host['LIBPMEM_CFLAGS'].split(),
@@ -581,7 +577,6 @@ foreach k, v: config_host
config_host_data.set(k, v == 'y' ? 1 : v)
endif
endforeach
-genh += configure_file(output: 'config-host.h', configuration: config_host_data)
minikconf = find_program('scripts/minikconf.py')
config_all = {}
@@ -736,6 +731,119 @@ config_all += {
'CONFIG_ALL': true,
}
+# Submodules
+
+capstone = not_found
+capstone_opt = get_option('capstone')
+if capstone_opt in ['enabled', 'auto', 'system']
+ have_internal = fs.exists(meson.current_source_dir() / 'capstone/Makefile')
+ capstone = dependency('capstone', version: '>=4.0',
+ static: enable_static, method: 'pkg-config',
+ required: capstone_opt == 'system' or
+ capstone_opt == 'enabled' and not have_internal)
+ if capstone.found()
+ capstone_opt = 'system'
+ elif have_internal
+ capstone_opt = 'internal'
+ else
+ capstone_opt = 'disabled'
+ endif
+endif
+if capstone_opt == 'internal'
+ capstone_data = configuration_data()
+ capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1')
+
+ capstone_files = files(
+ 'capstone/cs.c',
+ 'capstone/MCInst.c',
+ 'capstone/MCInstrDesc.c',
+ 'capstone/MCRegisterInfo.c',
+ 'capstone/SStream.c',
+ 'capstone/utils.c'
+ )
+
+ if 'CONFIG_ARM_DIS' in config_all_disas
+ capstone_data.set('CAPSTONE_HAS_ARM', '1')
+ capstone_files += files(
+ 'capstone/arch/ARM/ARMDisassembler.c',
+ 'capstone/arch/ARM/ARMInstPrinter.c',
+ 'capstone/arch/ARM/ARMMapping.c',
+ 'capstone/arch/ARM/ARMModule.c'
+ )
+ endif
+
+ # FIXME: This config entry currently depends on a c++ compiler.
+ # Which is needed for building libvixl, but not for capstone.
+ if 'CONFIG_ARM_A64_DIS' in config_all_disas
+ capstone_data.set('CAPSTONE_HAS_ARM64', '1')
+ capstone_files += files(
+ 'capstone/arch/AArch64/AArch64BaseInfo.c',
+ 'capstone/arch/AArch64/AArch64Disassembler.c',
+ 'capstone/arch/AArch64/AArch64InstPrinter.c',
+ 'capstone/arch/AArch64/AArch64Mapping.c',
+ 'capstone/arch/AArch64/AArch64Module.c'
+ )
+ endif
+
+ if 'CONFIG_PPC_DIS' in config_all_disas
+ capstone_data.set('CAPSTONE_HAS_POWERPC', '1')
+ capstone_files += files(
+ 'capstone/arch/PowerPC/PPCDisassembler.c',
+ 'capstone/arch/PowerPC/PPCInstPrinter.c',
+ 'capstone/arch/PowerPC/PPCMapping.c',
+ 'capstone/arch/PowerPC/PPCModule.c'
+ )
+ endif
+
+ if 'CONFIG_S390_DIS' in config_all_disas
+ capstone_data.set('CAPSTONE_HAS_SYSZ', '1')
+ capstone_files += files(
+ 'capstone/arch/SystemZ/SystemZDisassembler.c',
+ 'capstone/arch/SystemZ/SystemZInstPrinter.c',
+ 'capstone/arch/SystemZ/SystemZMapping.c',
+ 'capstone/arch/SystemZ/SystemZModule.c',
+ 'capstone/arch/SystemZ/SystemZMCTargetDesc.c'
+ )
+ endif
+
+ if 'CONFIG_I386_DIS' in config_all_disas
+ capstone_data.set('CAPSTONE_HAS_X86', 1)
+ capstone_files += files(
+ 'capstone/arch/X86/X86Disassembler.c',
+ 'capstone/arch/X86/X86DisassemblerDecoder.c',
+ 'capstone/arch/X86/X86ATTInstPrinter.c',
+ 'capstone/arch/X86/X86IntelInstPrinter.c',
+ 'capstone/arch/X86/X86InstPrinterCommon.c',
+ 'capstone/arch/X86/X86Mapping.c',
+ 'capstone/arch/X86/X86Module.c'
+ )
+ endif
+
+ configure_file(output: 'capstone-defs.h', configuration: capstone_data)
+
+ capstone_cargs = [
+ # FIXME: There does not seem to be a way to completely replace the c_args
+ # that come from add_project_arguments() -- we can only add to them.
+ # So: disable all warnings with a big hammer.
+ '-Wno-error', '-w',
+
+ # Include all configuration defines via a header file, which will wind up
+ # as a dependency on the object file, and thus changes here will result
+ # in a rebuild.
+ '-include', 'capstone-defs.h'
+ ]
+
+ libcapstone = static_library('capstone',
+ sources: capstone_files,
+ c_args: capstone_cargs,
+ include_directories: 'capstone/include')
+ capstone = declare_dependency(link_with: libcapstone,
+ include_directories: 'capstone/include/capstone')
+endif
+config_host_data.set('CONFIG_CAPSTONE', capstone.found())
+
+genh += configure_file(output: 'config-host.h', configuration: config_host_data)
+
# Generators
hxtool = find_program('scripts/hxtool')
@@ -1007,6 +1115,7 @@ common_ss.add(files('cpus-common.c'))
subdir('softmmu')
+common_ss.add(capstone)
specific_ss.add(files('disas.c', 'exec.c', 'gdbstub.c'), capstone, libpmem, libdaxctl)
specific_ss.add(files('exec-vary.c'))
specific_ss.add(when: 'CONFIG_TCG', if_true: files(
@@ -1566,7 +1675,7 @@ summary_info += {'vvfat support': config_host.has_key('CONFIG_VVFAT')}
summary_info += {'qed support': config_host.has_key('CONFIG_QED')}
summary_info += {'parallels support': config_host.has_key('CONFIG_PARALLELS')}
summary_info += {'sheepdog support': config_host.has_key('CONFIG_SHEEPDOG')}
-summary_info += {'capstone': config_host.has_key('CONFIG_CAPSTONE')}
+summary_info += {'capstone': capstone_opt == 'disabled' ? false : capstone_opt}
summary_info += {'libpmem support': config_host.has_key('CONFIG_LIBPMEM')}
summary_info += {'libdaxctl support': config_host.has_key('CONFIG_LIBDAXCTL')}
summary_info += {'libudev': libudev.found()}