From: Namhyung Kim <namhyung@kernel.org>
To: Leo Yan <leo.yan@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf capstone: Fix build with Capstone versions before 6
Date: Mon, 13 Jul 2026 13:53:55 -0700 [thread overview]
Message-ID: <alVQY7uJzapcfDCr@google.com> (raw)
In-Reply-To: <20260713182133.GC512733@e132581.arm.com>
On Mon, Jul 13, 2026 at 07:21:33PM +0100, Leo Yan wrote:
> Hi Namhyung,
>
> On Mon, Jul 13, 2026 at 10:39:57AM -0700, Namhyung Kim wrote:
> > On Mon, Jul 13, 2026 at 12:08:35PM +0100, Leo Yan wrote:
> > > 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.
> >
> > Please see
> >
> > https://lore.kernel.org/r/20260706234836.815254-1-namhyung@kernel.org
>
> I am a bit concerned that defining the macros directly in perf is a good
> idea, since the Capstone library doesn't actually support the arch/insn
> and the macros merely work around the build.
Yep, the goal is to avoid build errors. Actually it'll fail at runtime
and fallback to other libraries when it tries to use on RISC-V. But I
think it should continue to support old capstones on supported archs.
>
> Perhaps checking the Capstone version would be a safer approach?
I'm not sure. IIUC RISC-V support was added to v5.0 and CS_MODE_RISCV_C
was changed before v6.0 is out. Do you build capstone from source or
use a packaged version?
>
> I have no knowledge for capstone, I will leave this to you to decide which
> is better. I tested your patch, which works well at my side.
Thanks for the test!
Namhyung
prev parent reply other threads:[~2026-07-13 20:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 11:08 [PATCH] perf capstone: Fix build with Capstone versions before 6 Leo Yan
2026-07-13 17:39 ` Namhyung Kim
2026-07-13 18:21 ` Leo Yan
2026-07-13 20:53 ` Namhyung Kim [this message]
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=alVQY7uJzapcfDCr@google.com \
--to=namhyung@kernel.org \
--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=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.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