mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	 Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	 Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	 James Clark <james.clark@linaro.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
	 linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Leo Yan <leo.yan@arm.com>
Subject: [PATCH] perf capstone: Fix build with Capstone versions before 6
Date: Mon, 13 Jul 2026 12:08:35 +0100	[thread overview]
Message-ID: <20260713-perf_fix_capstone_build-v1-1-796ea08c04db@arm.com> (raw)

The commit 12c4737f55f2 ("perf capstone: Determine architecture from
e_machine") added a RISC-V mapping for Capstone disassembly.

However, the RISC-V arch and mode definitions are only available from
Capstone 6.0.0. Older Capstone headers do not define CS_ARCH_RISCV,
CS_MODE_RISCV64 or CS_MODE_RISCV32, so perf fails to build.

Guard the RISC-V mapping with a Capstone major version check. Also use
CS_MODE_RISCV_C instead of CS_MODE_RISCVC, which is the mode name used
by Capstone 6.

Fixes: 12c4737f55f2 ("perf capstone: Determine architecture from e_machine")
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/util/capstone.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/capstone.c b/tools/perf/util/capstone.c
index 9bba78ee0c5a2e6c86a97ffe69ca4db966bafd9b..99efeb40ed03621e781ef9b888321e28d237a0ca 100644
--- a/tools/perf/util/capstone.c
+++ b/tools/perf/util/capstone.c
@@ -182,10 +182,12 @@ static bool e_machine_to_capstone(uint16_t e_machine, bool is64, bool is_big_end
 		*arch = CS_ARCH_SPARC;
 		*mode |= CS_MODE_V9;
 		return true;
+#if defined(CS_VERSION_MAJOR) && CS_VERSION_MAJOR >= 6
 	case EM_RISCV:
 		*arch = CS_ARCH_RISCV;
-		*mode |= (is64 ? CS_MODE_RISCV64 : CS_MODE_RISCV32) | CS_MODE_RISCVC;
+		*mode |= (is64 ? CS_MODE_RISCV64 : CS_MODE_RISCV32) | CS_MODE_RISCV_C;
 		return true;
+#endif
 	default:
 		return false;
 	}

---
base-commit: ef3af1df4f3372bd8ad47619452a283048b3bc8d
change-id: 20260713-perf_fix_capstone_build-510dc3bfecfb

Best regards,
-- 
Leo Yan <leo.yan@arm.com>


             reply	other threads:[~2026-07-13 11:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 11:08 Leo Yan [this message]
2026-07-13 17:39 ` Namhyung Kim
2026-07-13 18:21   ` Leo Yan
2026-07-13 20:53     ` Namhyung Kim
2026-07-14  8:36       ` Leo Yan
2026-07-14 17:02         ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260713-perf_fix_capstone_build-v1-1-796ea08c04db@arm.com \
    --to=leo.yan@arm.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®