linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Ravi Bangoria <ravi.bangoria@amd.com>,
	Qi Liu <liuqi115@huawei.com>, Leo Yan <leo.yan@linaro.org>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] perf build: Don't compile demangle-cxx.cpp if not necessary
Date: Fri, 26 May 2023 15:26:55 -0300	[thread overview]
Message-ID: <ZHD57wlaQnY9dqEB@kernel.org> (raw)
In-Reply-To: <CAP-5=fXuKqU=ZD4G3t1H=dD1SMghiVXHj5YTFhX+Jj98jAiVUg@mail.gmail.com>

Em Wed, Apr 26, 2023 at 10:27:42PM -0700, Ian Rogers escreveu:
> On Mon, Apr 17, 2023 at 12:25 PM Ian Rogers <irogers@google.com> wrote:
> >
> > demangle-cxx.cpp requires a C++ compiler, but feature checks may fail
> > because of the absence of this. Add a CONFIG_CXX_DEMANGLE so that the
> > source isn't built if not supported. Copy libbfd and cplus demangle
> > variants to a weak symbol-elf.c version so they aren't dependent on
> > C++. These variants are only built with the build option
> > BUILD_NONDISTRO=1.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> 
> Testing on arm and noticed we hadn't picked this one up.

Thanks, applied.

- Arnaldo

 
> Thanks,
> Ian
> 
> > ---
> >  tools/perf/Makefile.config   |  1 +
> >  tools/perf/util/Build        |  2 +-
> >  tools/perf/util/symbol-elf.c | 27 +++++++++++++++++++++++++++
> >  3 files changed, 29 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index 71442c54c25f..5f0f24b56f50 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -923,6 +923,7 @@ ifndef NO_DEMANGLE
> >      EXTLIBS += -lstdc++
> >      CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
> >      CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
> > +    $(call detected,CONFIG_CXX_DEMANGLE)
> >    endif
> >    ifdef BUILD_NONDISTRO
> >      ifeq ($(filter -liberty,$(EXTLIBS)),)
> > diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> > index bd18fe5f2719..f9df1df1eec0 100644
> > --- a/tools/perf/util/Build
> > +++ b/tools/perf/util/Build
> > @@ -214,7 +214,7 @@ perf-$(CONFIG_ZSTD) += zstd.o
> >
> >  perf-$(CONFIG_LIBCAP) += cap.o
> >
> > -perf-y += demangle-cxx.o
> > +perf-$(CONFIG_CXX_DEMANGLE) += demangle-cxx.o
> >  perf-y += demangle-ocaml.o
> >  perf-y += demangle-java.o
> >  perf-y += demangle-rust.o
> > diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> > index 35724f6a84fa..cd08bdb9824f 100644
> > --- a/tools/perf/util/symbol-elf.c
> > +++ b/tools/perf/util/symbol-elf.c
> > @@ -31,6 +31,13 @@
> >  #include <bfd.h>
> >  #endif
> >
> > +#if defined(HAVE_LIBBFD_SUPPORT) || defined(HAVE_CPLUS_DEMANGLE_SUPPORT)
> > +#ifndef DMGL_PARAMS
> > +#define DMGL_PARAMS     (1 << 0)  /* Include function args */
> > +#define DMGL_ANSI       (1 << 1)  /* Include const, volatile, etc */
> > +#endif
> > +#endif
> > +
> >  #ifndef EM_AARCH64
> >  #define EM_AARCH64     183  /* ARM 64 bit */
> >  #endif
> > @@ -271,6 +278,26 @@ static bool want_demangle(bool is_kernel_sym)
> >         return is_kernel_sym ? symbol_conf.demangle_kernel : symbol_conf.demangle;
> >  }
> >
> > +/*
> > + * Demangle C++ function signature, typically replaced by demangle-cxx.cpp
> > + * version.
> > + */
> > +__weak char *cxx_demangle_sym(const char *str __maybe_unused, bool params __maybe_unused,
> > +                             bool modifiers __maybe_unused)
> > +{
> > +#ifdef HAVE_LIBBFD_SUPPORT
> > +       int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
> > +
> > +       return bfd_demangle(NULL, str, flags);
> > +#elif defined(HAVE_CPLUS_DEMANGLE_SUPPORT)
> > +       int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
> > +
> > +       return cplus_demangle(str, flags);
> > +#else
> > +       return NULL;
> > +#endif
> > +}
> > +
> >  static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
> >  {
> >         char *demangled = NULL;
> > --
> > 2.40.0.634.g4ca3ef3211-goog
> >

-- 

- Arnaldo

      reply	other threads:[~2023-05-26 18:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17 19:25 [PATCH v1] perf build: Don't compile demangle-cxx.cpp if not necessary Ian Rogers
2023-04-27  5:27 ` Ian Rogers
2023-05-26 18:26   ` Arnaldo Carvalho de Melo [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=ZHD57wlaQnY9dqEB@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=liuqi115@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    /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).