From nobody Tue Feb 10 09:58:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1600041842; cv=none; d=zohomail.com; s=zohoarc; b=NachzzpQVLhsrzltU6fhz4Q9EDy/DzJev3AE5sXivdvyUR/F6LojGi+42BXZb80+tI++NifKatgApgLh2KhGNizGay9TF5CRhpgHKju3fD04QweIZQIHfZV7xVp+HSZ+VJSIhxQw7J7aR8WuRtNJGt9uKw4tJpPprJXAv/S66rU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600041842; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1udUAr8a7IXOV2H9rA8omIwMHcyQUC+GvcI+H0onXWA=; b=JQmjQ5kvgJZ5vy+gJEh+xkzi0XcqphT0XrZ/Xv41BO+luEyWNv+8wtaixB1JCyrstJYR87peQORPx+2mTwcOkoMsfMHWxwAPKdB+CaHyL8Rwkwbgi1nqNZnxS1gkPGm0aN5ACEnh3QPrwdkHB65+sgA/aPoOdy4BTN8+JFf8CvM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600041842634828.6129280892211; Sun, 13 Sep 2020 17:04:02 -0700 (PDT) Received: from localhost ([::1]:37882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHbyT-0006RS-DS for importer@patchew.org; Sun, 13 Sep 2020 20:04:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHbwW-0002Ua-8i for qemu-devel@nongnu.org; Sun, 13 Sep 2020 20:02:00 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:42415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kHbwU-0004BW-14 for qemu-devel@nongnu.org; Sun, 13 Sep 2020 20:01:59 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d6so11043556pfn.9 for ; Sun, 13 Sep 2020 17:01:57 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id 31sm6538252pgs.59.2020.09.13.17.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 17:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1udUAr8a7IXOV2H9rA8omIwMHcyQUC+GvcI+H0onXWA=; b=tH9ekyKbKNqBu7NOdNeDYHc1kHfGZjX9Q4P+BttxtUy7ZI073n3WDF+AnHW3gpSyiI T0KTeU697vw0Ig5J+9TDKOSUhVOiEw8xICE2gHJ4vHCmC+gbL5w1k3zkB1mA8FFh12sJ KCuvbrffdclxn8MPs1fe3eCwR1ft80V+UOh1+UlTqMm/6E1FcedtMNAFUeGquFPnHyHs zVjZhYgC8XjtWRAon7HCfgimsXiG2OHCCJpgspXYj3IZE4/wOUtiiyjNaqc99j9AOJk4 F52ZQ3iWMyAvKnKBQxhmsKGUzgr1VUZqosyl711uZfsHVUkygGW+0o9l4FEpSiAfn7Hb 8LCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1udUAr8a7IXOV2H9rA8omIwMHcyQUC+GvcI+H0onXWA=; b=WUn9Z6HYxB9t44+QAZqxn79xy0bMlhySegYV0+IxsQnhgcxN4PgRsq4MZ0o4EgJOiM sYEfYznhzeKnmtqsRGxTCs/qF3cxCdntHdzXBvjmRys4qjwaMkWa52U+jwwB8f4kdf6j 4ogJ8HYDosi+EMMf/1cUyGqPBl83HJS2QC5xf++pBnFT9PoWjm1yP+pz/yZT1ysgXX0c uaqgvD9l90a+L8AToD814I12sNUu7N9kcXlidT6YDUwvBKhKu1Ki3blMCbnS/7QDj4fL mEfEVPvDarwPV3Ayc/dDrZJWfuuTeSda6htto56qLwZfG/agG0pybenWjBCDSt5SoncJ bH7g== X-Gm-Message-State: AOAM530OHNcc8tdXrmh+wb+QWsTyiEsh1clOoCaYl4syU7yTk2xiaY+o VmOktKNI/tEb5HzyMwF3O8v90O5gFbFe4Q== X-Google-Smtp-Source: ABdhPJxwZNNflMubO9tL+ul472twpJwRlhJHLpU9uoUUxbux6A+eJ72GTvjuqkI9AVYEKzI/fXfqAA== X-Received: by 2002:a17:902:eb05:b029:d1:8c50:b1bc with SMTP id l5-20020a170902eb05b02900d18c50b1bcmr11606416plb.35.1600041716306; Sun, 13 Sep 2020 17:01:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 01/11] capstone: Convert Makefile bits to meson bits Date: Sun, 13 Sep 2020 17:01:43 -0700 Message-Id: <20200914000153.1725632-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200914000153.1725632-1-richard.henderson@linaro.org> References: <20200914000153.1725632-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , luoyonggang@gmail.com, alex.bennee@linaro.org, thuth@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" There are better ways to do this, e.g. meson cmake subproject, but that requires cmake 3.7 and some of our CI environments only provide cmake 3.5. Nor can we add a meson.build file to capstone/, because the git submodule would then always report "untracked files". Fixing that would require creating our own branch on the qemu git mirror, at which point we could just as easily create a native meson subproject. In leiu, build the library via the main meson.build. This improves the current state of affairs in that we will re-link the qemu executables against a changed libcapstone.a, which we wouldn't do before-hand. In addition, the use of the confuration header file instead of command-line -DEFINES means that we will rebuild the capstone objects with changes to meson.build. Cc: Paolo Bonzini Signed-off-by: Richard Henderson --- configure | 24 +++---------- Makefile | 16 --------- meson.build | 89 ++++++++++++++++++++++++++++++++++++++++++++--- meson_options.txt | 3 ++ 4 files changed, 91 insertions(+), 41 deletions(-) diff --git a/configure b/configure index 2b6a1196da..4fc5c15283 100755 --- a/configure +++ b/configure @@ -5146,27 +5146,15 @@ case "$capstone" in esac =20 case "$capstone" in - git | internal) + git) if test "$capstone" =3D git; then git_submodules=3D"${git_submodules} capstone" fi - mkdir -p capstone - if test "$mingw32" =3D "yes"; then - LIBCAPSTONE=3Dcapstone.lib - else - LIBCAPSTONE=3Dlibcapstone.a - fi - capstone_libs=3D"-Lcapstone -lcapstone" - capstone_cflags=3D"-I${source_path}/capstone/include" ;; =20 - system) - capstone_libs=3D"$($pkg_config --libs capstone)" - capstone_cflags=3D"$($pkg_config --cflags capstone)" + internal | system | no) ;; =20 - no) - ;; *) error_exit "Unknown state for capstone: $capstone" ;; @@ -7290,8 +7278,6 @@ if test "$ivshmem" =3D "yes" ; then fi if test "$capstone" !=3D "no" ; then echo "CONFIG_CAPSTONE=3Dy" >> $config_host_mak - echo "CAPSTONE_CFLAGS=3D$capstone_cflags" >> $config_host_mak - echo "CAPSTONE_LIBS=3D$capstone_libs" >> $config_host_mak fi if test "$debug_mutex" =3D "yes" ; then echo "CONFIG_DEBUG_MUTEX=3Dy" >> $config_host_mak @@ -7816,9 +7802,6 @@ done # for target in $targets if [ "$fdt" =3D "git" ]; then subdirs=3D"$subdirs dtc" fi -if [ "$capstone" =3D "git" -o "$capstone" =3D "internal" ]; then - subdirs=3D"$subdirs capstone" -fi echo "SUBDIRS=3D$subdirs" >> $config_host_mak if test -n "$LIBCAPSTONE"; then echo "LIBCAPSTONE=3D$LIBCAPSTONE" >> $config_host_mak @@ -8005,7 +7988,8 @@ NINJA=3D${ninja:-$PWD/ninjatool} $meson setup \ -Db_coverage=3D$(if test "$gcov" =3D yes; then echo true; else ech= o false; fi) \ -Dsdl=3D$sdl -Dsdl_image=3D$sdl_image \ -Dvnc=3D$vnc -Dvnc_sasl=3D$vnc_sasl -Dvnc_jpeg=3D$vnc_jpeg -Dvnc_png=3D$v= nc_png \ - -Dgettext=3D$gettext -Dxkbcommon=3D$xkbcommon -Du2f=3D$u2f\ + -Dgettext=3D$gettext -Dxkbcommon=3D$xkbcommon -Du2f=3D$u2f \ + -Dcapstone=3D$capstone \ $cross_arg \ "$PWD" "$source_path" =20 diff --git a/Makefile b/Makefile index 57f72f56c6..0746aa83e3 100644 --- a/Makefile +++ b/Makefile @@ -156,22 +156,6 @@ dtc/all: .git-submodule-status dtc/libfdt dtc/%: .git-submodule-status @mkdir -p $@ =20 -# Overriding CFLAGS causes us to lose defines added in the sub-makefile. -# Not overriding CFLAGS leads to mis-matches between compilation modes. -# Therefore we replicate some of the logic in the sub-makefile. -# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't; -# no need to annoy QEMU developers with such things. -CAP_CFLAGS =3D $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS)) $(CAPSTONE_CFLAGS) -CAP_CFLAGS +=3D -DCAPSTONE_USE_SYS_DYN_MEM -CAP_CFLAGS +=3D -DCAPSTONE_HAS_ARM -CAP_CFLAGS +=3D -DCAPSTONE_HAS_ARM64 -CAP_CFLAGS +=3D -DCAPSTONE_HAS_POWERPC -CAP_CFLAGS +=3D -DCAPSTONE_HAS_X86 - -.PHONY: capstone/all -capstone/all: .git-submodule-status - $(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=3Dno= BUILDDIR=3D"$(BUILD_DIR)/capstone" CC=3D"$(CC)" AR=3D"$(AR)" LD=3D"$(LD)" = RANLIB=3D"$(RANLIB)" CFLAGS=3D"$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_D= IR)/capstone/$(LIBCAPSTONE)) - .PHONY: slirp/all slirp/all: .git-submodule-status $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp \ diff --git a/meson.build b/meson.build index 690723b470..4417de1e14 100644 --- a/meson.build +++ b/meson.build @@ -415,11 +415,6 @@ if 'CONFIG_USB_LIBUSB' in config_host libusb =3D declare_dependency(compile_args: config_host['LIBUSB_CFLAGS']= .split(), link_args: config_host['LIBUSB_LIBS'].split(= )) endif -capstone =3D not_found -if 'CONFIG_CAPSTONE' in config_host - capstone =3D declare_dependency(compile_args: config_host['CAPSTONE_CFLA= GS'].split(), - link_args: config_host['CAPSTONE_LIBS'].sp= lit()) -endif libpmem =3D not_found if 'CONFIG_LIBPMEM' in config_host libpmem =3D declare_dependency(compile_args: config_host['LIBPMEM_CFLAGS= '].split(), @@ -616,6 +611,90 @@ config_all +=3D { 'CONFIG_ALL': true, } =20 +if get_option('capstone') =3D=3D 'no' + capstone =3D not_found +elif get_option('capstone') =3D=3D 'system' + capstone =3D dependency('capstone', static: enable_static, required: tru= e) +else + capstone_data =3D configuration_data() + capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1') + + capstone_files =3D 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 +=3D 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 +=3D 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 +=3D files( + 'capstone/arch/PowerPC/PPCDisassembler.c', + 'capstone/arch/PowerPC/PPCInstPrinter.c', + 'capstone/arch/PowerPC/PPCMapping.c', + 'capstone/arch/PowerPC/PPCModule.c' + ) + endif + + if 'CONFIG_I386_DIS' in config_all_disas + capstone_data.set('CAPSTONE_HAS_X86', 1) + capstone_files +=3D files( + 'capstone/arch/X86/X86Disassembler.c', + 'capstone/arch/X86/X86DisassemblerDecoder.c', + 'capstone/arch/X86/X86ATTInstPrinter.c', + 'capstone/arch/X86/X86IntelInstPrinter.c', + 'capstone/arch/X86/X86Mapping.c', + 'capstone/arch/X86/X86Module.c' + ) + endif + + configure_file(output: 'capstone-defs.h', + configuration: capstone_data) + + capstone_cargs =3D [ + # FIXME: There does not seem to be a way to completely replace the c_a= rgs + # 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 =3D static_library('capstone', + sources: capstone_files, + c_args: capstone_cargs, + include_directories: 'capstone/include') + capstone =3D declare_dependency(link_with: libcapstone, + include_directories: 'capstone/include') +endif + # Generators =20 hxtool =3D find_program('scripts/hxtool') diff --git a/meson_options.txt b/meson_options.txt index 543cf70043..99ecd44aca 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -22,3 +22,6 @@ option('vnc_sasl', type : 'feature', value : 'auto', description: 'SASL authentication for VNC server') option('xkbcommon', type : 'feature', value : 'auto', description: 'xkbcommon support') + +option('capstone', type: 'string', value: 'no', + description: 'capstone support') --=20 2.25.1