linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Aditya Gupta <adityag@linux.ibm.com>,
	"Steinar H. Gunderson" <sesse@google.com>,
	Charlie Jenkins <charlie@rivosinc.com>,
	Changbin Du <changbin.du@huawei.com>,
	"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
	James Clark <james.clark@linaro.org>,
	Kajol Jain <kjain@linux.ibm.com>,
	Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
	Li Huafei <lihuafei1@huawei.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Andi Kleen <ak@linux.intel.com>,
	Chaitanya S Prakash <chaitanyas.prakash@arm.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	llvm@lists.linux.dev, Song Liu <song@kernel.org>,
	bpf@vger.kernel.org
Subject: Re: [PATCH v4 06/19] perf capstone: Support for dlopen-ing libcapstone.so
Date: Fri, 27 Jun 2025 12:26:50 -0700	[thread overview]
Message-ID: <aF7wesWHTv_Wp-8y@google.com> (raw)
In-Reply-To: <CAP-5=fXLUO3yvSmM4nSnNV_qQGGLP_XTcfPgOhgOkuaNnr3Hvw@mail.gmail.com>

On Fri, Jun 27, 2025 at 09:44:02AM -0700, Ian Rogers wrote:
> On Thu, Jun 26, 2025 at 9:53 PM Ian Rogers <irogers@google.com> wrote:
> >
> > On Thu, Jun 26, 2025 at 4:19 PM Namhyung Kim <namhyung@kernel.org> wrote:
> > >
> > > On Thu, Apr 17, 2025 at 04:07:27PM -0700, Ian Rogers wrote:
> > > > If perf wasn't built against libcapstone, no HAVE_LIBCAPSTONE_SUPPORT,
> > > > support dlopen-ing libcapstone.so and then calling the necessary
> > > > functions by looking them up using dlsym. Reverse engineer the types
> > > > in the API using pahole, adding only what's used in the perf code or
> > > > necessary for the sake of struct size and alignment.
> > >
> > > I still think it's simpler to require capstone headers at build time and
> > > add LIBCAPSTONE_DYNAMIC=1 or something to support dlopen.
> >
> > I agree, having a header file avoids the need to declare the header
> > file values. This is simpler. Can we make the build require
> > libcapstone and libLLVM in the same way that libtraceevent is
> > required? That is you have to explicitly build with NO_LIBTRACEEVENT=1
> > to get a no libtraceevent build to succeed. If we don't do this then
> > having LIBCAPSTONE_DYNAMIC will most likely be an unused option and
> > not worth carrying in the code base, I think that's sad. If we require
> > the libraries I don't like the idea of people arguing, "why do I need
> > to install libcapstone and libLLVM just to get the kernel/perf to
> > build now?" The non-simple, but still not very complex, approach taken
> > here was taken as a compromise to get the best result (a perf that
> > gets faster, BPF support, .. when libraries are available without
> > explicitly depending on them) while trying not to offend kernel
> > developers who are often trying to build on minimal systems.
> 
> Fwiw, a situation that I think is analogous (and was playing on my
> mind while writing the code) is that we don't require python to build
> perf and carry around empty-pmu-events.c:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/pmu-events/empty-pmu-events.c?h=perf-tools-next
> It would be simpler (in the code base and in general) to require
> everyone building perf to have python.
> Having python on a system seems less of a stretch than requiring
> libcapstone and libLLVM.
> 
> If we keep the existing build approach, optional capstone and libLLVM
> by detecting it as a feature, then just linking against the libraries
> is natural. Someone would need to know they care about optionality and
> enable LIBCAPSTONE_DYNAMIC=1. An average build where the libraries
> weren't present would lose the libcapstone and libLLVM support. We
> could warn about this situation but some people are upset about build
> warnings, and if we do warn we could be pushing people into just
> linking against libcapstone and libLLVM which seems like we'll fall
> foul of the, "perf has too many library dependencies," complaint. We
> could warn about linking against libraries when there is a _DYNAMIC
> alternative like this available, but again people don't like build
> warnings and they could legitimately want to link against libcapstone
> or libLLVM.
> 
> Anyway, that's why I ended up with the code in this state, to best try
> to play off all the different compromises and complaints that have
> been dealt with in the past.

I can see your point.  Adding new build flags is likely to be unused and
forgotten.

But I also think is that this dlopen support is mostly useful to distro
package managers who want to support more flexible environment and
regular dynamic linking is preferred to local builds over dlopen.  Then
adding a note to a pull request and contacting them directly (if needed)
might work?

Thanks,
Namhyung


  reply	other threads:[~2025-06-27 19:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17 23:07 [PATCH v4 00/19] Support dynamic opening of capstone/llvm remove BUILD_NONDISTRO Ian Rogers
2025-04-17 23:07 ` [PATCH v4 01/19] perf build: Remove libtracefs configuration Ian Rogers
2025-04-17 23:07 ` [PATCH v4 02/19] perf map: Constify objdump offset/address conversion APIs Ian Rogers
2025-04-17 23:07 ` [PATCH v4 03/19] perf capstone: Move capstone functionality into its own file Ian Rogers
2025-04-17 23:07 ` [PATCH v4 04/19] perf llvm: Move llvm " Ian Rogers
2025-04-17 23:07 ` [PATCH v4 05/19] perf capstone: Remove open_capstone_handle Ian Rogers
2025-04-17 23:07 ` [PATCH v4 06/19] perf capstone: Support for dlopen-ing libcapstone.so Ian Rogers
2025-06-26 23:19   ` Namhyung Kim
2025-06-27  4:53     ` Ian Rogers
2025-06-27 16:44       ` Ian Rogers
2025-06-27 19:26         ` Namhyung Kim [this message]
2025-06-27 23:11           ` Ian Rogers
2025-04-17 23:07 ` [PATCH v4 07/19] perf llvm: Support for dlopen-ing libLLVM.so Ian Rogers
2025-04-17 23:07 ` [PATCH v4 08/19] perf llvm: Mangle libperf-llvm.so function names Ian Rogers
2025-04-17 23:07 ` [PATCH v4 09/19] perf dso: Move read_symbol from llvm/capstone to dso Ian Rogers
2025-04-17 23:07 ` [PATCH v4 10/19] perf dso: Support BPF programs in dso__read_symbol Ian Rogers
2025-04-17 23:07 ` [PATCH v4 11/19] perf llvm: Disassemble cleanup Ian Rogers
2025-04-17 23:07 ` [PATCH v4 12/19] perf dso: Clean up read_symbol error handling Ian Rogers
2025-04-17 23:07 ` [PATCH v4 13/19] perf build: Remove libbfd support Ian Rogers
2025-04-17 23:07 ` [PATCH v4 14/19] perf build: Remove libiberty support Ian Rogers
2025-04-17 23:07 ` [PATCH v4 15/19] perf build: Remove unused defines Ian Rogers
2025-04-17 23:07 ` [PATCH v4 16/19] perf disasm: Remove disasm_bpf Ian Rogers
2025-04-17 23:07 ` [PATCH v4 17/19] perf disasm: Make ins__scnprintf and ins__is_nop static Ian Rogers
2025-04-17 23:07 ` [PATCH v4 18/19] perf srcline: Fallback between addr2line implementations Ian Rogers
2025-04-17 23:07 ` [PATCH v4 19/19] perf disasm: Remove unused evsel from annotate_args Ian Rogers
2025-04-18 21:29 ` [PATCH v4 00/19] Support dynamic opening of capstone/llvm remove BUILD_NONDISTRO Arnaldo Carvalho de Melo
2025-04-19  4:22   ` Ian Rogers
     [not found]     ` <CA+JHD93NCu5VeP9b+DzMm0f0YHwJLRFJeHNtWogx6wKFrHi8Yw@mail.gmail.com>
2025-05-27 20:45       ` Ian Rogers

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=aF7wesWHTv_Wp-8y@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adityag@linux.ibm.com \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=bpf@vger.kernel.org \
    --cc=chaitanyas.prakash@arm.com \
    --cc=changbin.du@huawei.com \
    --cc=charlie@rivosinc.com \
    --cc=dvyukov@google.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kan.liang@linux.intel.com \
    --cc=kjain@linux.ibm.com \
    --cc=lihuafei1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=peterz@infradead.org \
    --cc=sesse@google.com \
    --cc=song@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;
as well as URLs for NNTP newsgroup(s).